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

arraify

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arraify

convert a value to array

  • 1.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

arraify

Convert a value to an array

Install

$ npm install arraify

Usage

const arrify = require('arraify');

const obj = {
  0: 'zero',
  1: 'one',
  length: 2,
};
arrify(obj);
// ['zero', 'one']

const obj = {
  0: 'zero',
  1: 'one',
  length: 3,
};

arrify.config.arraySimilarity = 2;
arrify(obj);
// [{ 0: 'zero', 1: 'one', length: 3 }]
arrify.config.arraySimilarity = 1;
arrify(obj);
// [{ 0: 'zero', 1: 'one', length: 3 }]

arrify.config.arraySimilarity = 0;
arrify(obj);
// ['zero', 'one', undefined]

arrify(1, 2, 3);
// [1, 2, 3]

arrify('string');
// ['s', 't', 'r', 'i', 'n', 'g']

arrify.config.splitString = false;
arrify('string');
// ['sting']

arrify([]);
// []

arrify();
// []

arrify(null);
// []

arrify(undefined);
// []

Configs

arrify.config = {
  splitString: true,
  arraySimilarity: 2,
};

splitString:

true | false, and true is the default

arraySimilarity:

0 | 1 | 2, and 2 is the default

License

MIT © Gyumeijie

Keywords

FAQs

Package last updated on 08 May 2019

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