0.1.9 • Published 11 years ago

memoize_test v0.1.9

Weekly downloads
38
License
-
Repository
github
Last release
11 years ago

Memoization Test

Memoize a slow function with callback in its arguments.

Note. The callback on the function must be the first argument.

Installation

npm install memoize_test

Usage

The input of memoize is slow_function and the output is a faster function.

memoize = require('memoize_test')

fast_function = memoize(slow_function); // runs faster than slow_function by using cache functions

You can also pass the TTL. The default one will be 5 seconds.

fast_function = memoize(slow_function,{ttl:2000}); // Time to live set to 2 seconds

Special case

We can also assume that sometimes the cache function can be slower than the slow_function.In this situation both the cache_retrieve and slow_fn will be called and the first being completed will be used. To see a solution for this case, take a look at better_memoization.coffee

For test purpose if you're running better_memoization.coffee the number 2 will always simulate the cache function being slower.

Author

This was written by Esteban Arango Medina.

0.1.9

11 years ago

0.1.8

11 years ago

0.1.7

11 years ago

0.1.6

11 years ago

0.1.5

11 years ago

0.1.4

11 years ago

0.1.3

11 years ago

0.1.2

11 years ago

0.1.1

11 years ago