Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Variables

histograph: Function = ...

Returns the histograph of an array as a Map. Makes no attempt to cope with deep equality; will fail for complex contents, as such.

import { histograph } from './jssm';

histograph( [0, 0, 1, 1, 2, 2, 1] ); // Map()
weighted_histo_key: Function = ...
weighted_rand_select: Function = ...
weighted_sample_select: Function = ...

Functions

  • arr_uniq_p<T>(el: T, i: number, source: T[]): boolean
  • Predicate for validating an array for uniqueness. Not generally meant for external use.

    Type Parameters

    • T

    Parameters

    • el: T
    • i: number
    • source: T[]

    Returns boolean

  • array_box_if_string(n: any): any
  • find_repeated<T>(arr: T[]): [T, number][]
  • 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] ]

    Type Parameters

    • T

    Parameters

    • arr: T[]

    Returns [T, number][]

  • gen_splitmix32(a?: number): (() => number)
  • hook_name(from: string, to: string): string
  • Internal method generating names for edges for the hook lookup map. Not meant for external use.

    Parameters

    • from: string
    • to: string

    Returns string

  • name_bind_prop_and_state(prop: string, state: string): string
  • Internal method generating names for edges for the hook lookup map. Not meant for external use.

    Parameters

    • prop: string
    • state: string

    Returns string

  • named_hook_name(from: string, to: string, action: string): string
  • Internal method generating names for actions for the hook lookup map. Not meant for external use.

    Parameters

    • from: string
    • to: string
    • action: string

    Returns string

  • seq(n: number): number[]
  • 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); // []

    Parameters

    • n: number

    Returns number[]

  • unique<T>(arr?: T[]): T[]
  • 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]

    Type Parameters

    • T

    Parameters

    • Optional arr: T[]

    Returns T[]

Generated using TypeDoc