Socket
Book a DemoInstallSign in
Socket

collapse-array

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

collapse-array

A simple utility for collapsing single-element arrays.

latest
npmnpm
Version
2.0.0
Version published
Maintainers
1
Created
Source

collapse-array

collapse-array is a simple utility for collapsing single-element arrays.

Build status

Browser support

Install

npm install collapse-array

Example

var collapse = require('collapse-array')
var collapseDeep = require('collapse-array/deep')
var collapseObj = require('collapse-array/object')

collapse([4])
// => 4

collapse([1, 2, 3])
// => [1, 2, 3]

collapseDeep([[[[2],[3]]]])
// => [2, 3]

collapseObj({
  a: 123,
  b: [['one'], ['two', 'three'], ['four']],
  c: function () {
    return 'hello'
  }
})
/*
{
  a: 123,
  b: ['one', ['two', 'three'], 'four'],
  c: function () {
    return 'hello'
  }
}
*/

License

MIT

Keywords

array

FAQs

Package last updated on 05 Feb 2015

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