0.0.1 • Published 5 years ago

@sullux/fp-light-to-object v0.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

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] }