npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

phane-tech-array-utils

v1.0.2

Published

Pure JavaScript array utility functions

Downloads

203

Readme

📦 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, condition , callback)

Filters array values.

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

🔎 findArrayItem(arr, condition , callback)

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, condition , callback)

Checks if any item matches.

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

✅ checkIsAllMatched(arr, condition , callback)

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

🔗 Links

  • 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