
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
@plq/array-functions
Advanced tools
A set of frequently used functions for working with arrays, for sorting, filtering or checking the state of an array
A set of frequently used functions for working with arrays, for sorting, filtering or checking the state of an array
filterBySameKeyValueFilters an array of objects so that the value of a given key occurs only once in the array.
import { filterBySameKeyValue } from '@plq/array-functions'
const array = [
{ id: 1, name: 'Alice' },
{ id: 2, name: 'Bob' },
{ id: 3, name: 'Alice' },
]
console.log(filterBySameKeyValue(array, 'name')) // Output: [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }]
getKeyValueReturns the array of values of a given key from an array of objects.
import { getKeyValue } from '@plq/array-functions'
const array = [
{ id: 1, name: 'Alice' },
{ id: 2, name: 'Bob' },
{ id: 3, name: 'Alice' },
]
console.log(getKeyValue(array, 'name')) // Output: ['Alice', 'Bob', 'Alice']
sortBySorts an array of objects by a given key.
import { sortBy } from '@plq/array-functions'
const array = [
{ id: 1, name: 'Alice' },
{ id: 3, name: 'Alice' },
{ id: 2, name: 'Bob' },
]
console.log(sortBy(array, 'id')) // Output: [{ id: 3, name: 'Bob' }, { id: 2, name: 'Alice' }, { id: 1, name: 'Alice' }]
console.log(sortBy(array, 'id', 'asc')) // Output: [{ id: 1, name: 'Alice' }, { id: 2, name: 'Alice' }, { id: 3, name: 'Bob' }]
isSortedChecks if an array of objects is sorted by a given key.
import { isSorted } from '@plq/array-functions'
const array = [
{ id: 1, name: 'Alice' },
{ id: 2, name: 'Bob' },
{ id: 3, name: 'Alice' },
]
console.log(isSorted(array, 'id')) // Output: false because default sort order is 'desc'
console.log(isSorted(array, 'id', 'asc')) // Output: true
console.log(isSorted(array, 'name', 'asc')) // Output: false
getUniqueValuesReturns an array of unique values from an array of objects.
import { getUniqueValues } from '@plq/array-functions'
const array = [
{ id: 1, name: 'Alice' },
{ id: 2, name: 'Bob' },
{ id: 3, name: 'Alice' },
]
console.log(getUniqueValues(array, 'name')) // Output: ['Alice', 'Bob']
splitByKeyValueSplits an array of objects into subarrays with the same value of the given key.
import { splitByKeyValue } from '@plq/array-functions'
const array = [
{ id: 1, name: 'Alice' },
{ id: 2, name: 'Bob' },
{ id: 3, name: 'Alice' },
]
console.log(splitByKeyValue(array, 'name')) // Output: [[{ id: 1, name: 'Alice' }, { id: 3, name: 'Alice' }], [{ id: 2, name: 'Bob' }]]
createBalancedArrayCreates an array of a specified length where the sum of all elements equals a given sum. The function distributes the sum evenly across the array elements. If the sum is negative, the function creates an array of negative numbers. If the sum cannot be evenly distributed, the function distributes the remainder as evenly as possible. If the length is zero or negative, the function returns an empty array.
import { createBalancedArray } from '@plq/array-functions'
console.log(createBalancedArray(5, 10)); // Output: [2, 2, 2, 2, 2]
console.log(createBalancedArray(3, -5)); // Output: [-2, -2, -1]
console.log(createBalancedArray(0, 10)); // Output: []
console.log(createBalancedArray(-3, 10)); // Output: []
npm install
We use ESLint and @typescript-eslint/eslint-plugin to lint our code.
Check out .eslintrc.json
npm run lint
We use Jest to test our code.
npm test
We use TypeScript to build our code.
npm run build
src folder like function-name.tsfunctionName in function-name.tssrc/index.ts like export { default as functionName } from './function-name'__tests__ folder with name function-name.test.tsfunctionName in function-name.test.tsnpm run lintnpm run testFAQs
A set of frequently used functions for working with arrays, for sorting, filtering or checking the state of an array
The npm package @plq/array-functions receives a total of 0 weekly downloads. As such, @plq/array-functions popularity was classified as not popular.
We found that @plq/array-functions demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.