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

js-internals

v1.3.6

Published

This is a NPM Package based on JS , Which is basically gives an deep understanding How Inbuilt Js Functions , Methods Works Under the Hood , it can be much helpful those who are intermediate or new in js or preparing for an Job Preparation !! Happy Coding

Readme

Boost Up The Js Understanding ☠️

github-header-image (2)

Welcome to the Custom JavaScript Functions package! This npm package provides custom implementations of built-in JavaScript functions, allowing users to understand how these functions work internally. This is especially useful for learning purposes and for those who want to see how common JavaScript functions can be replicated.

Features 🚀

  • Custom Implementations: Each function in this package is a custom implementation that mimics the behavior of the native JavaScript functions.
  • Educational: The primary goal of this package is to provide an educational resource for developers to understand the inner workings of JavaScript functions.
  • Polyfill-style Functions: These implementations can serve as polyfills, helping developers use similar functionality in environments where certain features may not be available.

example code 🐬

const { INTERNAL , GET_ALL } = require('js-internals');
//INTERNAL  is an object that contains all the custom native funcs
//map_internals() gives that implemented custom code of native js funcs in a seperate folder
//You can use this custom funcs just by providing a "$" symbol before the name eg. $map();

INTERNAL.map_internals() //You will get the custom implementation of map()

//sample example
const numbers = [1, 2, 3];
const filtered = numbers.$filter(n => n > 2);
console.log('Filtered:', filtered);
//output [3]

//Get all the custom implementations at once
GET_ALL()

Project Tree 🌳

📦 js-internals
│
├── 📂 src
│   ├── 📂 DataStructures
│   │   ├── 📄 Set.js
│   │
│   ├── 📂 Polyfills
│   │   ├── 📂 Array
│   │   │   ├── 📂 InstanceMethods
│   │   │   │   ├── 📄 _map.js
│   │   │   │   ├── 📄 _filter.js
│   │   │   │   ├── 📄 _reduce.js
│   │   │   │   ├── 📄 _forEach.js
│   │   │   │   ├── 📄 _some.js
│   │   │   │   ├── 📄 _every.js
│   │   │   │   ├── 📄 _find.js
│   │   │   │   ├── 📄 _indexOf.js
│   │   │   │   ├── 📄 _includes.js
│   │   │   │   ├── 📄 _sort.js
│   │   │   │   ├── 📄 _reverse.js
│   │   │   │   ├── 📄 _splice.js
│   │   │   │   ├── 📄 _slice.js
│   │   │   │   ├── 📄 _concat.js
│   │   │   │   ├── 📄 _join.js
│   │   │   ├── 📂 StaticMethods
│   │   │   │   ├── 📄 _from.js
│   │   │   │   ├── 📄 _isArray.js
│   │   │   │   ├── 📄 _of.js
│   │   │
│   │   ├── 📂 String
│   │   │   ├── 📄 _charAt.js
│   │   │   ├── 📄 _indexOf.js
│   │   │   ├── 📄 _includes.js
│   │   │   ├── 📄 _slice.js
│   │   │   ├── 📄 _substring.js
│   │   │   ├── 📄 _trim.js
│   │   │   ├── 📄 _toLowerCase.js
│   │   │   ├── 📄 _toUpperCase.js
│   │   │   ├── 📄 _split.js
│   │   │   ├── 📄 _replace.js
│   │   │
│   │   ├── 📂 Object
│   │   │   ├── 📄 _keys.js
│   │   │   ├── 📄 _values.js
│   │   │   ├── 📄 _entries.js
│   │   │   ├── 📄 _assign.js
│   │   │   ├── 📄 _freeze.js
│   │   │   ├── 📄 _seal.js
│   │   │   ├── 📄 _getOwnPropertyDescriptor.js
│   │   │   ├── 📄 _create.js
│   │   │   ├── 📄 _hasOwnProperty.js
│   │   │
│   │   ├── 📂 Function
│   │   │   ├── 📄 _call.js
│   │   │   ├── 📄 _apply.js
│   │   │   ├── 📄 _bind.js
│   │   │
│   │   ├── 📂 Math
│   │   │   ├── 📄 _max.js
│   │   │   ├── 📄 _min.js
│   │   │   ├── 📄 _floor.js
│   │   │   ├── 📄 _ceil.js
│   │   │   ├── 📄 _round.js
│   │   │   ├── 📄 _random.js
│   │   │   ├── 📄 _abs.js
│   │   │
│   │   ├── 📂 Global
│   │   │   ├── 📄 _parseInt.js
│   │   │   ├── 📄 _parseFloat.js
│   │   │   ├── 📄 _isNaN.js
│   │   │   ├── 📄 _isFinite.js
│   │   │   ├── 📄 _stringify.js
│   │   │   ├── 📄 _parse.js
│   │
│   ├── 📄 index.js
│
├── 📂 tests
│   ├── 📂 Array
│   │   ├── 📄 test_map.js
│   │   ├── 📄 test_filter.js
│   │   ├── 📄 test_reduce.js
│   │   ├── 📄 test_forEach.js
│   │   ├── 📄 ...
│   ├── 📂 String
│   │   ├── 📄 test_charAt.js
│   │   ├── 📄 test_indexOf.js
│   │   ├── 📄 ...
│   ├── 📂 Object
│   │   ├── 📄 test_keys.js
│   │   ├── 📄 test_values.js
│   │   ├── 📄 ...
│   ├── 📂 Math
│   │   ├── 📄 test_max.js
│   │   ├── 📄 test_min.js
│   │   ├── 📄 ...
│   ├── 📂 Global
│   │   ├── 📄 test_parseInt.js
│   │   ├── 📄 test_isNaN.js
│   │   ├── 📄 ...
│   ├── 📄 script.js
│
├── 📄 package.json

