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

@yogesh_longwani/js-lab

v1.0.2

Published

A collection of hand-crafted JavaScript utility functions and custom Array/String prototype methods — built from scratch to learn how JavaScript internals work.

Readme

js-lab

A small JavaScript utility library built from scratch to learn how core language features work under the hood.

It includes:

  • custom Array.prototype methods
  • custom String.prototype methods
  • standalone array and string helpers
  • debounce/throttle performance helpers
  • a simple custom iterator

This project is written in CommonJS and is designed both for learning and for experimenting with JavaScript internals.


Table of contents


Features

  • Learn how built-in array methods work by re-implementing them yourself
  • Explore string helpers and prototype methods
  • Use reusable utilities for interview-style array problems
  • Control event frequency with debounce and throttle
  • Create custom iterators that follow the Iterator Protocol

Installation

npm install @yogesh_longwani/js-lab

Or clone the repository and work directly with the source files.

Note: this package currently exposes module subpaths like js-lab/array, js-lab/string, js-lab/performance, and js-lab/iterators.


Usage

Array utilities

const {
  applyArrayPrototypes,
  removeDuplicates,
  findMaxMin,
} = require("@yogesh_longwani/js-lab/array");

applyArrayPrototypes();

console.log([1, 2, 3].myMap((x) => x * 2));
// [2, 4, 6]

console.log(removeDuplicates([1, 2, 2, 3, 3, 4]));
// [1, 2, 3, 4]

console.log(findMaxMin([5, 9, 1, 7]));
// { min: 1, max: 9 }

String utilities

const {
  applyStringPrototypes,
  compressString,
  firstNonRepeatingChar,
} = require("@yogesh_longwani/js-lab/string");

applyStringPrototypes();

console.log("hello".myToUpperCase());
// HELLO

console.log(compressString("aaabbcccc"));
// a3b2c4

console.log(firstNonRepeatingChar("aabbcdd"));
// c

Performance helpers

const { debounce, throttle } = require("@yogesh_longwani/js-lab/performance");

const onSearch = debounce((query) => {
  console.log("Searching for:", query);
}, 300);

const onScroll = throttle(() => {
  console.log("Scroll event handled");
}, 100);

Iterator helper

const { makeIterator } = require("@yogesh_longwani/js-lab/iterators");

const iterator = makeIterator(0, 5, 2);

console.log(iterator.next());
// { value: 0, done: false }
console.log(iterator.next());
// { value: 2, done: false }
console.log(iterator.next());
// { value: 4, done: false }

Modules

js-lab/array

Contains both prototype methods and standalone array utilities.

Prototype methods

Call applyArrayPrototypes() once to attach the custom methods to Array.prototype.

Standalone utilities

Use these without modifying native prototypes.

js-lab/string

Contains custom string prototype methods plus standalone string helpers.

js-lab/performance

Contains debounce and throttle for controlling function execution rate.

js-lab/iterators

Contains a custom iterator factory built around the Iterator Protocol.


API Reference

Array prototype methods

Mutation methods

  • myPush(...items) — add items to the end of an array
  • myPop() — remove the last element
  • myShift() — remove the first element
  • myUnshift(x) — add one element to the beginning
  • myReverse() — reverse an array in place
  • mySplice(start, deleteCount) — custom splice implementation

Iteration methods

  • myForEach(callback)
  • myMap(callback)
  • myFilter(callback)
  • myFind(callback)
  • myFindIndex(callback)
  • myEvery(callback)
  • mySome(callback)
  • mySlice(start, end)
  • myLastIndexOf(searchElement)

Standalone array utilities

  • removeDuplicates(arr)
  • findFirstDuplicate(arr)
  • findFirstMissingNumber(arr)
  • findMaxMin(arr)
  • findSecondLargest(arr)
  • intersection(arr1, arr2)
  • isSubarray(mainArr, subArr)
  • majorityElement(arr)
  • moveZerosToEnd(arr)
  • reverseArray(arr)
  • rotateArray(arr, k)
  • myConcat(...arrays)
  • myJoin(arr, separator)
  • isPalindrome(arr)

String prototype methods

  • myToUpperCase()
  • myToLowerCase()
  • myIndexOf(char)

Standalone string utilities

  • compressString(str)
  • firstNonRepeatingChar(str)
  • stringToInteger(str)

Performance helpers

  • debounce(fn, delay)
  • throttle(fn, delay)

Iterator helper

  • makeIterator(start, end, step)

Project Structure

js-lab/
├── package.json
├── README.md
├── index.js
└── src/
    ├── array/
    │   ├── index.js
    │   ├── prototypes.js
    │   └── utils.js
    ├── string/
    │   └── index.js
    ├── performance/
    │   └── index.js
    └── iterators/
        └── index.js

Notes

  • This library is great for learning and experimenting with JavaScript behavior.
  • Prototype patching is optional, but it should be used carefully in real projects.
  • Some methods are educational re-implementations and may not fully match every edge case of the native JavaScript methods.

Contributing

Pull requests, fixes, and improvements are welcome.

A good contribution usually includes:

  • clear function names
  • comments where the logic is not obvious
  • examples in the README
  • tests for new helpers

License

Choose a valid SPDX license identifier in package.json, such as MIT or UNLICENSED.