Nexium

Arrays

Unlock the Power of Arrays with Nexium's Essential Methods

Import the NArray

const { NArray } = require('nexium')

chunkArray

splits array into chunks of specified length

const arr = [1, 2, 3, 4, 5, 6, 7]
const chunkLength = 3
const result = NArray.chunkArray(arr, chunkLength) // [[1, 2, 3], [4, 5, 6], [7]]

uniqueArray

remove duplicates from the given array.

const array = [{ id: 1 }, { id: 2 }, { id: 1 }]
const result = NArray.uniqueArray(array) // [{ id: 1 }, { id: 2 }]

countNonRepeating

remove duplicates from the given array.

const str_result = NArray.countNonRepeating(['a', 'b', 'b', 'c', 'd', 'd', 'e'], 'string') // 3
const num_result = NArray.countNonRepeating([1, 2, 2, 3, 4, 4, 5], 'number') // 3

On this page