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

arrayize

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

arrayize

Return input if it is an array, otherwise return input wrapped in an array. If input is null or undefined, return empty array.

  • 0.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
14
decreased by-70.21%
Maintainers
1
Weekly downloads
 
Created
Source

arrayize

Return input if it is an array, otherwise return input wrapped in an array. If input is null or undefined, return empty array.

Installation

npm install arrayize

Usage

var arrayize = require('arrayize');

// Empty array if passed undefined or null
arrayize();                     // => []
arrayize(null);                 // => []

// Original array if passed an array
arrayize([]);                   // => []
arrayize(['foo']);              // => [ 'foo' ]
arrayize(['foo','bar','baz']);  // => [ 'foo', 'bar', 'baz' ]

// Original value wrapped in an array if passed anything else
arrayize('foo');                // => [ 'foo' ]
arrayize(3);                    // => [ 3 ]
arrayize({foo:'bar'});          // => [ { foo: 'bar' } ]
arrayize(function() {});        // => [ [Function] ]
arrayize(new Date());           // => [ Wed Mar 05 2014 03:29:26 GMT-0800 (PST) ]
arrayize(/foo/);                // => [ /foo/ ]

Running tests

git clone http://github.com/tauren/arrayize
cd arrayize
npm install
npm test

Keywords

FAQs

Package last updated on 05 Mar 2014

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