Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

record-tuple-convert

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

record-tuple-convert

Easily convert deep Objects and Arrays to Records and Tuples.

  • 0.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
Maintainers
1
Weekly downloads
 
Created
Source

Record and Tuple Converter

npm version

Recursively convert JS objects and arrays to Records and Tuples

Disclaimer

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 = require('record-tuple-convert').convertToRecord;
const convertToTuple = require('record-tuple-convert').convertToTuple;

// Convert simple objects
convertToRecord({ foo: 'bar' }); // -> #{ foo: 'bar' }

// Convert deep objects
convertToRecord({
  foo: {
    bar: 'baz'
  }
}); // #{ foo: #{ bar: 'baz' } }

// Convert simple arrays
convertToTuple(['foo', 'bar']); // -> #['foo', 'bar']

// Convert nth-dimensional arrays
convertToTuple(['foo', ['bar', ['baz']]]); // -> #['foo', #['bar', #['baz']]]

// Mix and match!

convertToRecord({ foo: ['bar'], baz: true }); // -> #{ foo: #['bar'], baz: true }

convertToTuple(['foo', { bar: 'baz' }]) // -> #['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.

Keywords

FAQs

Package last updated on 23 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc