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

exstat

v1.1.1

Published

useful mathematics / cryptography-related functions

Downloads

12

Readme

exstat

this is a collection of utility functions that I'm currently working on. I've been using them to work on a cryptography library, so that's what they're geared toward.

usage

npm i exstat and then const exstat = require("exstat"). exstat has three groups of functions (exstat.array, exstat.string, and exstat.number), named for the type of input they take. example:

const { array: a, string: s, number: n } = require("exstat");

a.normalize([2, 3, 4, 5, 6], [0, 1])
// returns [ 0, 0.25, 0.5, 0.75, 1 ]

n.inRange(0.5, [0, 1])
// returns true

detailed information is below.

functions

normalize(set, range) ⇒ array

normalize - normalizes an array to a certain range, or the set [0, 1] by default

kind: global function returns: array - normalized set of numbers

| param | type | description | | --- | --- | --- | | set | array | set of numbers to normalize | | range | array | range to normalize to |

median(arr) ⇒ number

median - finds the median of an array

kind: global function returns: number - the median of the array of numbers

| param | type | description | | --- | --- | --- | | arr | array | array of numbers |

mean(arr) ⇒ number

mean - finds the median of an array

kind: global function returns: number - the median of the array

| param | type | description | | --- | --- | --- | | arr | array | array of numbers |

toUTF8Array(str) ⇒ array

toUTF8Array - converts a string to a byte array

kind: global function returns: array - byte array

| param | type | description | | --- | --- | --- | | str | string | string to be converted |

binAdd(str1, str2) ⇒ string

binAdd - add two string representations of binary numbers

kind: global function returns: string - binary representation of the result of the operation

| param | type | description | | --- | --- | --- | | str1 | string | first binary string | | str2 | string | second binary string |

binToInt(bin) ⇒ number

binToInt - convert binary number to integer

kind: global function returns: number - interger result of binary string

| param | type | description | | --- | --- | --- | | bin | string | string representation of binary number |

trunc(str, len) ⇒ string

trunc - truncate a string to a certain length

kind: global function returns: string - truncated string

| param | type | description | | --- | --- | --- | | str | string | string to be truncated | | len | number | length to truncate to |

binToHex(str) ⇒ string

binToHex - convert binary number to hex number

kind: global function returns: string - hexadecimal number from the result of conversion

| param | type | description | | --- | --- | --- | | str | string | binary number to convert |

inRange(num, range) ⇒ boolean

inRange - determine wether a number is within a certain range

kind: global function returns: boolean - returns true if number is in range, false if not.

| param | type | description | | --- | --- | --- | | num | number | the number to check | | range | array | the range that num should be within |

mod(a, b) ⇒ number

mod - finds the remainder after division of one number by another

kind: global function returns: number - result of operation

| param | type | description | | --- | --- | --- | | a | number | number to perform modulo operation on | | b | number | number to perform modulo operation on |

padZero(num, len) ⇒ string

padZero - pad a number with zeros

kind: global function returns: string - string resulting from padding of number with zeros

| param | type | description | | --- | --- | --- | | num | number | number to pad | | len | number | final length of resulting string |