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

array-divide

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

array-divide

Divide an array into multiple arrays each of whom have the same number of items

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

array-divide

NPM version Bower version Build Status Coverage Status devDependency Status

Divide an array into multiple arrays each of whom have the same number of items

arrayDivide(['a', 'b', 'c', 'd'], 2); //=> [['a', 'b'], ['c', 'd']]
arrayDivide(['a', 'b', 'c', 'd'], 3); //=> [['a', 'b', 'c'], ['d']]

Installation

Package managers

npm
npm install array-divide
bower
bower install array-divide
Duo
const arrayDivide = require('shinnn/array-divide');

Standalone

Download the script file directly.

API

arrayDivide(array, count)

array: Array
count: Number (the maximum number of items)
Return: Array (a new array and doesn't break the original one)

arrayDivide(['a', 'b', 'c', 'd'], 100); //=> [['a', 'b', 'c', 'd']]
arrayDivide([], 100); //=> []

arrayDivide(['a', 'b', 'c'], 0); // throw an error (count must be >= 1)
arrayDivide(arguments, 1); // throw an error (doesn't support array-like object)

License

Copyright (c) 2015 Shinnosuke Watanabe

Licensed under the MIT License.

Keywords

FAQs

Package last updated on 31 Dec 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

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