Socket
Socket
Sign inDemoInstall

as-arr

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    as-arr

Convert objects (specially strings) into arrays


Version published
Weekly downloads
3
decreased by-50%
Maintainers
1
Install size
2.80 kB
Created
Weekly downloads
 

Readme

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

Last updated on 07 Jun 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc