npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

protaxer

v0.2.0

Published

A package for calculating tax based on a specified rate, designed for use with ProBot.

Downloads

181

Readme

ProTaxer

ProTaxer is a simple npm package for calculating tax based on a specified rate. It is designed for use with ProBot or any other project needing tax calculations.

Features

  • Calculate Tax: Determine the amount of tax based on a given value.
  • Taxed Value: Get the total value including tax.
  • Without Tax: Get the original value before tax was applied.
  • Custom Tax Rate: Set a custom tax rate with a default of 20%.
  • Floating Point Precision: Optionally handle calculations with floating point precision.
  • Discounts: Apply discounts to the initial value before tax calculation.
  • Currency Formatting: Convert values to currency strings.
  • History Tracking: Track historical calculations.

Installation

To install ProTaxer, run:

npm install protaxer

Usage

Basic Usage

import { Taxer } from 'protaxer';

// Create an instance of Taxer with a value
const taxer = new Taxer(100); // Default tax rate is 20%

console.log(`Tax: ${taxer.Tax}`); // Calculate tax
console.log(`Taxed Value: ${taxer.TaxedValue}`); // Calculate value including tax
console.log(`Without Tax: ${taxer.WithoutTax}`); // Calculate value without tax

Custom Tax Rate and Precision

import { Taxer } from 'protaxer';

// Create an instance with a custom tax rate and floating point precision
const taxer = new Taxer(100, 25, true); // Custom tax rate of 25% and float precision

console.log(`Tax: ${taxer.Tax}`); // Calculate tax
console.log(`Taxed Value: ${taxer.TaxedValue}`); // Calculate value including tax
console.log(`Without Tax: ${taxer.WithoutTax}`); // Calculate value without tax

API

Taxer

  • Constructor(value: number, TAX_RATE?: number, float?: boolean)

    • value: The initial value for tax calculations.
    • TAX_RATE: The tax rate to apply (default: 20%).
    • float: Whether to return results as floats (default: false).
  • get Tax()

    • Returns the tax amount.
  • get TaxedValue()

    • Returns the value including tax.
  • get WithoutTax()

    • Returns the value without tax.
  • get NonTax()

    • Returns the value excluding tax.
  • get InclusiveTax()

    • Returns the tax amount from an already taxed value.
  • get ExclusiveTaxedValue()

    • Returns the total value including tax from an already taxed value.
  • set Rate(rate: number)

    • Sets a custom tax rate.
  • set Float(float: boolean)

    • Sets whether results should be returned as floats.
  • Discount(discount: number): number

    • Applies a discount to the initial value before tax calculation.
  • ToJSON()

    • Serializes the instance to a JSON string.
  • ToString()

    • Returns a string representation of the instance.
  • FromJSON(json: string): Taxer

    • Creates an instance from a JSON string.
  • ToCurrencyString(locale: string = 'en-US', currency: string = 'USD'): string

    • Converts the value to a currency string.
  • SaveToHistory()

    • Saves the current calculation to history.
  • FetchHistory()

    • Retrieves the history of calculations.
  • ResetHistory()

    • Clears the history of calculations.
  • ResetRate()

    • Resets the tax rate to the default (20%).
  • ValueString()

    • Returns the value as a formatted string.
  • UnShorthand(float: boolean = true): string

    • Converts a shorthand notation to a full numeric value.
  • Print()

    • Prints a table of tax-related information to the console.

ProBot

  • Constructor(client: Client)

    • client: An instance of the Discord.js Client.
  • On(event: string, handler: (data: Data) => void): void

    • Registers a handler for a specific event.
  • AddUserId(userId: string): void

    • Adds a user ID to the filter list.
  • RemoveUserId(userId: string): void

    • Removes a user ID from the filter list.
  • ClearFilter(): void

    • Clears all user IDs from the filter list.
  • GetLast(): any

    • Retrieves the latest income data.
  • SetNotification(channelId: string, message: string): void

    • Sets up the notification details.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contributing

If you would like to contribute to ProTaxer, please fork the repository and submit a pull request with your changes. Contributions are always welcome!

Questions?

For questions or issues, please open an issue on the GitHub repository.