Sample Code of custom $call(context, ...args) [Same as native call()]

/**
 * Function.prototype.call() - Calls a function with a given 'this' value and arguments provided individually.
 * The "call()" method allows you to invoke a function with a specific 'this' context, along with arguments passed individually. It is useful when you want to change the context ('this') for a particular function invocation.
 * @syntax :
 * @function.call(thisArg, arg1, arg2, ..., argN);

 * @thisArg : The value to use as 'this' when calling the function. If 'thisArg' is 'null' or 'undefined', it will default to the global object ('globalThis' in non-strict mode).
 * @arg1 , arg2, ..., argN: Individual arguments to pass to the function.

 * @returns:
 * The result of calling the function with the provided 'this' value and arguments.
**/

Function.prototype.__call = function(context, ...args) {
    if (typeof this !== "function") {
        throw new Error(this + " is not a function.");
    }

    if (context === undefined || context === null) {
        return this.apply(globalThis, args);
    }

    const boundContext = Object(context);

    boundContext.func = this;
    const result = boundContext.func(...args);
    delete boundContext.func;

    return result;
};

Progress ✨ ~

image

Available Functions 🚀

Array Methods

| Function | Status | Native Function | |--------------------------------------------|----------------|-------------------------------| | $Map(array, callback) | Implemented ✅ | Array.prototype.map() | | $Filter(array, callback) | Implemented ✅ | Array.prototype.filter() | | $Reduce(array, callback, initialValue) | Implemented ✅ | Array.prototype.reduce() | | $Array.from(value) | Implemented ✅ | Array.from() | | $Array.isArray(array) | Implemented ✅ | Array.isArray() | | $Array.of(value) | Implemented ✅ | Array.of() | | $ForEach(array, callback) | Implemented ✅ | Array.prototype.forEach() | | $Some(array, callback) | Implemented ✅ | Array.prototype.some() | | $Every(array, callback) | Implemented ✅ | Array.prototype.every() | | $Find(array, callback) | Implemented ✅ | Array.prototype.find() | | $IndexOf(array, element) | Implemented ✅ | Array.prototype.indexOf() | | $Includes(array, element) | Implemented ✅ | Array.prototype.includes() | | $Reverse(array) | Implemented ✅ | Array.prototype.reverse() | | $Sort(array, compareFunction) | Implemented ✅ | Array.prototype.sort() | | $Splice(array, start, deleteCount, ...items) | Implemented ✅ | Array.prototype.splice() | | $Slice(array, start, end) | Implemented ✅ | Array.prototype.slice() | | $Concat(array, ...arrays) | Todo | Array.prototype.concat() | | $Join(array, separator) | Todo | Array.prototype.join() |

String Methods

| Function | Status | Native Function | |----------------------------------------------|----------------|----------------------------------| | $CharAt(string, index) | Todo | String.prototype.charAt() | | $IndexOf(string, searchValue, fromIndex) | Todo | String.prototype.indexOf() | | $Includes(string, searchString, fromIndex)| Todo | String.prototype.includes() | | $Slice(string, start, end) | Todo | String.prototype.slice() | | $Substring(string, start, end) | Todo | String.prototype.substring() | | $Trim(string) | Todo | String.prototype.trim() | | $ToLowerCase(string) | Todo | String.prototype.toLowerCase() | | $ToUpperCase(string) | Todo | String.prototype.toUpperCase() | | $Split(string, separator, limit) | Todo | String.prototype.split() | | $Replace(string, searchValue, newValue) | Todo | String.prototype.replace() |

