Predicate for validating an array for uniqueness. Not generally meant for external use.
Lists all repeated items in an array along with their counts. Subject to
matching rules of Map. NaN
is manually removed because of conflict rules
around unique. Because these are compared with ===
and because
arrays and objects never match that way unless they're the same object,
arrays and objects are never considered repeats.
find_repeated<string>([ ]); // []
find_repeated<string>([ "one" ]); // []
find_repeated<string>([ "one", "two" ]); // []
find_repeated<string>([ "one", "one" ]); // [ ["one", 2] ]
find_repeated<string>([ "one", "two", "one" ]); // [ ["one", 2] ]
find_repeated<number>([ 0, NaN, 0, NaN ]); // [ [0, 2] ]
Creates a SplitMix32 random generator. Used by the randomness test suite.
Sourced from bryc
: https://github.com/bryc/code/blob/master/jshash/PRNGs.md#splitmix32
Replaces the Mulberry generator, which was found to have problems
Internal method generating names for edges for the hook lookup map. Not meant for external use.
Internal method generating names for edges for the hook lookup map. Not meant for external use.
Internal method generating names for actions for the hook lookup map. Not meant for external use.
Returns, for a non-negative integer argument n
, the series [0 .. n]
.
import { seq } from './jssm';
seq(5); // [0, 1, 2, 3, 4]
seq(0); // []
Reduces an array to its unique contents. Compares with ===
and makes no
effort to deep-compare contents; two matching arrays or objects contained
will be treated as distinct, according to javascript rules. This also means
that NaNs
will be dropped, because they do not self-compare.
unique( [] ); // []
unique( [0,0] ); // [0]
unique( [0,1,2, 0,1,2, 0,1,2] ); // [0,1,2]
unique( [ [1], [1] ] ); // [ [1], [1] ] because arrays don't match
unique( [0,NaN,2] ); // [0,2]
Generated using TypeDoc
Returns the histograph of an array as a
Map
. Makes no attempt to cope with deep equality; will fail for complex contents, as such.