@unction/attach
TypeScript icon, indicating that this package has built-in type declarations

7.13.0 • Public • Published

@unction/attach

Tests Stability Dependencies

A => B => Record<string | number | symbol, B> | Map<A, B> => Record<string | number | symbol, B> | Map<A, B> ObjectKeyType => ValueType => ObjectType => ObjectType MapKeyType => ValueType => MapType => MapType ArrayKeyType => ValueType => ArrayType => ArrayType null => ValueType => SetType => SetType null => ValueType => StreamType => StreamType

A polymorphic way to attach a value to the key on a keyed enumerator. When dealing with a sorted list type and the key is larger than the list, it will append to the list. When the key is an index that already exists it will place the value at that index and shift remaining values to the right.

attach("hello")("world")({}) // => {hello: "world"}
attach(3)("x")([1, 2, 3]) // => [1, 2, 3, "x"]
attach(1)("x")([1, 2, 3]) // => [1, "x", 2, 3]
attach(null)("x")(new Set([1, 2, 3])) // => {1 2 3 "x"}
attach(10)("x")([]) // => ["x"]
attach(0)("a")("bc") // => "abc"
attach(null)("a")(xstream.of("b")) // => a---b--=>

Readme

Keywords

Package Sidebar

Install

npm i @unction/attach

Weekly Downloads

62

Version

7.13.0

License

SEE LICENSE IN LICENSE

Unpacked Size

30 kB

Total Files

7

Last publish

Collaborators

  • krainboltgreene