Releases: libsugar/sugar.js
Releases · libsugar/sugar.js
2.12.0-beta.4
- Add
-
guard function
guard<{ a: 1 }>({ a: 1 }) => { a: 1 }
-
tuple function
tuple(1, 2, 3) => [1, 2, 3]
-
Pair type
Pair<K, V> => [K, V]
-
ReadonlyPair type
ReadonlyPair<K, V> => readonly [K, V]
-
AnyPair type
AnyPair<K, V> => [K, V] | readonly [K, V]
-
PairKey type
PairKey<[1, 2]> => 1
-
PairValue type
PairKey<[1, 2]> => 2
-
seq.mapKey
-
seq.mapValue
-
seq.arr
-
2.12.0-beta.3
- Add
-
OnceIter
Cache the results of the iterator
-
pipe
fp style pipe function
Example
const f = pipe( (a: number, b: number) => a + b, (a: number) => a + 2, ) f(1, 2) // => 5
-
seq/ops
move seq ops fromseq
toseq/ops
-
seq/fp
fp style seq ops
-
seq/linq
linq style seq alias
-
seq.includes
same as
array.includes
-
se.sum
-
seq.avg
-
seq.toArray
-
seq.toSet
-
seq.toMap
-
static Seq.empty
Create empty seq
Example
Seq.empty<number>()
-
static Seq.to
Create a Seq from a range starting from 0
Example
Seq.to(3) // [0, 1, 2]
-
static Seq.range
Create a Seq from a range
Example
Seq.range(3, 6) // [3, 4, 5]
-
seq.push
like array.push
-
seq.unshift
like array.unshift
-
seq.as
cast types
-
seq.groupBy
linq groupBy
-
seq.product
Cartesian product
Example
seq([1, 2, 3]).product(['a', 'b']) // returns [ [1, 'a'], [1, 'b'], [2, 'a'], [2, 'b'], [3, 'a'], [3, 'b'], ]
-
seq.relate
sql inner join
Example
seq([1, 2, 3]).relate(['1', '2', '3'], a => a, b => +b) // returns [ [1, '1'], [2, '2'], [3, '3'], ]
-