tiny-fns

1.0.4 • Public • Published

tiny-fns

A microscopic zero-dep library of immutable helper functions that probably didn't need to be written.

usage

npm install tiny-fns
import { flatten } from 'tiny-fns'
 
flatten([['a'], ['b']])

docs

chunk (try it)

Splits an array into multiple arrays of specified length.

chunk(['a', 'b', 'c', 'd', 'e'], 2)
 
// -> [['a', 'b'], ['c', 'd'], ['e']]

flatten (try it)

Flattens an array one level deep.

flatten([['a', 'b'], ['c'], 'd', [['e']]])
 
// -> ['a', 'b', 'c', 'd', ['e']]

fromPairs (try it)

Creates an object from an array of key/value pair arrays.

fromPairs([['a', 1], ['b', 2], ['c', 3]])
 
// -> { a: 1, b: 2, c: 3 }

mapKeys (try it)

Creates a new object by mapping keys of an existing object.

mapKeys({ a: 1, b: 2, c: 3 }, key => `${key}${key}`)
 
// -> { aa: 1, bb: 2, cc: 3 }

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i tiny-fns

    Weekly Downloads

    7

    Version

    1.0.4

    License

    MIT

    Unpacked Size

    4.74 kB

    Total Files

    4

    Last publish

    Collaborators

    • erquhart