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

list-maker

v1.1.0

Published

Use the list maker package to simplify your code associated with data structures such as lists. Shorten your several lines of code with simply one call!

Readme

List maker

List maker simplifies your interaction with lists in javascript. Now, you can manipulate lists easily and efficiently with much more easy-to-understand code!

Installation

Install list maker with npm

  npm i list-maker

Documentation

A new list can be made by using the following code

const { List } = require('list-maker');
let names = new List(["John", "Tim", "John", "Paul"]);
// To access the array, call the .array property
console.log(names.array); // Logs ["John", "Tim", "John", "Paul"]

To add an element to the newly created list, use the add function

names.add("Kanye");
console.log(names.array); // Now the list has a new element called Kanye: ["John", "Tim", "John", "Paul", "Kanye"]

To remove an element/elements, use the following functions

names.removeAt(1); // The 2nd element has been removed: ["John", "John", "Paul", "Kanye"]
names.removeRepeats(); // Removes all the repeated data in a list: ["John", "Paul", "Kanye"]
names.removeFirst(); // The first element has been removed: ["Paul", "Kanye"]
names.removeLast(); // The last element has been removed: ["Paul"]
names.empty(); // Removes all elements from the list: []

It is possible to add multiple elements to a list maker list as well:

names.add("Smith", "Kyle", "Logan");

Sorting Lists:

names.sortAsc(); // Sorting the list in ascending order
names.sortDesc(); // Sorting the list in descending order

Splitting of a list:

let ageNames = new List([25, "Lowry", 18, "Michael", 37, "Kim", 27, "Lee"]);
ageNames.splitPairs(); // The main list is split into sub-lists with elements having pairs of values, the age and name: [[25, "Lowry"], [18, "Michael"], [37, "Kim"], [27, "Lee"]]
let genderAgeNames = new List(["male", 25, "Lowry", "male", 19, "Patrick", "female", 40, "Amanda"]);
// The list must now be split into a sub-list with three elements:
genderAgeNames.splitList(3)

Sometimes list can contain lists inside them. To sort these lists, the sortInnerList function can be used.

Since we want to sort according to age, that is the first field in the inner list, we pass zero as a parameter (indexing starts with zero).

let ageNames = new List([[25, "Lowry"], [18, "Michael"], [37, "Kim"], [27, "Lee"]]);
ageNames.sortInnerList(0);
console.log(ageNames.array); // Ascending order of age: [[18, "Michael"], [25, "Lowry"], [27, "Lee"], [37, "Kim"]]

If we want to sort ageNames in ascending order of name, we will provide the number 1 as a parameter:

let ageNames = new List([[25, "Lowry"], [18, "Michael"], [37, "Kim"], [27, "Lee"]]);
ageNames.sortInnerList(1);
console.log(ageNames.array); // Ascending order of name: [[37, "Kim"], [27, "Lee"], [25, "Lowry"], [18, "Michael"]]

Converting an already created list to a list-maker list:

const arr = [1, 2, 3, 4, 5];
let method1 = new List(arr);
let method2 = new List();
method2.dumpList(arr); // Retrieving all the individual elements in arr and dumping them in a list-maker list

Replacing elements in a list:

const arr = new List(["Shaun", "Kevin", "Louise", "Larry", "Kevin"]);
arr.replaceAt(2, "Fraiser"); // Replacing the 3rd element in the list with the string "Fraiser" (indexing from 0): ["Shaun", "Kevin", "Fraiser", "Larry", "Kevin"]
arr.replaceFirstOccurrence("Shaun", "Sean"); // Replacing the first instance of the word "Shaun" in the list with the string "Sean": ["Sean", "Kevin", "Fraiser", "Larry", "Kevin"]
arr.replaceAll("Kevin", "Kean") // Replacing all the instances of the word "Kevin" with the string "Kean"

Advanced remove functions:

const names = ["Stuart", "Leonard", "Amy", "Bert", "Stuart"];
names.removeFirstOccurrence("Stuart"); // The function removes the first occurrence of the name stuart: ["Leonard", "Amy", "Bert", "Stuart"]
names.removeIndexes(2, 3); // The function removes elements in the indexes two and three: ["Leonard", "Amy"]
names.removeVal("Leonard"); // Removes all the occurrences of the name Leonard: ["Amy"]
const foods = ["Brisket", "Sushi", "Salmon", "Ramen", "Penne"];
foods.removeRange(0, 2); // This function removes all elements in the range of indexes zero to two: ["Ramen", "Penne"]

Formatting list values:

const numbArr = ["1", "2", "3", "4", "5"];
numbArr.convertToNumbers(); // Converts the type of all elements to a number
const stringArr = numbArr.convertToStrings(); // Converts the type of all elements to a string
const two_dec_arr = numbArr.roundAllDigits(2); // Rounds all elements to 2 decimal places: [1.00, 2.00, 3.00, 4.00, 5.00]

More functions:

const nums = [1, 1, 2, 2, 3, 3, 4, 4, 5, 5];

console.log(nums.numOccurrences(1)); // Returns the number of occurrences of the number 1 in the list
console.log(nums.findPositions(1)); // Returns the index positions of the number 1 in the list
console.log(nums.summate()); // Adds all the values in the list together
console.log(nums.average()); // Takes average of the values in the list

const letters_split = ["H", "E", "L", "L", "O", " ", "W", "O", "R", "L", "D"];
console.log(letters_split.concatenate()); // Returns the string: HELLO WORLD

A list can be copied by using the clone function:

const series = new List([1, 2, 3, 4, 5]);
const another_series = series.clone();

License

MIT

Authors