functions_to_work_with_arrays_js

1.0.2 • Public • Published

Array Utilities

A simple package for array manipulation using Lodash.

Installation

Install the package via npm:

npm install functions_to_work_with_arrays_js

Usage

Import and use the functions:

import { squareNumbers, groupBy } from 'functions_to_work_with_arrays_js';

// Example 1: Squaring numbers
const numbers = [1, 2, 3, 4, 5];
console.log(squareNumbers(numbers)); // [1, 4, 9, 16, 25]

// Example 2: Grouping objects by a key
const users = [
    { id: 1, name: 'Dima', age: 25 },
    { id: 2, name: 'Nikita', age: 25 },
    { id: 3, name: 'Andrey', age: 30 },
];
console.log(groupBy(users, 'age'));
// { '25': [{ id: 1, name: 'Dima', age: 25 }, { id: 2, name: 'Nikita', age: 25 }], '30': [{ id: 3, name: 'Andrey', age: 30 }] }

Package Sidebar

Install

npm i functions_to_work_with_arrays_js

Weekly Downloads

7

Version

1.0.2

License

MIT

Unpacked Size

3.63 kB

Total Files

5

Last publish

Collaborators

  • oktaw