Record and Tuple Converter
Records and Tuples
Recursively convert JS objects and arrays toDisclaimer
As the record and tuple proposal is still in it's early stages, this package is not using a finalized API, so breaking changes might be frequent.
Since Babel still yet doesn't have a transform for Records and Tuples, you'll need to use @bloomberg/record-tuple-polyfill.
Usage
const convertToRecord = convertToRecord;const convertToTuple = convertToTuple; // Convert simple objects; // -> #{ foo: 'bar' } // Convert deep objects; // #{ foo: #{ bar: 'baz' } } // Convert simple arrays; // -> #['foo', 'bar'] // Convert nth-dimensional arrays; // -> #['foo', #['bar', #['baz']]] // Mix and match! ; // -> #{ foo: #['bar'], baz: true } // -> #['foo', #{ bar: 'baz' }]
Contributing
This repo is open to issues and PRs, they are even encouraged!
To get setup, clone the repo, run npm install
and follow the instructions at @bloomberg/record-tuple-polyfill to install the polyfill.
To run the tests, run npm test
.