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 🙏

© 2024 – Pkg Stats / Ryan Hefner

array-utils-package

v1.0.0

Published

This npm package provides a collection of utility functions for performing common operations on arrays. These functions are designed to simplify and speed up array manipulation tasks in JavaScript projects.

Downloads

4

Readme

Array Utils Package

This npm package provides a collection of utility functions for performing common operations on arrays. These functions are designed to simplify and speed up array manipulation tasks in JavaScript projects.

Installation

To install this package, run the following command:

npm install array-utils-package

Usage

After installing the package, you can import and use the provided utility functions in your project. Below is an example of how to use the package:

const arrayUtils = require('array-utils-package');

const numbers = [1, 2, 2, 3, 4, 5, 5, 6, 7];

console.log(arrayUtils.sum(numbers)); // Output: 35

console.log(arrayUtils.average(numbers)); // Output: 3.888888888888889

console.log(arrayUtils.max(numbers)); // Output: 7

console.log(arrayUtils.min(numbers)); // Output: 1

console.log(arrayUtils.unique(numbers)); // Output: [1, 2, 3, 4, 5, 6, 7]

console.log(arrayUtils.clear()); // Output: []

console.log(arrayUtils.chunk(numbers, 3)); // Output: [[1, 2, 2], [3, 4, 5], [5, 6, 7]]

const nestedArray = [1, [2, 3], [4, [5, 6]], 7];
console.log(arrayUtils.flatten(nestedArray)); // Output: [1, 2, 3, 4, 5, 6, 7]

const arr1 = [1, 2, 3];
const arr2 = [2, 3, 4];
console.log(arrayUtils.difference(arr1, arr2)); // Output: [1]

console.log(arrayUtils.intersect(arr1, arr2)); // Output: [2, 3]

Functions

  1. sum(arr)

    • Description: Returns the sum of all elements in the array.
    • Parameters: arr (Array): The array of numbers.
    • Returns: number: The sum of the array elements.
  2. average(arr)

    • Description: Returns the average of all elements in the array.
    • Parameters: arr (Array): The array of numbers.
    • Returns: number: The average of the array elements.
  3. max(arr)

    • Description: Returns the maximum value in the array.
    • Parameters: arr (Array): The array of numbers.
    • Returns: number: The maximum value in the array.
  4. min(arr)

    • Description: Returns the minimum value in the array.
    • Parameters: arr (Array): The array of numbers.
    • Returns: number: The minimum value in the array.
  5. unique(arr)

    • Description: Removes duplicate values from the array and returns a new array with unique elements.
    • Parameters: arr (Array): The array of values.
    • Returns: Array: A new array with unique elements.
  6. clear()

    • Description: Clears all elements from the array (returns an empty array).
    • Parameters: None
    • Returns: Array: An empty array.
  7. chunk(arr, size)

    • Description: Splits the array into chunks of a specified size.
    • Parameters: arr (Array): The array to be chunked.
    • Returns: Array: An array of chunks.
  8. flatten(arr)

    • Description: Flattens a nested array into a single array.
    • Parameters: arr (Array): The nested array.
    • Returns: Array: A single flattened array.
  9. difference(arr1, arr2)

    • Description: Returns an array of elements that are in the first array but not in the second.
    • Parameters: arr1 (Array): The first array.
    • Returns: Array: An array of elements in arr1 that are not in arr2.
  10. intersect(arr1, arr2)

    • Description: Returns an array of elements that are common to both arrays.
    • Parameters: arr1 (Array): The first array.
    • Returns: Array: An array of elements that are common to both arr1 and arr2.