New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

exstat

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

exstat

useful mathematics / cryptography-related functions

  • 1.1.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by200%
Maintainers
1
Weekly downloads
 
Created
Source

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

median(arr)number

median - finds the median of an array

mean(arr)number

mean - finds the median of an array

toUTF8Array(str)array

toUTF8Array - converts a string to a byte array

binAdd(str1, str2)string

binAdd - add two string representations of binary numbers

binToInt(bin)number

binToInt - convert binary number to integer

trunc(str, len)string

trunc - truncate a string to a certain length

binToHex(str)string

binToHex - convert binary number to hex number

inRange(num, range)boolean

inRange - determine wether a number is within a certain range

mod(a, b)number

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

padZero(num, len)string

padZero - pad a number with zeros

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

paramtypedescription
setarrayset of numbers to normalize
rangearrayrange 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

paramtypedescription
arrarrayarray of numbers

mean(arr) ⇒ number

mean - finds the median of an array

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

paramtypedescription
arrarrayarray of numbers

toUTF8Array(str) ⇒ array

toUTF8Array - converts a string to a byte array

kind: global function returns: array - byte array

paramtypedescription
strstringstring 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

paramtypedescription
str1stringfirst binary string
str2stringsecond binary string

binToInt(bin) ⇒ number

binToInt - convert binary number to integer

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

paramtypedescription
binstringstring representation of binary number

trunc(str, len) ⇒ string

trunc - truncate a string to a certain length

kind: global function returns: string - truncated string

paramtypedescription
strstringstring to be truncated
lennumberlength 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

paramtypedescription
strstringbinary 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.

paramtypedescription
numnumberthe number to check
rangearraythe 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

paramtypedescription
anumbernumber to perform modulo operation on
bnumbernumber 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

paramtypedescription
numnumbernumber to pad
lennumberfinal length of resulting string

FAQs

Package last updated on 27 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc