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

as-arr

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

as-arr

Convert objects (specially strings) into arrays

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

as-arr npm

Convert objects (specially strings) into arrays:

var asArr = require('as-arr')

// split strings by spaces
asArr('a b c') // => ['a', 'b', 'c']

// by default all spaces are removed
asArr('   a   b  c    ') // => ['a', 'b', 'c']

// custom separators
asArr('a, b, c', /,\s*/) // => ['a', 'b', 'c']
asArr('abc', '') // => ['a', 'b', 'c']

// arrays are bypassed
asArr(['a', 'b', 'c']) // => ['a', 'b', 'c']

// objects are wrapped into an array
asArr(123) // => [ 123 ]
asArr(null) // => [ null ]

// it ALWAYS returns an array
asArr() // => []

// create a function with a custom separator
var toArr = asArr.use(/\s*\|\s*|\s*,\s*|\s+/)
toArr('a, b  c | d') // => ['a', 'b', 'c', 'd']

License

MIT License

Keywords

FAQs

Package last updated on 07 Jun 2016

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