
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.
@utilify/array
Advanced tools
A collection of utility functions for array manipulation and transformation. Simplifies common operations like chunking, flattening, shuffling, finding differences, and more.
The array utility functions provide a variety of methods to manipulate and transform arrays and strings. They help simplify common operations such as splitting, flattening, shuffling, and finding differences between arrays, among others.
To install the array utility functions, use one of the following commands depending on your package manager:
npm install @utilify/array
yarn add @utilify/array
pnpm add @utilify/array
After installation, you can import the functions into your project using ESM or CJS.
This library supports both the ESM and CJS module systems.
import { shuffle } from '@utilify/array';
const { shuffle } = require('@utilify/array');
Here's an overview of the functions available in the array and string utilities package:
function after(str: string, index: number): string;
function after<T>(arr: T[], index: number): T[];
Returns the elements of the array or string after the index index.
function before(str: string, index: number): string;
function before<T>(arr: T[], index: number): T[];
Returns the elements of the array or string before the index index.
function chunk(str: string, size: number): string[];
function chunk<T>(arr: T[], size: number): T[][];
Splits the array or string into smaller chunks of size size.
function compact<T>(arr: T[]): T[];
Removes "falsy" values (false, null, 0, "", undefined, NaN) from the array.
function difference<T>(arr1: T[], arr2: T[]): T[];
Returns the elements from the first array that are not in the second array.
function first(str: string, count?: number): string;
function first<T>(arr: T[], count?: number): T[];
Returns the first count elements of the array or string.
function flattenArr<T>(arr: T[], depth?: number): FlatArray<T[], number>[];
Flattens the array up to the specified depth.
function getRandom(str: string): string;
function getRandom<T>(arr: T[]): T;
Returns a random element from the array or string.
function isIterable(value: any): boolean;
Checks if the value is iterable.
function last(str: string, count?: number): string;
function last<T>(arr: T[], count?: number): T[];
Returns the last count elements of the array or string.
function rotate<T>(arr: T[], offset: number): T[];
Rotates the elements of the array offset positions.
function sanitizeArr<T>(arr: T[], values: T[], replace?: T): T[];
Removes or replaces the specified values in the array.
function shuffle<T>(arr: T[]): T[];
Shuffles the elements of the array.
function swap<T>(arr: T[], fromIndex: number, toIndex: number): T[];
Swaps the elements at positions fromIndex and toIndex.
function union<T>(...arrs: T[][]): T[];
Returns the union of multiple arrays.
function unique<T>(arr: T[]): T[];
Returns an array with unique elements.
FAQs
A collection of utility functions for array manipulation and transformation. Simplifies common operations like chunking, flattening, shuffling, finding differences, and more.
The npm package @utilify/array receives a total of 11 weekly downloads. As such, @utilify/array popularity was classified as not popular.
We found that @utilify/array demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers 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.