0.9.0 • Published 7 years ago

node-memoza v0.9.0

Weekly downloads
287
License
MIT
Repository
github
Last release
7 years ago

Memoza

Build Status Code Climate Test Coverage

Description

Like _.memoize this one allows to cache functions and stores the results in FS.

Configuration

const memoza = require('node-memoza');
const wrapper = memoza({ cache: { path: cachePath } });
  1. Remembers cb's arguments

    const func = (param1, cb) => {
     setTimeout(() => { cb(param1); }, 10000);
    }
    const wrapped = wrapper(func);
    wrapped(1234, (param) => console.log(param)); //will log "1234" in 10 seconds
    // ...once cb called
    wrapped(1234, (param) => console.log(param)); //will log "1234" without delay
  2. Remembers Promise resolution value

    const func = (param1) => {
     return new Promise((resolve) => {
       setTimeout(() => { resolve(param1); }, 10000);
     });
    }
    const wrapped = wrapper(func);
    wrapped(1234).then((param) => console.log(param)); //will log "1234" in 10 seconds
    wrapped(1234).then((param) => console.log(param)); // ...once promise has been resolved it will log "1234"
0.9.0

7 years ago

0.8.0

7 years ago

0.7.0

7 years ago

0.6.0

7 years ago

0.5.1

7 years ago

0.5.0

7 years ago

0.4.0

7 years ago

0.3.2

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago