nullable-util
utility functions with Nullable
usage example
const util = const collection = 1 2 3 4 5 util// => Nullable.of(1) util// => Nullable.of(4) util// => Nullable.of(5) util// => Nullable.of(2) const users = 1: name: 'A' admin: false 2: name: 'B' admin: true util// => Nullable.of(['1', {name: 'A', admin: false}])// This returns a [key, value] pair as a 2-element Array.// Note, Object property names are always strings. util// => Nullable.of(['2', {name: 'B', admin: true}])
first
and last
operate on Arrays and Array-likes (NodeList, etc.), plain Objects,
ES6 collections (Set and Map, but not WeakSet or WeakMap which are not iterable).
first
can also operate on generators, but not last
since generators may be infinite.
See test suite for more examples.
installation
$ npm install nullable-util
running the tests
From package root:
$ npm install
$ npm test
license
ISC. (c) MMXVII jsdnxx. See LICENSE.md