Options
All
  • Public
  • Public/Protected
  • All
Menu

extra-lists

Index

Functions

cartesianProduct

  • cartesianProduct<T, U, V>(xs: Lists<T, U>[], fm?: mapFn<number, Lists<T, U>, Lists<T, U> | V>): Iterable<Lists<T, U> | V>
  • Lists cartesian product of lists.

    Type parameters

    • T

    • U

    • V = U

    Parameters

    • xs: Lists<T, U>[]

      lists

    • fm: mapFn<number, Lists<T, U>, Lists<T, U> | V> = null

      map function (vs, i)

    Returns Iterable<Lists<T, U> | V>

chunk

  • chunk<T, U>(x: Lists<T, U>, n?: number, s?: number): Lists<T, U>[]
  • Breaks lists into chunks of given size.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • n: number = 1

      chunk size (1)

    • s: number = ...

      chunk step (n)

    Returns Lists<T, U>[]

compare

  • compare<T, U, V>(x: Lists<T, U>, y: Lists<T, U>, fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): number
  • Compares two lists.

    Type parameters

    • T

    • U

    • V = U

    Parameters

    • x: Lists<T, U>

      lists

    • y: Lists<T, U>

      another lists

    • Optional fc: compareFn<U | V>

      compare function (a, b)

    • Optional fm: mapFn<T, U, U | V>

      map function (v, k, x)

    Returns number

    x=y: 0, otherwise: -ve/+ve

concat

  • concat<T, U>(...xs: Lists<T, U>[]): Lists<T, U>
  • Appends entries from all lists.

    Type parameters

    • T

    • U

    Parameters

    • Rest ...xs: Lists<T, U>[]

      n lists

    Returns Lists<T, U>

count

  • count<T, U>(x: Lists<T, U>, ft: testFn<T, U>): number
  • Counts values which satisfy a test.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • ft: testFn<T, U>

      test function (v, k, x)

    Returns number

countAs

  • countAs<T, U, V>(x: Lists<T, U>, fm?: mapFn<T, U, U | V>): Map<U | V, number>
  • Counts occurrences of values.

    Type parameters

    • T

    • U

    • V = U

    Parameters

    • x: Lists<T, U>

      lists

    • fm: mapFn<T, U, U | V> = null

      map function (v, k, x)

    Returns Map<U | V, number>

    Map {value => count}

difference

  • difference<T, U>(x: Lists<T, U>, y: Lists<T, U>): Lists<T, U>
  • Gives entries of lists not present in another.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • y: Lists<T, U>

      another lists

    Returns Lists<T, U>

drop

  • drop<T, U>(x: Lists<T, U>, n?: number): Lists<T, U>
  • Removes first n entries.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • n: number = 1

      number of entries (1)

    Returns Lists<T, U>

entries

  • entries<T, U>(x: Lists<T, U>): Entries<T, U>
  • Lists all key-value pairs.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    Returns Entries<T, U>

entry

  • entry<T, U>(x: Lists<T, U>, r?: number): [T, U]
  • Picks an arbitrary entry.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • r: number = ...

      random seed 0->1

    Returns [T, U]

every

  • every<T, U>(x: Lists<T, U>, ft: testFn<T, U>): boolean
  • Checks if all values satisfy a test.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • ft: testFn<T, U>

      test function (v, k ,x)

    Returns boolean

filter

  • filter<T, U>(x: Lists<T, U>, ft: testFn<T, U>): Lists<T, U>
  • Keeps entries which pass a test.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • ft: testFn<T, U>

      test function (v, k, x)

    Returns Lists<T, U>

filterAt

  • filterAt<T, U>(x: Lists<T, U>, ks: T[]): Lists<T, U>
  • Gets lists with given keys.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • ks: T[]

      keys

    Returns Lists<T, U>

find

  • find<T, U>(x: Lists<T, U>, ft: testFn<T, U>): U
  • Finds a value passing a test.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • ft: testFn<T, U>

      test function (v, k, x)

    Returns U

findAll

  • findAll<T, U>(x: Lists<T, U>, ft: testFn<T, U>): Iterable<U>
  • Finds values passing a test.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • ft: testFn<T, U>

      test function (v, k, x)

    Returns Iterable<U>

flat

  • flat<T>(x: Lists<T, any>, n?: number, fm?: mapFn<T, any, any>, ft?: testFn<T, any>): Lists<T, any>
  • Flattens nested lists to given depth.

    Type parameters

    • T

    Parameters

    • x: Lists<T, any>

      nested lists

    • n: number = -1

      maximum depth (-1)

    • fm: mapFn<T, any, any> = null

      map function (v, k, x)

    • ft: testFn<T, any> = null

      test function (v, k, x)

    Returns Lists<T, any>

