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

@kwizeraaimable/1d_array

v1.0.0

Published

Simplifying the manipulation of one dimensional numeric arrays.

Downloads

1

Readme

Description

This is going to simplify coding in javascript when dealing with one dimensional numeric arrays.

Installation

This is an npm package so you'll have to install it via the npm

npm install @kwizeraaimable/1d_array

Usage

This one has a very simple and easy syntax

//Import the npm package
const oneD_arrays_simplified = require("@kwizeraaimable/1d_array");

//A demo array
const demoArray = [1, 2, 3, 4, 1, 2, 3, 5, 6, 7, 8, 9];

//the sum
const sum = oneD_arrays_simplified.sum(demoArray);

//maximum value in the array
const maximum = oneD_arrays_simplified.maximum(demoArray);

//minimum value in the array
const minimum = oneD_arrays_simplified.minimum(demoArray);

//the average
const average = oneD_arrays_simplified.average(demoArray);

//arrange them in ascending order
const ascending = oneD_arrays_simplified.ascending(demoArray);

//arrange them in descending order
const descending = oneD_arrays_simplified.descending(demoArray);

//Reverse the order of the values
const reverse = oneD_arrays_simplified.reverse(demoArray);

//check if a certain value exists in the array
const demoNum = 4;
const exists = oneD_arrays_simplified.valueInArr(demoArray, demoNum);

//remove duplicates from the array
const noDuplicates = oneD_arrays_simplified.removeDuplicates(demoArray);

//find the index of a value
const index = oneD_arrays_simplified.findIndexOf(demoArray, demoNum);

//slice the array
//get the first 3 values
const first3Values = oneD_arrays_simplified.slice(demoArray, 3);

//get the last 4 values, make sure you make the number negative
const last4Values = oneD_arrays_simplified.slice(demoArray, -4);

//concatenate 2 arrays
const arr1 = [1, 2, 3, 4, 5];
const arr2 = [2, 3, 4, 5, 4];
const concatenatedArray = oneD_arrays_simplified.concat(arr1, arr2);

//check if all values meet a certain condition
//this is to check if numbers are even
const condition = (n) => {
  return n % 2 === 0;
};
const allMeetCondition = oneD_arrays_simplified.satisfyCondition(
  demoArray,
  condition
);

//check if atlease one value meets a given condition
const oneMeetsCondition = oneD_arrays_simplified.oneSatisfyCondition(
  demoArray,
  condition
);

//find the index of the last occurrence of a number
const lastIndexofValue = oneD_arrays_simplified.lastOccurrenceOf(
  demoArray,
  demoNum
);

//flatten multdimensional arrays into a one dimensional array
const multdimensional = [
  [1, 2, 3, 4],
  [5, 6, 7, 7],
];
const flattened = oneD_arrays_simplified.flatten(multdimensional);

Conclusion

I thank you for choosing to use my package. I wish you goodluck within your coding journey.