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 🙏

© 2025 – Pkg Stats / Ryan Hefner

infinityf

v2.0.1

Published

make javascript able to infinity recursion

Downloads

3

Readme

Infinityf

Infinity recursive function

infinityf makes javascript able to use infinity call stack if you have enought memory.

It works exactly the same as vanilla function. There are ways to use infinity function:

###callback Best performance. It receive return data in callback function. Not support async.

Code is a little bit dirty, i don't recommend for the projects using dynamic function call.

###async Bad performance(in non blocking code). It receive return data by await expression. Support async.

I think if use this async infinity function as "async function", it will almost don't depress performance.

###generator Good performance. It receive return data by yield expression. Not support async.

I recommend this way for general projects.

Installation

$ npm install infinityf

Usage

var fibo = (n) => {
    if(n <= 2)
        return 1;
    return fibo(n-1) + fibo(n-2);
};
console.log(fibo(10));

this code is the same as :

1.callback

const infinityf = require("infinityf");

var infFibo = (get,arg) => {
    if(arg <= 2)
        return 1;
    get(infFibo, arg-1, (v1)=>{
        get(infFibo, arg-2, (v2)=> {
            return v1 + v2;
        });
    });
};
console.log(infinityf.callback(infFibo,10));

2.async

const infinityf = require("infinityf");

var infFibo = async (get,arg) => {
    if(arg <= 2)
        return 1;
    return await get(infFibo, arg-1) + await get(infFibo, arg-2);
};

infinityf.async(infFibo,10).then(returnValue => {
    console.log(returnValue);
});

3.generator

const infinityf = require("infinityf");

var infFibo = function* (get,arg) {
    if(arg <= 2)
        return 1;
    return (yield get(infFibo, arg-1)) + (yield get(infFibo, arg-2));
};

console.log(infinityf.generator(infFibo,10));

Functions / Types

infinityf[InfinityFunctionType](InfinityFunction f, arg)

infinityf runs InfinityFunction f with arg and return result.

1.callback

console.log(infinityf.callback(f,arg));

2.async

infinityf.async(f,arg).then(returnedValue => {
    console.log(returnValue);
});

3.generator

console.log(infinityf.generator(f,arg));

InfinityFunctionType

String, "callback" or "async" or "generator"

InfinityFunction

Function, it have to be same type as InfinityFunctionType.

1.callback

let f = (get,arg) => {
    get(func, otherArg, returnedValue => {
        ...
    });
};

In callback infinity function / callback function, only call "get" once.

2.async

let f = async (get,arg) => {
    let returnedValue = await get(func, otherArg);
    ...
};

3.generator

let f = function* (get,arg) => {
    let returnedValue = yield get(func, otherArg); //use yield to ONLY call get function
    ...
}

about get function

get function is used to get other InfinityFunction's result with args. After get other InfinityFunction's result, it will call callback with result.

Generator, Async function

get function

Simple.

let returnedValue = await get(func, arg); //IN ASYNC INFINITY FUNCTION
let returnedValue = yield get(func, arg); //IN GENERATOR INFINITY FUNCTION

return

Simple..

return returnValue; //IN ASYNC / GENERATOR INFINITY FUNCTION

just return.

Callback function

get function

After call the get function, do not use return because return don't do anything. and I recommend to don't run anything after use get function.

let myFunction = (get,arg) => {
    get(otherIF,7,data=>{
        console.log(`otherIF's result: ${data}`);
    });
    otherF(); //NOT GOOD.
};

CallbackFunction, result => { ... }

CallbackFunction is not a real type(class). CallbackFunction is made by user code, like this:

let myFunction = (get,arg) => {
    get(otherIF,7,data=>{ //<= this is CallbackFunction
        console.log(`otherIF's result: ${data}`);
    });
};

return

You can return the value in everywhere in InfinityFunction (callback). InfinityFunction (callback) or CallbackFunction.

this is a fibonacci number function:

const infinityf = require("infinityf");

var infFibo = (get,arg) => {
    if(arg <= 2)
        return 1; //can return
    get(infFibo, arg-1, (v1)=>{
        get(infFibo, arg-2, (v2)=> {
            return v1 + v2; //can return in CallbackFunction
        });
    });
};
console.log(infinityf(infFibo,10));