flatMap

  • flatMap<T>(x: Lists<T, any>, fm?: mapFn<T, any, any>, ft?: testFn<T, any>): Lists<T, any>
  • Flattens nested lists, using map function.

    Type parameters

    • T

    Parameters

    • x: Lists<T, any>

      nested lists

    • fm: mapFn<T, any, any> = null

      map function (v, k, x)

    • ft: testFn<T, any> = null

      test function (v, k, x)

    Returns Lists<T, any>

forEach

  • forEach<T, U>(x: Lists<T, U>, fc: calledFn<T, U>): void
  • Calls a function for each value.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • fc: calledFn<T, U>

      called function (v, k, x)

    Returns void

fromEntries

  • fromEntries<T, U>(es: Entries<T, U>): Lists<T, U>
  • Creates lists from entries.

    Type parameters

    • T

    • U

    Parameters

    • es: Entries<T, U>

      entries

    Returns Lists<T, U>

get

  • get<T, U>(x: Lists<T, U>, k: T): U
  • Gets value at key.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • k: T

      key

    Returns U

getAll

  • getAll<T, U>(x: Lists<T, U>, ks: T[]): Iterable<U>
  • Gets values at keys.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • ks: T[]

      keys

    Returns Iterable<U>

getPath

  • getPath<T>(x: Lists<T, any>, p: T[]): any
  • Gets value at path in nested lists.

    Type parameters

    • T

    Parameters

    • x: Lists<T, any>

      nested lists

    • p: T[]

      path

    Returns any

has

  • has<T, U>(x: Lists<T, U>, k: T): boolean
  • Checks if lists has a key.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • k: T

      key?

    Returns boolean

hasEntry

  • hasEntry<T, U, V>(x: Lists<T, U>, e: [T, U], fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): boolean
  • Checks if map has an entry.

    Type parameters

    • T

    • U

    • V = U

    Parameters

    • x: Lists<T, U>

      a map

    • e: [T, U]

      entry?

    • fc: compareFn<U | V> = null

      compare function (a, b)

    • fm: mapFn<T, U, U | V> = null

      map function (v, k, x)

    Returns boolean

hasPath

  • hasPath<T>(x: Lists<T, any>, p: T[]): boolean
  • Checks if nested lists has a path.

    Type parameters

    • T

    Parameters

    • x: Lists<T, any>

      nested lists

    • p: T[]

      path

    Returns boolean

hasSubset

  • hasSubset<T, U, V>(x: Lists<T, U>, y: Lists<T, U>, fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): boolean
  • Checks if lists has a subset.

    Type parameters

    • T

    • U

    • V = U

    Parameters

    • x: Lists<T, U>

      lists

    • y: Lists<T, U>

      subset?

    • fc: compareFn<U | V> = null

      compare function (a, b)

    • fm: mapFn<T, U, U | V> = null

      map function (v, k, x)

    Returns boolean

hasValue

  • hasValue<T, U, V>(x: Lists<T, U>, v: U, fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): boolean
  • Checks if lists has a value.

    Type parameters

    • T

    • U

    • V = U

    Parameters

    • x: Lists<T, U>

      lists

    • v: U

      value?

    • fc: compareFn<U | V> = null

      compare function (a, b)

    • fm: mapFn<T, U, U | V> = null

      map function (v, k, x)

    Returns boolean

head

  • head<T, U>(x: Lists<T, U>, ed?: [T, U]): [T, U]
  • Gets first entry.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • ed: [T, U] = ...

      default entry

    Returns [T, U]

intersection

  • intersection<T, U>(x: Lists<T, U>, y: Lists<T, U>, fc?: combineFn<U>): Lists<T, U>
  • Gives entries present in both lists.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • y: Lists<T, U>

      another lists

    • fc: combineFn<U> = null

      combine function (a, b)

    Returns Lists<T, U>

is

  • is<T, U>(v: any): v is Lists<T, U>
  • Checks if value is lists.

    Type parameters

    • T

    • U

    Parameters

    • v: any

      value

    Returns v is Lists<T, U>

isDisjoint

  • isDisjoint<T, U>(x: Lists<T, U>, y: Lists<T, U>): boolean
  • Checks if lists have no common keys.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • y: Lists<T, U>

      another lists

    Returns boolean

isEmpty

  • isEmpty<T, U>(x: Lists<T, U>): boolean
  • Checks if lists is empty.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    Returns boolean

isEqual

  • isEqual<T, U, V>(x: Lists<T, U>, y: Lists<T, U>, fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): boolean
  • Checks if two lists are equal.

    Type parameters

    • T

    • U

    • V = U

    Parameters

    • x: Lists<T, U>

      lists

    • y: Lists<T, U>

      another lists

    • fc: compareFn<U | V> = null

      compare function (a, b)

    • fm: mapFn<T, U, U | V> = null

      map function (v, k, x)

    Returns boolean