Object Methods

| Function | Status | Native Function | |--------------------------------------------|----------------|----------------------------------------| | $Keys(object) | Todo | Object.keys() | | $Values(object) | Todo | Object.values() | | $Entries(object) | Todo | Object.entries() | | $Assign(target, ...sources) | Todo | Object.assign() | | $Freeze(object) | Todo | Object.freeze() | | $Seal(object) | Todo | Object.seal() | | $GetOwnPropertyDescriptor(object, property) | Todo | Object.getOwnPropertyDescriptor() | | $Create(prototype, properties) | Todo | Object.create() | | $HasOwnProperty(object, property) | Todo | Object.prototype.hasOwnProperty() |

Function Methods

| Function | Status | Native Function | |--------------------------------------------|----------------|-------------------------------------| | $Call(func, thisArg, ...args) | Implemented ✅ | Function.prototype.call() | | $Apply(func, thisArg, args) | Implemented ✅ | Function.prototype.apply() | | $Bind(func, thisArg, ...args) | Implemented ✅ | Function.prototype.bind() |

Math Methods

| Function | Status | Native Function | |--------------------------------------------|----------------|-----------------------------------| | $Max(...numbers) | Implemented ✅ | Math.max() | | $Min(...numbers) | Implemented ✅ | Math.min() | | $Floor(number) | Todo | Math.floor() | | $Ceil(number) | Todo | Math.ceil() | | $Round(number) | Todo | Math.round() | | $Random() | Todo | Math.random() | | $Abs(number) | Todo | Math.abs() |

Other Global Functions

| Function | Status | Native Function | |--------------------------------------------|----------------|----------------------------------| | $ParseInt(string, radix) | Implemented ✅ | parseInt() | | $ParseFloat(string) | Implemented ✅ | parseFloat() | | $IsNaN(value) | Implemented ✅ | isNaN() | | $IsFinite(value) | Implemented ✅ | isFinite() | | $parseJSON(jsonString) | Implemented ✅ | JSON.parse() | | $Stringify(value) | Implemented ✅ | JSON.stringify() |

Hello Devs 👋🏻 If you want to contribute you are always Welcome !! Come and Contribute Here > 3 💗🫠

Contribution Rule's

  • maintain existing file naming convension (eg. _file.js)
  • maintain existing code format for Contribution
  • ensure you write all the import tests for that func maintaining the proper format (eg. test_funcName.js)
  • demo test file for custom func $call()
const { __call } = require('../package/src/internal-custom-functions/Array_Object/Static_Methods/_call');

function deepEqual(obj1, obj2) {
    return JSON.stringify(obj1) === JSON.stringify(obj2);
}

// Run tests for the custom __call method
const tests = [
    {
        description: 'Basic Function Call with Context',
        func: function(greeting, punctuation) { return `${greeting}, ${this.name}${punctuation}`; },
        context: { name: 'Alice' },
        args: ['Hello', '!'],
        expected: 'Hello, Alice!',
        testNumber: 0
    },
    {
        description: 'Function with No Context',
        func: function(num1, num2) { return num1 + num2; },
        context: undefined,
        args: [5, 10],
        expected: 15,
        testNumber: 1
    }
    //Write atleast 7-8 proper test cases.
];

// Run the tests
tests.forEach(test => {
    let result;
    let errorOccurred = false;
    try {
        result = test.func.__call(test.context, ...test.args);
    } catch (error) {
        if (test.expectedError) {
            errorOccurred = true;
            console.log(`Passed Test${test.testNumber} ✅: ${test.description}`);
        } else {
            console.log(`Failed Test${test.testNumber} ❌: ${test.description}`);
            console.error('Unexpected Error:', error);
        }
    }

    if (!errorOccurred && deepEqual(result, test.expected)) {
        console.log(`Passed Test${test.testNumber} ✅: ${test.description}`);
    } else if (!errorOccurred) {
        console.log(`Failed Test${test.testNumber} ❌: ${test.description}`);
        console.log(`Expected: ${JSON.stringify(test.expected)}`);
        console.log(`Actual: ${JSON.stringify(result)}`);
    }
});

Project SetUp

First Clone The Repo

git clone https://github.com/Rudrajiii/Js-Internals

Then Move To Project Directory

cd Js-Internals

Now Open Your Favourite Code Editor [ Mine is Vs-Code :) So ]

code .

Installation ⏬

To install this package, use npm:

npm install --save-dev js-internals

To Run The Tests: Make the test script executable: For (Linux):

chmod +x pkg_tester.sh

Run the test script:

./pkg_tester.sh