@sullux/fp-light-to-object

0.0.1 • Public • Published

home

fp-light-to-object

npm i @sullux/fp-light-to-object source test

Produces an object from any input. If the input is iterable, the object is assembled from the given key/value pairs.

toObject

toObject(any)

Produces an object from the given input value. If the input is iterable, toObject assumes that each entry is a two-element array of key and value.

const { toObject } = require('@sullux/fp-light-to-object')

toObject() // { 'Undefined': undefined }

toObject(null) // { 'Null': null }

toObject([['foo', 'bar'], ['baz', 42]]) // { foo: 'bar', baz: 42 }

toObject({ foo: 42 }) // { foo: 42 }

toObject(new Date()) // { Date: 2019-03-01T14:56:53.812Z }

toObject(42) // { Number: 42 }

toObject('foo') // { String: 'foo' }

toObject(() => 42) // { Function: [Function] }

Readme

Keywords

Package Sidebar

Install

npm i @sullux/fp-light-to-object

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

1.88 kB

Total Files

3

Last publish

Collaborators

  • sullux