join

  • join<T, U>(x: Lists<T, U>, sep?: string, asc?: string): string
  • Joins values together.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • sep: string = ','

      separator (,)

    • asc: string = '='

      associator (=)

    Returns string

key

  • key<T, U>(x: Lists<T, U>, r?: number): T
  • Picks an arbitrary key.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • r: number = ...

      random seed 0->1

    Returns T

keys

  • keys<T, U>(x: Lists<T, U>): Iterable<T>
  • Lists all keys.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    Returns Iterable<T>

length

  • length<T, U>(x: Lists<T, U>): number
  • Gets size of lists.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    Returns number

map

  • map<T, U, V>(x: Lists<T, U>, fm: mapFn<T, U, V>): any[][]
  • Updates values based on map function.

    Type parameters

    • T

    • U

    • V

    Parameters

    • x: Lists<T, U>

      lists

    • fm: mapFn<T, U, V>

      map function (v, k, x) s

    Returns any[][]

max

  • max<T, U, V>(x: Lists<T, U>, fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): [T, U]
  • Finds largest value.

    Type parameters

    • T

    • U

    • V = U

    Parameters

    • x: Lists<T, U>

      lists

    • fc: compareFn<U | V> = null

      compare function (a, b)

    • fm: mapFn<T, U, U | V> = null

      map function (v, k, x)

    Returns [T, U]

min

  • min<T, U, V>(x: Lists<T, U>, fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): [T, U]
  • Finds smallest entry.

    Type parameters

    • T

    • U

    • V = U

    Parameters

    • x: Lists<T, U>

      lists

    • fc: compareFn<U | V> = null

      compare function (a, b)

    • fm: mapFn<T, U, U | V> = null

      map function (v, k, x)

    Returns [T, U]

partition

  • partition<T, U>(x: Lists<T, U>, ft: testFn<T, U>): [Lists<T, U>, Lists<T, U>]
  • Segregates values by test result.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • ft: testFn<T, U>

      test function (v, k, x)

    Returns [Lists<T, U>, Lists<T, U>]

partitionAs

  • partitionAs<T, U, V>(x: Lists<T, U>, fm?: mapFn<T, U, U | V>): Map<U | V, Lists<T, U>>
  • Segregates values by similarity.

    Type parameters

    • T

    • U

    • V = U

    Parameters

    • x: Lists<T, U>

      lists

    • fm: mapFn<T, U, U | V> = null

      map function (v, k, x)

    Returns Map<U | V, Lists<T, U>>

    Map {key => values}

range

  • range<T, U, V>(x: Lists<T, U>, fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): [[T, U], [T, U]]
  • Finds smallest and largest entries.

    Type parameters

    • T

    • U

    • V = U

    Parameters

    • x: Lists<T, U>

      lists

    • fc: compareFn<U | V> = null

      compare function (a, b)

    • fm: mapFn<T, U, U | V> = null

      map function (v, k, x)

    Returns [[T, U], [T, U]]

reduce

  • reduce<T, U, V>(x: Lists<T, U>, fr: reduceFn<T, U, U | V>, acc?: U | V): U | V
  • Reduces values to a single value.

    Type parameters

    • T

    • U

    • V = U

    Parameters

    • x: Lists<T, U>

      lists

    • fr: reduceFn<T, U, U | V>

      reduce function (acc, v, k, x)

    • Optional acc: U | V

      initial value

    Returns U | V

reject

  • reject<T, U>(x: Lists<T, U>, ft: testFn<T, U>): Lists<T, U>
  • Discards entries which pass a test.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • ft: testFn<T, U>

      test function (v, k, x)

    Returns Lists<T, U>

rejectAt

  • rejectAt<T, U>(x: Lists<T, U>, ks: T[]): Lists<T, U>
  • Gets lists without given keys.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • ks: T[]

      keys

    Returns Lists<T, U>

remove

  • remove<T, U>(x: Lists<T, U>, k: T): Lists<T, U>
  • Deletes an entry.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • k: T

      key

    Returns Lists<T, U>

scanUntil

  • scanUntil<T, U>(x: Lists<T, U>, ft: testFn<T, U>): T
  • Finds key of first entry not passing a test.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • ft: testFn<T, U>

      test function (v, k, x)

    Returns T

scanWhile

  • scanWhile<T, U>(x: Lists<T, U>, ft: testFn<T, U>): T
  • Finds key of first entry not passing a test.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • ft: testFn<T, U>

      test function (v, k, x)

    Returns T

search

  • search<T, U>(x: Lists<T, U>, ft: testFn<T, U>): T
  • Finds key of an entry passing a test.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • ft: testFn<T, U>

      test function (v, k, x)

    Returns T

