New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

phane-tech-array-utils

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

phane-tech-array-utils

Pure JavaScript array utility functions

latest
Source
npmnpm
Version
1.0.4
Version published
Maintainers
1
Created
Source

📦 Kotipalli Phaneendra Kumar - Array Utilities

A lightweight, dependency-free JavaScript module that provides safe and predictable array utility functions.

These helpers make it easy to add, remove, search, transform, and validate arrays while handling edge cases such as null, undefined, empty arrays, and invalid inputs.

Designed to be minimal, consistent, and well-tested for both Node.js and browser environments.

✨ Highlights

  • 📚 Safe array helpers
  • ➕ Add / remove utilities
  • 🔍 Search & match helpers
  • 🔁 Transform utilities
  • 🧪 Extensive Jest test coverage
  • ⚡ Zero dependencies

📦 Installation

npm install phane-tech-array-utils

🚀 Import

import {
  getArrayLength,
  addItemToAnArray,
  addItemsInFrontToAnArray,
  addOrRemoveItemsByIndex,
  removeFirstItemOfAnArray,
  removeLastItemOfAnArray,
  mapAnArray,
  filterAnArray,
  findArrayItem,
  findIndexArrayItem,
  checkIsMatched,
  checkIsAllMatched,
  sortAnArray,
  flatAnArray,
  merginMultipleArray,
  countItem
} from "phane-tech-array-utils";

📚 API Reference

📏 getArrayLength(arr)

Returns the length of an array.

getArrayLength([1,2,3]); // 3
getArrayLength([]); // 0

➕ addItemToAnArray(arr, item)

Adds an item to the end of the array.

addItemToAnArray([1,2], 3); // [1,2,3]

➕ addItemsInFrontToAnArray(arr, ...items)

Adds items to the beginning of an array.

addItemsInFrontToAnArray([2,3], 1); // [1,2,3]

🔄 addOrRemoveItemsByIndex(arr, startIndex, count, ...items)

Adds or removes items using index.

addOrRemoveItemsByIndex([1,2,3], 1, 1); // [1,3]

➖ removeLastItemOfAnArray(arr)

Removes the last element of an array.

removeLastItemOfAnArray([1,2,3]); // [1,2]

➖ removeFirstItemOfAnArray(arr)

Removes the first element of an array.

removeFirstItemOfAnArray([1,2,3]); // [2,3]

🔁 mapAnArray(arr, callback)

Safely maps array values.

mapAnArray([1,2,3], n => n * 2); // [2,4,6]

🔍 filterAnArray(arr, conditionOrcallback)

Filters array values.

filterAnArray([1,2,3], 2); // [2]
filterAnArray([{a:1},{a:2}], {a:1}); // [{a:1}]

🔎 findArrayItem(arr, conditionOrcallback)

Finds the first matched item.

findArrayItem([1,2,3], 2); // 2

🔢 findIndexArrayItem(arr, callback)

Returns the index of the matched item.

findIndexArrayItem([1,2,3], v => v === 2); // 1

✅ checkIsMatched(arr, conditionOrcallback)

Checks if any item matches.

checkIsMatched([1,2,3], 2); // true

✅ checkIsAllMatched(arr, conditionOrcallback)

Checks if all items match.

checkIsAllMatched([2,2,2], 2); // true

🔀 sortAnArray(arr, key?)

Sorts an array or array of objects.

sortAnArray([3,1,2]); // [1,2,3]
sortAnArray([{a:2},{a:1}], "a"); // [{a:1},{a:2}]

🧩 flatAnArray(arr)

Deep flattens nested arrays.

flatAnArray([1,[],[2,[3]]]); // [1,2,3]

🔗 merginMultipleArray(...arrays)

Merges multiple arrays into one.

merginMultipleArray([1],[2],[3]); // [1,2,3]

➕ countItem(arr, key?)

Counts or sums array values.

countItem([1,2,3]); // 6
countItem([{a:1},{a:2}], "a"); // 3

📄 License

MIT

  • GitHub Repository: https://github.com/phane-tech/phane-tech-array-utils
  • Demo / Documentation: https://phane-tech.github.io/phane-tech-array-utils/module-ArrayHelpers.html
  • Unit Test Cases Reports: https://phane-tech.github.io/phane-tech-array-utils/unit-test-report.html

Keywords

javascript

FAQs

Package last updated on 19 Jan 2026

Did you know?

Socket

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.

Install

Related posts