Library of recurring, unconnected but pure functions
Install the package as npm package. Provided are a umd-formatted file in the dist folder to require or to just load
<script src="../../node_modules/dist/myLib.js"></script>
<script src="https://unpkg.com/my-lib@latest"></script>
and an es-module in the module folder to import the separate functions or to import all
import { isAlphaNumeric } from 'my-lib'
import * as myLib from 'my-lib'
Find unique values from both arrays
Parameters
array1
(unknown[]
)array2
(unknown[]
)
Return type
the combination
unknown[]
Process comma separated list to a sanitised array with normalised strings
Parameters
commaSeparatedList
(string
)
Return type
array with separate strings
string[]
Create a genuine array from a css-query
Parameters
cssQuery
(string
)
Return type
array with Elements
Node[]
Find unique values appearing in both arrays
Parameters
array1
(any[]
)array2
(any[]
)
Return type
the intersection
unknown[]
Recursively copy all indivisible data to new object Pay attention to Date and RegExp objects
Parameters
variable
(any
)
Return type
the same data with different references
any
Try generic ways to produce a string, an empty string if necessary
Parameters
value
(any
)
Return type
string represention of anything
string
The sake of package; log the console
Return type
void
Check for existence of property in object
Parameters
object
(Record<string, unknown>
)prop
(string
)
Return type
the object has the property as its own property -- not inheriting it
boolean
Test for being a string consisting of letters and/or digits, for being undelimited
Parameters
word
(string
)
Return type
consists of letters and/or digits only
boolean
Check node for being part of the DOM
Parameters
elm
(Element
)
Return type
true when the node is on the webpage
boolean
Test value for being a character; a string with a length of one
Parameters
char
(string
)
Return type
is a single character
boolean
Test value for being a string representation of a digit
Parameters
char
(string
)
Return type
is a number 0-9
boolean
Check all arguments for being a number with the same sign (Zero is sign-neutral)
Parameters
nums
(number[]
)
Return type
equality
boolean
Check for a match covering the string entirely
Parameters
word
(string
)regex
(RegExp
)
Return type
all characters of the word were described in regex
boolean
Check value for indivisible: string, number, boolean, bigint, symbol, undefined, null, function
Parameters
value
(unknown
)
Return type
boolean
Test value for being a letter
Parameters
char
(string
)
Return type
char is a letter
boolean
Test value for being a lowercase letter
Parameters
char
(string
)
Return type
char is a lower-case letter
boolean
Check value for being a primitive but leave out the anti-value undefined;
Parameters
value
(unknown
)
Return type
is a primitive
boolean
Test value for being an uppercase letter
Parameters
char
(string
)
Return type
char is a upper-case letter
boolean
Test for values with which calculations can be done
Parameters
nums
(number[]
)
Return type
every argument is a usable number
boolean
Check the variable for living in an object wrapper These can be generated by new String / Number etc. see https://developer.mozilla.org/en-US/docs/Glossary/Primitive
Parameters
value
(unknown
)
Return type
is a wrapped primitive
boolean
Calculate average of array with Numbers
Parameters
seq
(number[]
)
Return type
the average of the numbers
number
Calculate sum of array with Numbers
Parameters
seq
(number[]
)
Return type
the sum of the numbers
number
Round at decimals
Parameters
origin
(number
)decimals
(number
)
Return type
the rounded number
number
Round at digits; round with significance
Parameters
origin
(number
)digits
(number
)
Return type
the rounded number
number
Round at digits to exponential notation; round with significance
Parameters
origin
(number
)digits
(number
)
Return type
the rounded number as exponent
string
Convert anything to a string, an empty string if necessary. Expect sensible but not consistent cross-environment behaviour on functions.
Parameters
value
(any
)
Return type
string represention of anything
string