utils 1.0.72
Install from the command line:
Learn more about npm packages
$ npm install @bhoos/utils@1.0.72
Install via package.json:
"@bhoos/utils": "1.0.72"
About this version
Utility functions
Utility functions with a functional programming flavour
- partition : partition a list into two using a predicate
- removeDuplicates
- topologicalSort : find topological sort of a graph (represented a list of all nodes, and a function that returns children nodes of a given node)
String manipulation
- prefixp : check a string for a given prefix.
p
stands for predicate (i.e. functions that return boolean) - removePrefix
Generate a numeric checksum value for the given input string
checksum(src: string): number
A Fisher-Yates algorithm based array shuffler.
Performs an in-place shuffling and returns the same input array.
shuffle<T>(array: T[]): T[]
array
: An array of any type
Convert utf-8 source string to an optimized uint8 (binary) array.
strToUint8(source: string)
Trim number to a max 4 digits with decimal place inbetween and suffixed by 'K', 'M', 'B', 'T' values.
trimNumber(number: number)
Convert uint8 (binary) array created by strToUint8
to the original
source string
uint8ToStr(buffer: Uint8Array)