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

arraywrap

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arraywrap

if it's not an array, wrap it in an array. if it's already an array, do nothing.

  • 2.0.0
  • latest
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

arraywrap.js

If it's not an array, make it one:

const arraywrap = require("arraywrap");

arraywrap(123); // => [123]
arraywrap("yo"); // => ['yo']
arraywrap(null); // => [null]
arraywrap(undefined); // => [undefined]
arraywrap(); // => []

If it's already an array, do nothing:

arraywrap([1, 2, 3]); // => [1, 2, 3]
arraywrap([]); // => []

const arr = [1, 2];
arrayWrap(arr) === arr; // true

This supports environments that don't have Array.isArray (like IE8 and below).

Keywords

FAQs

Package last updated on 11 Aug 2022

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