searchAll

  • searchAll<T, U>(x: Lists<T, U>, ft: testFn<T, U>): Iterable<T>
  • Finds keys of entries passing a test.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • ft: testFn<T, U>

      test function (v, k, x)

    Returns Iterable<T>

searchValue

  • searchValue<T, U, V>(x: Lists<T, U>, v: U, fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): T
  • Finds key with given value.

    Type parameters

    • T

    • U

    • V = U

    Parameters

    • x: Lists<T, U>

      lists

    • v: U

      search value

    • fc: compareFn<U | V> = null

      compare function (a, b)

    • fm: mapFn<T, U, U | V> = null

      map function (v, k, x)

    Returns T

searchValueAll

  • searchValueAll<T, U, V>(x: Lists<T, U>, v: U, fc?: compareFn<U | V>, fm?: mapFn<T, U, U | V>): Iterable<T>
  • Finds keys with given value.

    Type parameters

    • T

    • U

    • V = U

    Parameters

    • x: Lists<T, U>

      lists

    • v: U

      search value

    • fc: compareFn<U | V> = null

      compare function (a, b)

    • fm: mapFn<T, U, U | V> = null

      map function (v, k, x)

    Returns Iterable<T>

set

  • set<T, U>(x: Lists<T, U>, k: T, v: U): Lists<T, U>
  • Sets value at key.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • k: T

      key

    • v: U

      value

    Returns Lists<T, U>

shift

  • shift<T, U>(x: Lists<T, U>): Lists<T, U>
  • Removes first entry.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    Returns Lists<T, U>

size

  • size<T, U>(x: Lists<T, U>): number
  • Gets size of lists.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    Returns number

some

  • some<T, U>(x: Lists<T, U>, ft?: testFn<T, U>): boolean
  • Checks if any value satisfies a test.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • ft: testFn<T, U> = null

      test function (v, k, x)

    Returns boolean

subset

  • subset<T, U>(x: Lists<T, U>, n?: number, r?: number): Lists<T, U>
  • Picks an arbitrary submap.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • n: number = -1

      number of entries (-1 => any)

    • r: number = ...

      random seed 0->1

    Returns Lists<T, U>

subsets

  • subsets<T, U>(x: Lists<T, U>, n?: number): Iterable<Lists<T, U>>
  • Lists all possible subsets.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • n: number = -1

      number of entries (-1 => any)

    Returns Iterable<Lists<T, U>>

swap

  • swap<T, U>(x: Lists<T, U>, k: T, l: T): Lists<T, U>
  • Exchanges two values.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • k: T

      a key

    • l: T

      another key

    Returns Lists<T, U>

symmetricDifference

  • symmetricDifference<T, U>(x: Lists<T, U>, y: Lists<T, U>): Lists<T, U>
  • Gives entries not present in both lists.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • y: Lists<T, U>

      another lists

    Returns Lists<T, U>

tail

  • tail<T, U>(x: Lists<T, U>): Lists<T, U>
  • Gets lists without the first entry.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    Returns Lists<T, U>

take

  • take<T, U>(x: Lists<T, U>, n?: number): Lists<T, U>
  • Keeps first n entries only.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • n: number = 1

      number of entries (1)

    Returns Lists<T, U>

union

  • union<T, U>(x: Lists<T, U>, y: Lists<T, U>, fc?: combineFn<U>): Lists<T, U>
  • Gives lists present in any lists.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • y: Lists<T, U>

      another lists

    • fc: combineFn<U> = null

      combine function (a, b)

    Returns Lists<T, U>

unionKeys

  • unionKeys<T, U>(...xs: Lists<T, U>[]): Set<T>
  • Gives keys present in any lists.

    Type parameters

    • T

    • U

    Parameters

    • Rest ...xs: Lists<T, U>[]

      n lists

    Returns Set<T>

value

  • value<T, U>(x: Lists<T, U>, r?: number): U
  • Picks an arbitrary value.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    • r: number = ...

      random seed 0->1

    Returns U

values

  • values<T, U>(x: Lists<T, U>): Iterable<U>
  • Lists all values.

    Type parameters

    • T

    • U

    Parameters

    • x: Lists<T, U>

      lists

    Returns Iterable<U>

zip

  • zip<T, U, V>(xs: Lists<T, U>[], fm?: mapFn<T, U[], U[] | V>, ft?: tillFn, vd?: U): Lists<T, U[] | V>
  • Combines matching entries from all lists.

    Type parameters

    • T

    • U

    • V = U

    Parameters

    • xs: Lists<T, U>[]

      n lists

    • fm: mapFn<T, U[], U[] | V> = null

      map function (vs, k)

    • ft: tillFn = null

      till function (dones) (some)

    • Optional vd: U

      default value

    Returns Lists<T, U[] | V>

Generated using TypeDoc