Noisy Pterodactyl Melodies

    func-cache
    TypeScript icon, indicating that this package has built-in type declarations

    1.3.0 • Public • Published

    Fun cache

    This is the fun and cache.

    How does it work:

    It stores a map of results of a function and uses arguments as keys, for faster response,

    Note that if the function result in different results with the same argument, the cache wouldn't work.

    How to use:

    import funcache from "func-cache";
    
    const cachedFibonacci: typeof fibonnacci = funcache(fibonacci);
    function fibonnacci(num: number) {
      let a = 1,
        b = 0,
        temp;
    
      while (num >= 0) {
        temp = a;
        a = a + b;
        b = temp;
        num--;
      }
    
      return b;
    }
    
    console.log(cachedFibonacci(1000)); //-- viewing the result

    Install

    npm i func-cache

    DownloadsWeekly Downloads

    7

    Version

    1.3.0

    License

    MIT

    Unpacked Size

    11 kB

    Total Files

    13

    Last publish

    Collaborators

    • wolfpat01