@everymundo/array-helpers

1.6.1 • Public • Published

@everymundo/array-helpers

Helpers to handle array operations in a more elegant way

Instalation

npm i @everymundo/array-helpers

Helper Functions

  • flat10

flat10

This function flattens an array, hence the name flat10 (flatten), do you get it?

const {flat10} = require('@everymundo/array-helpers');
// or
// const {flat10} = require('@everymundo/array-helpers/flat10');

const arrayInput = [1, [2, [3, [4], [5], [6, 7]]], [8, [9]]];

const arrayOutput = flat10(arrayInput);

console.log(arrayOutput); // [1, 2, 3, 4, 5, 6, 7, 8, 9]

You can read the test code in test/flat10.test.js for more examples.

inChunks

const {inChunks} = require('@everymundo/array-helpers');

const arrayInput = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15];
const CHUNK_SIZE = 5
// Split in chunks of 5 elements each
const arrayOutput = inChunks(arrayInput, CHUNK_SIZE);

console.log(arrayOutput); // [ [ 1, 2, 3, 4, 5 ], [ 6, 7, 8, 9, 10 ], [ 11, 12, 13, 14, 15 ] ]

Readme

Keywords

Package Sidebar

Install

npm i @everymundo/array-helpers

Weekly Downloads

25

Version

1.6.1

License

MIT

Unpacked Size

23 kB

Total Files

18

Last publish

Collaborators

  • atamayo04
  • volodymyrpetrov
  • jsalvadorpp
  • lindolo25
  • double2-us
  • ceciliagalarza
  • carla-villegas
  • eblez
  • mjremedios1985
  • mtmorell88
  • a11y_automation2
  • ramses83
  • raydel
  • alex-orga
  • estebanpablo89
  • yartiles
  • jonmorazav
  • everymundo-admin
  • ballester
  • danielsan
  • halain
  • avivero93
  • anahiem
  • herlin
  • karinfdez
  • erlin
  • front10devs
  • hdelcastillo
  • dcuevacem
  • ortega.dc98
  • pedroleon917
  • kaylingw
  • lazjramos
  • daniuska-em