1
0
mirror of https://github.com/mgerb/mywebsite synced 2026-01-12 10:52:47 +00:00

updated bunch of file paths and changed the way posts are loaded

This commit is contained in:
2016-01-05 12:28:04 -06:00
parent 719ae331ae
commit c96a84d0ff
13249 changed files with 317868 additions and 2101398 deletions

31
node_modules/memoizee/.lint generated vendored Normal file
View File

@@ -0,0 +1,31 @@
@root
module
indent 2
maxlen 100
tabs
ass
plusplus
nomen
./lib/_base.js
bitwise
./ext/max-age.js
predef+ setTimeout, clearTimeout
./lib/ext/max.js
bitwise
continue
predef+ setTimeout, clearTimeout
./test/index.js
./test/ext/max-age.js
predef+ setTimeout
./benchmark
sub
predef+ console

4
node_modules/memoizee/.npmignore generated vendored Normal file
View File

@@ -0,0 +1,4 @@
.DS_Store
/node_modules
/npm-debug.log
/.lintcache

1
node_modules/memoizee/.testignore generated vendored Normal file
View File

@@ -0,0 +1 @@
/benchmark

15
node_modules/memoizee/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,15 @@
sudo: false # http://docs.travis-ci.com/user/workers/container-based-infrastructure/
language: node_js
node_js:
- 0.10
- 0.12
- iojs
before_install:
- mkdir node_modules; ln -s ../ node_modules/memoizee
notifications:
email:
- medikoo+memoize@medikoo.com
script: "npm test && npm run lint"

94
node_modules/memoizee/CHANGES generated vendored Normal file
View File

@@ -0,0 +1,94 @@
v0.3.9 -- 2015.08.04
* Update dependencies
* Improve documentation
* FIx spelling of LICENSE
v0.3.8 -- 2014.10.08
* Introduce WeakMap based `weak` mode
v0.3.7 -- 2014.08.14
* Fix prefetch support for asynchronous functions (#19)
* Configure lint scripts
v0.3.6 -- 2014.07.28
* Fix race condition issue related to clear/delete calls and returning id's (#18)
* Fix maxAge major cache handling issue (on timeout instead of individual record whole cache was
cleared)
v0.3.5 -- 2014.07.07
* Fix internal id genaration, for primitive, length = 1 case.
Ids were not serialized to strings, and that caused issues with other
internal logiv, which e.g. treated `null` case specifically.
Fixes #15 (Thanks @isaacg for reporting)
v0.3.4 -- 2014.06.22
* Fix async handling in case of clear between two async calls
(assurance of unique cache ids solves that). Fixes #13
v0.3.3 -- 2014.05.12
* Fix profiler special property definition
v0.3.2 -- 2014.05.01
* Provide no-arguments memoization out of a box
(no need to provide normalizer to `memoizee/plain`)
v0.3.1 -- 2014.04.27
* Update package.json to use latest 'tad' engine (fixes tests evaluation)
v0.3.0 -- 2014.04.27
Major reorganization and partial refactoring
* Move out main modules from lib folder
* Introduce normalizer based memoization. Primitive and regular handlers were converted into
dedicated normalizers (located in lib/normalizers folder). Custom normalizers can be provided at
run time via `normalizer` option.
* Provide 'plain' module which does not import (require) any extensions or normalizers. Thanks to
that it's lighter for e.g. client-side bundle. Any extensions that are expected to be used should
be required upfront, normalizers should be provided via `normalizer` option.
* Rename `memoized.clear` into `memoized.delete`, and `memoized.clearAll` into `memoized.clear`
* Rename `memoized.clearRef` into `memoized.deleteRef` (applies to 'refCounter' option)
* Remove 'method' option. Instead 'methods' and 'methods-plan' modules are provided which generate
descriptors for lazy created memoized methods.
* 'profile' is no longer an extension. It's provided as dedicated module.
* Clean up logic for `async` handling
* Take out 'max' extension's LRU logic into external `lru-queue` package.
See https://github.com/medikoo/lru-queue
* Remove possibility to access original arguments when resolvers are used
* Assure expected length of memoized functions
* Remove Makefile (it's environment agnostic package)
v0.2.6 -- 2013.10.08
* Fix internal events propagation when handling async calls that
resolve with errors. `asyncpurge` was emitted for values that had no
`asyncinit` emitted. Issue #9
v0.2.5 -- 2013.06.21
* Fix primitive handling for dynamic arguments length
v0.2.4 -- 2013.03.23
* Throw on circular invocations, they cannot be memoized as intended.
v0.2.3 -- 2012.10.04
* Fixed serious bug related to not properly cleared cache when working in
regular mode
v0.2.2 -- 2012.10.03
* preFetch functionality for maxAge variant
* Prevent memoization of already memoized functions
v0.2.1 -- 2012.09.21
* Fix missing global reference in method option logic
* Fix variable visibility in async option logic
* Lint cleanup
v0.2.0 -- 2012.09.21
* Modularization and general algorithm cleanup
* Cache is limited (max option) using LRU instead of FIFO algorithm
* Improved async mode, and its handling by other options
v0.1.1 -- 2012.09.19
* Fix dispose invocations for no arguments call
* Small documentation improvements
v0.1.0 -- 2012.09.18
* Initial. Derived from es5-ext package and added `async`, `maxAge`,
`refCounter`, `max` and `dispose` options.

19
node_modules/memoizee/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,19 @@
Copyright (C) 2012 Mariusz Nowak (www.medikoo.com)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

364
node_modules/memoizee/README.md generated vendored Normal file
View File

@@ -0,0 +1,364 @@
# Memoize
## Complete memoize/cache solution for JavaScript
_Originally derived from [es5-ext](https://github.com/medikoo/es5-ext) package._
Memoization is best technique to save on memory or CPU cycles when we deal with repeated operations. For detailed insight see: http://en.wikipedia.org/wiki/Memoization
### Features
* Works with any type of function arguments __no serialization is needed__
* Works with [__any length of function arguments__](#arguments-length). Length can be set as fixed or dynamic.
* One of the [__fastest__](#benchmarks) available solutions.
* Support for [__asynchronous functions__](#memoizing-asynchronous-functions)
* [__Primitive mode__](#primitive-mode) which assures fast performance when arguments are conversible to strings.
* [__WeakMap based mode__](#weakmap-based-configurations) for garbage collection friendly configuration
* Can be configured [__for methods__](#memoizing-a-method) (when `this` counts in)
* Cache [__can be cleared manually__](#manual-clean-up) or [__after specified timeout__](#expire-cache-after-given-period-of-time)
* Cache size can be __[limited on LRU basis](#limiting-cache-size)__
* Optionally [__accepts resolvers__](#resolvers) that normalize function arguments before passing them to underlying function.
* Optional [__reference counter mode__](#reference-counter), that allows more sophisticated cache management
* [__Profile tool__](#profiling--statistics) that provides valuable usage statistics
* Covered by [__over 500 unit tests__](#tests-)
### Installation
In your project path — __note the two `e`'s in `memoizee`:__
$ npm install memoizee
_`memoize` name was already taken, therefore project is published as `memoizee` on NPM._
To port it to Browser or any other (non CJS) environment, use your favorite CJS bundler. No favorite yet? Try: [Browserify](http://browserify.org/), [Webmake](https://github.com/medikoo/modules-webmake) or [Webpack](http://webpack.github.io/)
### Usage
```javascript
var memoize = require('memoizee');
var fn = function (one, two, three) { /* ... */ };
memoized = memoize(fn);
memoized('foo', 3, 'bar');
memoized('foo', 3, 'bar'); // Cache hit
```
### Configuration
All below options can be applied in any combination
#### Arguments length
By default fixed number of arguments that function take is assumed (it's read from function's `length` property) this can be overridden:
```javascript
memoized = memoize(fn, { length: 2 });
memoized('foo'); // Assumed: 'foo', undefined
memoized('foo', undefined); // Cache hit
memoized('foo', 3, {}); // Third argument is ignored (but passed to underlying function)
memoized('foo', 3, 13); // Cache hit
```
Dynamic _length_ behavior can be forced by setting _length_ to `false`, that means memoize will work with any number of arguments.
```javascript
memoized = memoize(fn, { length: false });
memoized('foo');
memoized('foo'); // Cache hit
memoized('foo', undefined);
memoized('foo', undefined); // Cache hit
memoized('foo', 3, {});
memoized('foo', 3, 13);
memoized('foo', 3, 13); // Cache hit
```
#### Primitive mode
If we work with large result sets, or memoize hot functions, default mode may not perform as fast as we expect. In that case it's good to run memoization in _primitive_ mode. To provide fast access, results are saved in hash instead of an array. Generated hash ids are result of arguments to string convertion. __Mind that this mode will work correctly only if stringified arguments produce unique strings.__
```javascript
memoized = memoize(fn, { primitive: true });
memoized('/path/one');
memoized('/path/one'); // Cache hit
```
#### Resolvers
When we're expecting arguments of certain type it's good to coerce them before doing memoization. We can do that by passing additional resolvers array:
```javascript
memoized = memoize(fn, { length: 2, resolvers: [String, Boolean] });
memoized(12, [1,2,3].length);
memoized("12", true); // Cache hit
memoized({ toString: function () { return "12"; } }, {}); // Cache hit
```
__Note. If your arguments are collections (arrays or hashes) that you want to memoize by content (not by self objects), you need to cast them to strings__, for it's best to just use [primitive mode](#primitive-mode). Arrays have standard string representation and work with primitive mode out of a box, for hashes you need to define `toString` method, that will produce unique string descriptions, or rely on `JSON.stringify`.
Similarly __if you want to memoize functions by their code representation not by their objects, you should use primitive mode__.
#### Memoizing asynchronous functions
With _async_ option we indicate that we memoize asynchronous function.
Operations that result with an error are not cached.
```javascript
afn = function (a, b, cb) {
setTimeout(function () {
cb(null, a + b);
}, 200);
};
memoized = memoize(afn, { async: true });
memoized(3, 7, function (err, res) {
memoized(3, 7, function (err, res) {
// Cache hit
});
});
memoized(3, 7, function (err, res) {
// Cache hit
});
```
#### Memoizing methods
When we are defining a prototype, we may want to define a method that will memoize it's results in relation to each instance. A basic way to obtain that would be:
```javascript
var Foo = function () {
this.bar = memoize(this.bar.bind(this), { someOption: true });
// ... constructor logic
};
Foo.prototype.bar = function () {
// ... method logic
};
```
There's a lazy methods descriptor generator provided:
```javascript
var d = require('d');
var memoizeMethods = require('memoizee/methods');
var Foo = function () {
// ... constructor logic
};
Object.defineProperties(Foo.prototype, memoizeMethods({
bar: d(function () {
// ... method logic
}, { someOption: true })
}));
```
#### WeakMap based configurations
In this case memoization cache is not bound to memoized function (which we may want to keep forever), but to objects for which given results were generated.
This mode works only for functions of which first argument is expected to be an object.
It can be combined with other options mentioned across documentation. However due to WeakMap specificity global clear is not possible.
```javascript
var memoize = require('memoizee/weak');
var memoized = memoize(function (obj) { return Object.keys(obj); });
var obj = { foo: true, bar: false };
memoized(obj);
memoized(obj); // Cache hit
```
#### Cache handling
##### Manual clean up:
Delete data for particular call.
```javascript
memoized.delete('foo', true);
```
Arguments passed to `delete` are treated with same rules as input arguments passed to function
Clear all cached data:
```javascript
memoized.clear();
```
##### Expire cache after given period of time
With _maxAge_ option we can ensure that cache for given call is cleared after predefined period of time (in milliseconds)
```javascript
memoized = memoize(fn, { maxAge: 1000 }); // 1 second
memoized('foo', 3);
memoized('foo', 3); // Cache hit
setTimeout(function () {
memoized('foo', 3); // No longer in cache, re-executed
memoized('foo', 3); // Cache hit
}, 2000);
```
Additionally we may ask to _pre-fetch_ in a background a value that is about to expire. _Pre-fetch_ is invoked only if value is accessed close to its expiry date. By default it needs to be within at least 33% of _maxAge_ timespan before expire:
```javascript
memoized = memoize(fn, { maxAge: 1000, preFetch: true }); // Defaults to 0.33
memoized('foo', 3);
memoized('foo', 3); // Cache hit
setTimeout(function () {
memoized('foo', 3); // Cache hit
}, 500);
setTimeout(function () {
memoized('foo', 3); // Cache hit, silently pre-fetched in next tick
}, 800);
setTimeout(function () {
memoized('foo', 3); // Cache hit
}, 1300);
```
_Pre-fetch_ timespan can be customized:
```javascript
memoized = memoize(fn, { maxAge: 1000, preFetch: 0.6 });
memoized('foo', 3);
memoized('foo', 3); // Cache hit
setTimeout(function () {
memoized('foo', 3); // Cache hit, silently pre-fetched in next tick
}, 500);
setTimeout(function () {
memoized('foo', 3); // Cache hit
}, 1300);
```
_Thanks [@puzrin](https://github.com/puzrin) for helpful suggestions concerning this functionality_
##### Reference counter
We can track number of references returned from cache, and manually delete them. When the last reference is cleared, the cache is purged automatically:
```javascript
memoized = memoize(fn, { refCounter: true });
memoized('foo', 3); // refs: 1
memoized('foo', 3); // Cache hit, refs: 2
memoized('foo', 3); // Cache hit, refs: 3
memoized.deleteRef('foo', 3); // refs: 2
memoized.deleteRef('foo', 3); // refs: 1
memoized.deleteRef('foo', 3); // refs: 0, Cache purged for 'foo', 3
memoized('foo', 3); // Re-executed, refs: 1
```
##### Limiting cache size
With _max_ option you can limit cache size, it's backed with [LRU algorithm](http://en.wikipedia.org/wiki/Cache_algorithms#Least_Recently_Used), provided by low-level [lru-queue](https://github.com/medikoo/lru-queue) utility
```javascript
memoized = memoize(fn, { max: 2 });
memoized('foo', 3);
memoized('bar', 7);
memoized('foo', 3); // Cache hit
memoized('bar', 7); // Cache hit
memoized('lorem', 11); // Cache cleared for 'foo', 3
memoized('bar', 7); // Cache hit
memoized('foo', 3); // Re-executed, Cache cleared for 'lorem', 11
memoized('lorem', 11); // Re-executed, Cache cleared for 'bar', 7
memoized('foo', 3); // Cache hit
memoized('bar', 7); // Re-executed, Cache cleared for 'lorem', 11
```
##### Registering dispose callback
You can register a callback to be called on each value removed from the cache:
```javascript
memoized = memoize(fn, { dispose: function (value) { /*…*/ } });
var foo3 = memoized('foo', 3);
var bar7 = memoized('bar', 7);
memoized.clear('foo', 3); // Dispose called with foo3 value
memoized.clear('bar', 7); // Dispose called with bar7 value
```
### Benchmarks
Simple benchmark tests can be found in _benchmark_ folder. Currently it's just plain simple calculation of fibonacci sequences. To run it you need to install other test candidates:
$ npm install underscore lodash lru-cache secondary-cache
Example output taken under Node v0.10.35 on 2011 MBP Pro:
```
Fibonacci 3000 x10:
1: 15ms Memoizee (primitive mode)
2: 15ms Underscore
3: 18ms lru-cache LRU (max: 1000)
4: 21ms secondary-cache LRU (max: 1000)
5: 37ms Lo-dash
6: 62ms Memoizee (primitive mode) LRU (max: 1000)
7: 163ms Memoizee (object mode) LRU (max: 1000)
8: 195ms Memoizee (object mode)
```
### Profiling & Statistics
If you want to make sure how much you benefit from memoization or just check if memoization works as expected, loading profile module will give access to all valuable information.
__Module needs to be imported before any memoization (that we want to track) is configured. Mind also that running profile module affects performance, it's best not to use it in production environment__
```javascript
var memProfile = require('memoizee/profile');
```
Access statistics at any time:
```javascript
memProfile.statistics; // Statistcs accessible for programmatical use
console.log(memProfile.log()); // Output statistics data in readable form
```
Example console output:
```
------------------------------------------------------------
Memoize statistics:
Init Cache %Cache Source location
11604 35682 75.46 (all)
2112 19901 90.41 at /Users/medikoo/Projects/_packages/next/lib/fs/is-ignored.js:276:12
2108 9087 81.17 at /Users/medikoo/Projects/_packages/next/lib/fs/is-ignored.js:293:10
6687 2772 29.31 at /Users/medikoo/Projects/_packages/next/lib/fs/watch.js:125:9
697 3922 84.91 at /Users/medikoo/Projects/_packages/next/lib/fs/is-ignored.js:277:15
------------------------------------------------------------
```
* _Init_ Initial hits
* _Cache_ Cache hits
* _%Cache_ What's the percentage of cache hits (of all function calls)
* _Source location_ Where in the source code given memoization was initialized
### Tests [![Build Status](https://travis-ci.org/medikoo/memoize.svg)](https://travis-ci.org/medikoo/memoize)
$ npm test
### Contributors
* [@puzrin](https://github.com/puzrin) (Vitaly Puzrin)
* Proposal and help with coining right _pre-fetch_ logic for [_maxAge_](https://github.com/medikoo/memoize#expire-cache-after-given-period-of-time) variant

124
node_modules/memoizee/benchmark/fibonacci.js generated vendored Normal file
View File

@@ -0,0 +1,124 @@
'use strict';
// Simple benchmark for very simple memoization case (fibonacci series)
// To run it, do following in memoizee package path:
//
// $ npm install underscore lodash lru-cache secondary-cache
// $ node benchmark/fibonacci.js
var forEach = require('es5-ext/object/for-each')
, pad = require('es5-ext/string/#/pad')
, memoizee = require('..')
, underscore = require('underscore').memoize
, lodash = require('lodash').memoize
, lruCache = require('lru-cache')
, lruSecondary = require('secondary-cache/lib/lru-cache')
, now = Date.now
, time, getFib, lru, memo, total, index = 3000, count = 10, i, lruMax = 1000
, data = {}, lruObj;
getFib = function (memoize, opts) {
var fib = memoize(function (x) {
return (x < 2) ? 1 : fib(x - 1) + fib(x - 2);
}, opts);
return fib;
};
lru = function (x) {
var value = lruObj.get(x);
if (value === undefined) {
value = ((x < 2) ? 1 : lru(x - 1) + lru(x - 2));
lruObj.set(x, value);
}
return value;
};
console.log("Fibonacci", index, "x" + count + ":\n");
total = 0;
i = count;
while (i--) {
memo = getFib(memoizee);
time = now();
memo(index);
total += now() - time;
}
data["Memoizee (object mode)"] = total;
total = 0;
i = count;
while (i--) {
memo = getFib(memoizee, { primitive: true });
time = now();
memo(index);
total += now() - time;
}
data["Memoizee (primitive mode)"] = total;
total = 0;
i = count;
while (i--) {
memo = getFib(underscore);
time = now();
memo(index);
total += now() - time;
}
data["Underscore"] = total;
total = 0;
i = count;
while (i--) {
memo = getFib(lodash);
time = now();
memo(index);
total += now() - time;
}
data["Lo-dash"] = total;
total = 0;
i = count;
while (i--) {
memo = getFib(memoizee, { primitive: true, max: lruMax });
time = now();
memo(index);
total += now() - time;
}
data["Memoizee (primitive mode) LRU (max: 1000)"] = total;
total = 0;
i = count;
while (i--) {
memo = getFib(memoizee, { max: lruMax });
time = now();
memo(index);
total += now() - time;
}
data["Memoizee (object mode) LRU (max: 1000)"] = total;
total = 0;
i = count;
while (i--) {
lruObj = lruCache({ max: lruMax });
time = now();
lru(index);
total += now() - time;
}
data["lru-cache LRU (max: 1000)"] = total;
total = 0;
i = count;
while (i--) {
lruObj = lruSecondary(lruMax);
time = now();
lru(index);
total += now() - time;
}
data["secondary-cache LRU (max: 1000)"] = total;
forEach(data, function (value, name, obj, index) {
console.log(index + 1 + ":", pad.call(value, " ", 5) + "ms ", name);
}, null, function (a, b) {
return this[a] - this[b];
});

146
node_modules/memoizee/ext/async.js generated vendored Normal file
View File

@@ -0,0 +1,146 @@
// Support for asynchronous functions
'use strict';
var aFrom = require('es5-ext/array/from')
, mixin = require('es5-ext/object/mixin')
, defineLength = require('es5-ext/function/_define-length')
, nextTick = require('next-tick')
, slice = Array.prototype.slice
, apply = Function.prototype.apply, create = Object.create
, hasOwnProperty = Object.prototype.hasOwnProperty;
require('../lib/registered-extensions').async = function (tbi, conf) {
var waiting = create(null), cache = create(null)
, base = conf.memoized, original = conf.original
, currentCallback, currentContext, currentArgs;
// Initial
conf.memoized = defineLength(function (arg) {
var args = arguments, last = args[args.length - 1];
if (typeof last === 'function') {
currentCallback = last;
args = slice.call(args, 0, -1);
}
return base.apply(currentContext = this, currentArgs = args);
}, base);
try { mixin(conf.memoized, base); } catch (ignore) {}
// From cache (sync)
conf.on('get', function (id) {
var cb, context, args;
if (!currentCallback) return;
// Unresolved
if (waiting[id]) {
if (typeof waiting[id] === 'function') waiting[id] = [waiting[id], currentCallback];
else waiting[id].push(currentCallback);
currentCallback = null;
return;
}
// Resolved, assure next tick invocation
cb = currentCallback;
context = currentContext;
args = currentArgs;
currentCallback = currentContext = currentArgs = null;
nextTick(function () {
var data;
if (hasOwnProperty.call(cache, id)) {
data = cache[id];
conf.emit('getasync', id, args, context);
apply.call(cb, data.context, data.args);
} else {
// Purged in a meantime, we shouldn't rely on cached value, recall
currentCallback = cb;
currentContext = context;
currentArgs = args;
base.apply(context, args);
}
});
});
// Not from cache
conf.original = function () {
var args, cb, origCb, result;
if (!currentCallback) return apply.call(original, this, arguments);
args = aFrom(arguments);
cb = function self(err) {
var cb, args, id = self.id;
if (id == null) {
// Shouldn't happen, means async callback was called sync way
nextTick(apply.bind(self, this, arguments));
return;
}
delete self.id;
cb = waiting[id];
delete waiting[id];
if (!cb) {
// Already processed,
// outcome of race condition: asyncFn(1, cb), asyncFn.clear(), asyncFn(1, cb)
return;
}
args = aFrom(arguments);
if (conf.has(id)) {
if (err) {
conf.delete(id);
} else {
cache[id] = { context: this, args: args };
conf.emit('setasync', id, (typeof cb === 'function') ? 1 : cb.length);
}
}
if (typeof cb === 'function') {
result = apply.call(cb, this, args);
} else {
cb.forEach(function (cb) { result = apply.call(cb, this, args); }, this);
}
return result;
};
origCb = currentCallback;
currentCallback = currentContext = currentArgs = null;
args.push(cb);
result = apply.call(original, this, args);
cb.cb = origCb;
currentCallback = cb;
return result;
};
// After not from cache call
conf.on('set', function (id) {
if (!currentCallback) {
conf.delete(id);
return;
}
if (waiting[id]) {
// Race condition: asyncFn(1, cb), asyncFn.clear(), asyncFn(1, cb)
if (typeof waiting[id] === 'function') waiting[id] = [waiting[id], currentCallback.cb];
else waiting[id].push(currentCallback.cb);
} else {
waiting[id] = currentCallback.cb;
}
delete currentCallback.cb;
currentCallback.id = id;
currentCallback = null;
});
// On delete
conf.on('delete', function (id) {
var result;
// If false, we don't have value yet, so we assume that intention is not
// to memoize this call. After value is obtained we don't cache it but
// gracefully pass to callback
if (hasOwnProperty.call(waiting, id)) return;
if (!cache[id]) return;
result = cache[id];
delete cache[id];
conf.emit('deleteasync', id, result);
});
// On clear
conf.on('clear', function () {
var oldCache = cache;
cache = create(null);
conf.emit('clearasync', oldCache);
});
};

27
node_modules/memoizee/ext/dispose.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
// Call dispose callback on each cache purge
'use strict';
var callable = require('es5-ext/object/valid-callable')
, forEach = require('es5-ext/object/for-each')
, extensions = require('../lib/registered-extensions')
, slice = Array.prototype.slice, apply = Function.prototype.apply;
extensions.dispose = function (dispose, conf, options) {
var del;
callable(dispose);
if (options.async && extensions.async) {
conf.on('deleteasync', del = function (id, result) {
apply.call(dispose, null, slice.call(result.args, 1));
});
conf.on('clearasync', function (cache) {
forEach(cache, function (result, id) { del(id, result); });
});
return;
}
conf.on('delete', del = function (id, result) { dispose(result); });
conf.on('clear', function (cache) {
forEach(cache, function (result, id) { del(id, result); });
});
};

70
node_modules/memoizee/ext/max-age.js generated vendored Normal file
View File

@@ -0,0 +1,70 @@
// Timeout cached values
'use strict';
var aFrom = require('es5-ext/array/from')
, noop = require('es5-ext/function/noop')
, forEach = require('es5-ext/object/for-each')
, timeout = require('timers-ext/valid-timeout')
, extensions = require('../lib/registered-extensions')
, max = Math.max, min = Math.min, create = Object.create;
extensions.maxAge = function (maxAge, conf, options) {
var timeouts, postfix, preFetchAge, preFetchTimeouts;
maxAge = timeout(maxAge);
if (!maxAge) return;
timeouts = create(null);
postfix = (options.async && extensions.async) ? 'async' : '';
conf.on('set' + postfix, function (id) {
timeouts[id] = setTimeout(function () { conf.delete(id); }, maxAge);
if (!preFetchTimeouts) return;
if (preFetchTimeouts[id]) clearTimeout(preFetchTimeouts[id]);
preFetchTimeouts[id] = setTimeout(function () {
delete preFetchTimeouts[id];
}, preFetchAge);
});
conf.on('delete' + postfix, function (id) {
clearTimeout(timeouts[id]);
delete timeouts[id];
if (!preFetchTimeouts) return;
clearTimeout(preFetchTimeouts[id]);
delete preFetchTimeouts[id];
});
if (options.preFetch) {
if ((options.preFetch === true) || isNaN(options.preFetch)) {
preFetchAge = 0.333;
} else {
preFetchAge = max(min(Number(options.preFetch), 1), 0);
}
if (preFetchAge) {
preFetchTimeouts = {};
preFetchAge = (1 - preFetchAge) * maxAge;
conf.on('get' + postfix, function (id, args, context) {
if (!preFetchTimeouts[id]) {
preFetchTimeouts[id] = setTimeout(function () {
delete preFetchTimeouts[id];
conf.delete(id);
if (options.async) {
args = aFrom(args);
args.push(noop);
}
conf.memoized.apply(context, args);
}, 0);
}
});
}
}
conf.on('clear' + postfix, function () {
forEach(timeouts, function (id) { clearTimeout(id); });
timeouts = {};
if (preFetchTimeouts) {
forEach(preFetchTimeouts, function (id) { clearTimeout(id); });
preFetchTimeouts = {};
}
});
};

26
node_modules/memoizee/ext/max.js generated vendored Normal file
View File

@@ -0,0 +1,26 @@
// Limit cache size, LRU (least recently used) algorithm.
'use strict';
var toPosInteger = require('es5-ext/number/to-pos-integer')
, lruQueue = require('lru-queue')
, extensions = require('../lib/registered-extensions');
extensions.max = function (max, conf, options) {
var postfix, queue, hit;
max = toPosInteger(max);
if (!max) return;
queue = lruQueue(max);
postfix = (options.async && extensions.async) ? 'async' : '';
conf.on('set' + postfix, hit = function (id) {
id = queue.hit(id);
if (id === undefined) return;
conf.delete(id);
});
conf.on('get' + postfix, hit);
conf.on('delete' + postfix, queue.delete);
conf.on('clear' + postfix, queue.clear);
};

39
node_modules/memoizee/ext/ref-counter.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
// Reference counter, useful for garbage collector like functionality
'use strict';
var d = require('d')
, extensions = require('../lib/registered-extensions')
, create = Object.create, defineProperties = Object.defineProperties;
extensions.refCounter = function (ignore, conf, options) {
var cache, postfix;
cache = create(null);
postfix = (options.async && extensions.async) ? 'async' : '';
conf.on('set' + postfix, function (id, length) { cache[id] = length || 1; });
conf.on('get' + postfix, function (id) { ++cache[id]; });
conf.on('delete' + postfix, function (id) { delete cache[id]; });
conf.on('clear' + postfix, function () { cache = {}; });
defineProperties(conf.memoized, {
deleteRef: d(function () {
var id = conf.get(arguments);
if (id === null) return null;
if (!cache[id]) return null;
if (!--cache[id]) {
conf.delete(id);
return true;
}
return false;
}),
getRefCount: d(function () {
var id = conf.get(arguments);
if (id === null) return 0;
if (!cache[id]) return 0;
return cache[id];
})
});
};

35
node_modules/memoizee/index.js generated vendored Normal file
View File

@@ -0,0 +1,35 @@
'use strict';
var normalizeOpts = require('es5-ext/object/normalize-options')
, resolveLength = require('./lib/resolve-length')
, plain = require('./plain');
module.exports = function (fn/*, options*/) {
var options = normalizeOpts(arguments[1]), length;
if (!options.normalizer) {
length = options.length = resolveLength(options.length, fn.length, options.async);
if (length !== 0) {
if (options.primitive) {
if (length === false) {
options.normalizer = require('./normalizers/primitive');
} else if (length > 1) {
options.normalizer = require('./normalizers/get-primitive-fixed')(length);
}
} else {
if (length === false) options.normalizer = require('./normalizers/get')();
else if (length === 1) options.normalizer = require('./normalizers/get-1')();
else options.normalizer = require('./normalizers/get-fixed')(length);
}
}
}
// Assure extensions
if (options.async) require('./ext/async');
if (options.dispose) require('./ext/dispose');
if (options.maxAge) require('./ext/max-age');
if (options.max) require('./ext/max');
if (options.refCounter) require('./ext/ref-counter');
return plain(fn, options);
};

144
node_modules/memoizee/lib/configure-map.js generated vendored Normal file
View File

@@ -0,0 +1,144 @@
'use strict';
var customError = require('es5-ext/error/custom')
, defineLength = require('es5-ext/function/_define-length')
, d = require('d')
, ee = require('event-emitter').methods
, resolveResolve = require('./resolve-resolve')
, resolveNormalize = require('./resolve-normalize')
, apply = Function.prototype.apply, call = Function.prototype.call
, create = Object.create, hasOwnProperty = Object.prototype.hasOwnProperty
, defineProperties = Object.defineProperties
, on = ee.on, emit = ee.emit;
module.exports = function (original, length, options) {
var cache = create(null), conf, memLength, get, set, del, clear, extDel, normalizer
, getListeners, setListeners, deleteListeners, memoized, resolve;
if (length !== false) memLength = length;
else if (isNaN(original.length)) memLength = 1;
else memLength = original.length;
if (options.normalizer) {
normalizer = resolveNormalize(options.normalizer);
get = normalizer.get;
set = normalizer.set;
del = normalizer.delete;
clear = normalizer.clear;
}
if (options.resolvers != null) resolve = resolveResolve(options.resolvers);
if (get) {
memoized = defineLength(function (arg) {
var id, result, args = arguments;
if (resolve) args = resolve(args);
id = get(args);
if (id !== null) {
if (hasOwnProperty.call(cache, id)) {
if (getListeners) conf.emit('get', id, args, this);
return cache[id];
}
}
if (args.length === 1) result = call.call(original, this, arg);
else result = apply.call(original, this, args);
if (id === null) {
id = get(args);
if (id !== null) throw customError("Circular invocation", 'CIRCULAR_INVOCATION');
id = set(args);
} else if (hasOwnProperty.call(cache, id)) {
throw customError("Circular invocation", 'CIRCULAR_INVOCATION');
}
cache[id] = result;
if (setListeners) conf.emit('set', id);
return result;
}, memLength);
} else if (length === 0) {
memoized = function () {
var result;
if (hasOwnProperty.call(cache, 'data')) {
if (getListeners) conf.emit('get', 'data', arguments, this);
return cache.data;
}
if (!arguments.length) result = call.call(original, this);
else result = apply.call(original, this, arguments);
if (hasOwnProperty.call(cache, 'data')) {
throw customError("Circular invocation", 'CIRCULAR_INVOCATION');
}
cache.data = result;
if (setListeners) conf.emit('set', 'data');
return result;
};
} else {
memoized = function (arg) {
var result, args = arguments, id;
if (resolve) args = resolve(arguments);
id = String(args[0]);
if (hasOwnProperty.call(cache, id)) {
if (getListeners) conf.emit('get', id, args, this);
return cache[id];
}
if (args.length === 1) result = call.call(original, this, args[0]);
else result = apply.call(original, this, args);
if (hasOwnProperty.call(cache, id)) {
throw customError("Circular invocation", 'CIRCULAR_INVOCATION');
}
cache[id] = result;
if (setListeners) conf.emit('set', id);
return result;
};
}
conf = {
original: original,
memoized: memoized,
get: function (args) {
if (resolve) args = resolve(args);
if (get) return get(args);
return String(args[0]);
},
has: function (id) { return hasOwnProperty.call(cache, id); },
delete: function (id) {
var result;
if (!hasOwnProperty.call(cache, id)) return;
if (del) del(id);
result = cache[id];
delete cache[id];
if (deleteListeners) conf.emit('delete', id, result);
},
clear: function () {
var oldCache = cache;
if (clear) clear();
cache = create(null);
conf.emit('clear', oldCache);
},
on: function (type, listener) {
if (type === 'get') getListeners = true;
else if (type === 'set') setListeners = true;
else if (type === 'delete') deleteListeners = true;
return on.call(this, type, listener);
},
emit: emit,
updateEnv: function () { original = conf.original; }
};
if (get) {
extDel = defineLength(function (arg) {
var id, args = arguments;
if (resolve) args = resolve(args);
id = get(args);
if (id === null) return;
conf.delete(id);
}, memLength);
} else if (length === 0) {
extDel = function () { return conf.delete('data'); };
} else {
extDel = function (arg) {
if (resolve) arg = resolve(arguments)[0];
return conf.delete(arg);
};
}
defineProperties(memoized, {
__memoized__: d(true),
delete: d(extDel),
clear: d(conf.clear)
});
return conf;
};

28
node_modules/memoizee/lib/methods.js generated vendored Normal file
View File

@@ -0,0 +1,28 @@
'use strict';
var forEach = require('es5-ext/object/for-each')
, normalizeOpts = require('es5-ext/object/normalize-options')
, callable = require('es5-ext/object/valid-callable')
, lazy = require('d/lazy')
, resolveLength = require('./resolve-length')
, extensions = require('./registered-extensions');
module.exports = function (memoize) {
return function (props) {
forEach(props, function (desc, name) {
var fn = callable(desc.value), length;
desc.value = function (options) {
if (options.getNormalizer) {
options = normalizeOpts(options);
if (length === undefined) {
length = resolveLength(options.length, fn.length, options.async && extensions.async);
}
options.normalizer = options.getNormalizer(length);
delete options.getNormalizer;
}
return memoize(fn.bind(this), options);
};
});
return lazy(props);
};
};

1
node_modules/memoizee/lib/registered-extensions.js generated vendored Normal file
View File

@@ -0,0 +1 @@
'use strict';

15
node_modules/memoizee/lib/resolve-length.js generated vendored Normal file
View File

@@ -0,0 +1,15 @@
'use strict';
var toPosInt = require('es5-ext/number/to-pos-integer');
module.exports = function (optsLength, fnLength, isAsync) {
var length;
if (isNaN(optsLength)) {
length = fnLength;
if (!(length >= 0)) return 1;
if (isAsync && length) return length - 1;
return length;
}
if (optsLength === false) return false;
return toPosInt(optsLength);
};

17
node_modules/memoizee/lib/resolve-normalize.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
'use strict';
var callable = require('es5-ext/object/valid-callable');
module.exports = function (userNormalizer) {
var normalizer;
if (typeof userNormalizer === 'function') return { set: userNormalizer, get: userNormalizer };
normalizer = { get: callable(userNormalizer.get) };
if (userNormalizer.set !== undefined) {
normalizer.set = callable(userNormalizer.set);
normalizer.delete = callable(userNormalizer.delete);
normalizer.clear = callable(userNormalizer.clear);
return normalizer;
}
normalizer.set = normalizer.get;
return normalizer;
};

21
node_modules/memoizee/lib/resolve-resolve.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
'use strict';
var toArray = require('es5-ext/array/to-array')
, callable = require('es5-ext/object/valid-callable')
, slice = Array.prototype.slice
, resolveArgs;
resolveArgs = function (args) {
return this.map(function (r, i) {
return r ? r(args[i]) : args[i];
}).concat(slice.call(args, this.length));
};
module.exports = function (resolvers) {
resolvers = toArray(resolvers);
resolvers.forEach(function (r) {
if (r != null) callable(r);
});
return resolveArgs.bind(resolvers);
};

112
node_modules/memoizee/lib/weak.js generated vendored Normal file
View File

@@ -0,0 +1,112 @@
'use strict';
var customError = require('es5-ext/error/custom')
, defineLength = require('es5-ext/function/_define-length')
, partial = require('es5-ext/function/#/partial')
, copy = require('es5-ext/object/copy')
, normalizeOpts = require('es5-ext/object/normalize-options')
, callable = require('es5-ext/object/valid-callable')
, d = require('d')
, WeakMap = require('es6-weak-map')
, resolveLength = require('./resolve-length')
, extensions = require('./registered-extensions')
, resolveResolve = require('./resolve-resolve')
, resolveNormalize = require('./resolve-normalize')
, slice = Array.prototype.slice, defineProperties = Object.defineProperties
, hasOwnProperty = Object.prototype.hasOwnProperty;
module.exports = function (memoize) {
return function (fn/*, options*/) {
var map, length, options = normalizeOpts(arguments[1]), memoized, resolve, normalizer;
callable(fn);
// Do not memoize already memoized function
if (hasOwnProperty.call(fn, '__memoized__') && !options.force) return fn;
length = resolveLength(options.length, fn.length, options.async && extensions.async);
options.length = length ? length - 1 : 0;
map = new WeakMap();
if (options.resolvers) resolve = resolveResolve(options.resolvers);
if (options.normalizer) normalizer = resolveNormalize(options.normalizer);
if ((length === 1) && !normalizer && !(options.async && extensions.async) &&
!(options.dispose && extensions.dispose) && !(options.maxAge && extensions.maxAge) &&
!(options.max && extensions.max) && !(options.refCounter && extensions.refCounter)) {
return defineProperties(function (obj) {
var result;
if (resolve) obj = resolve(arguments)[0];
if (map.has(obj)) return map.get(obj);
result = fn.call(this, obj);
if (map.has(obj)) throw customError("Circular invocation", 'CIRCULAR_INVOCATION');
map.set(obj, result);
return result;
}, {
__memoized__: d(true),
delete: d(function (obj) {
if (resolve) obj = resolve(arguments)[0];
return map.delete(obj);
})
});
}
memoized = defineProperties(defineLength(function (obj) {
var memoizer, args = arguments;
if (resolve) {
args = resolve(args);
obj = args[0];
}
memoizer = map.get(obj);
if (!memoizer) {
if (normalizer) {
options = copy(options);
options.normalizer = copy(normalizer);
options.normalizer.get = partial.call(options.normalizer.get, obj);
options.normalizer.set = partial.call(options.normalizer.set, obj);
if (options.normalizer.delete) {
options.normalizer.delete = partial.call(options.normalizer.delete, obj);
}
}
map.set(obj, memoizer = memoize(partial.call(fn, obj), options));
}
return memoizer.apply(this, slice.call(args, 1));
}, length), {
__memoized__: d(true),
delete: d(defineLength(function (obj) {
var memoizer, args = arguments;
if (resolve) {
args = resolve(args);
obj = args[0];
}
memoizer = map.get(obj);
if (!memoizer) return;
memoizer.delete.apply(this, slice.call(args, 1));
}, length))
});
if (!options.refCounter || !extensions.refCounter) return memoized;
defineProperties(memoized, {
deleteRef: d(defineLength(function (obj) {
var memoizer, args = arguments;
if (resolve) {
args = resolve(args);
obj = args[0];
}
memoizer = map.get(obj);
if (!memoizer) return null;
return memoizer.deleteRef.apply(this, slice.call(args, 1));
}, length)),
getRefCount: d(defineLength(function (obj) {
var memoizer, args = arguments;
if (resolve) {
args = resolve(args);
obj = args[0];
}
memoizer = map.get(obj);
if (!memoizer) return 0;
return memoizer.getRefCount.apply(this, slice.call(args, 1));
}, length))
});
return memoized;
};
};

3
node_modules/memoizee/methods-plain.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
'use strict';
module.exports = require('./lib/methods')(require('./plain'));

3
node_modules/memoizee/methods.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
'use strict';
module.exports = require('./lib/methods')(require('./'));

29
node_modules/memoizee/normalizers/get-1.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
'use strict';
var indexOf = require('es5-ext/array/#/e-index-of');
module.exports = function () {
var lastId = 0, argsMap = [], cache = [];
return {
get: function (args) {
var index = indexOf.call(argsMap, args[0]);
return (index === -1) ? null : cache[index];
},
set: function (args) {
argsMap.push(args[0]);
cache.push(++lastId);
return lastId;
},
delete: function (id) {
var index = indexOf.call(cache, id);
if (index !== -1) {
argsMap.splice(index, 1);
cache.splice(index, 1);
}
},
clear: function () {
argsMap = [];
cache = [];
}
};
};

71
node_modules/memoizee/normalizers/get-fixed.js generated vendored Normal file
View File

@@ -0,0 +1,71 @@
'use strict';
var indexOf = require('es5-ext/array/#/e-index-of')
, create = Object.create;
module.exports = function (length) {
var lastId = 0, map = [[], []], cache = create(null);
return {
get: function (args) {
var index = 0, set = map, i;
while (index < (length - 1)) {
i = indexOf.call(set[0], args[index]);
if (i === -1) return null;
set = set[1][i];
++index;
}
i = indexOf.call(set[0], args[index]);
if (i === -1) return null;
return set[1][i] || null;
},
set: function (args) {
var index = 0, set = map, i;
while (index < (length - 1)) {
i = indexOf.call(set[0], args[index]);
if (i === -1) {
i = set[0].push(args[index]) - 1;
set[1].push([[], []]);
}
set = set[1][i];
++index;
}
i = indexOf.call(set[0], args[index]);
if (i === -1) {
i = set[0].push(args[index]) - 1;
}
set[1][i] = ++lastId;
cache[lastId] = args;
return lastId;
},
delete: function (id) {
var index = 0, set = map, i, path = [], args = cache[id];
while (index < (length - 1)) {
i = indexOf.call(set[0], args[index]);
if (i === -1) {
return;
}
path.push(set, i);
set = set[1][i];
++index;
}
i = indexOf.call(set[0], args[index]);
if (i === -1) {
return;
}
id = set[1][i];
set[0].splice(i, 1);
set[1].splice(i, 1);
while (!set[0].length && path.length) {
i = path.pop();
set = path.pop();
set[0].splice(i, 1);
set[1].splice(i, 1);
}
delete cache[id];
},
clear: function () {
map = [[], []];
cache = create(null);
}
};
};

View File

@@ -0,0 +1,12 @@
'use strict';
module.exports = function (length) {
if (!length) {
return function () { return ''; };
}
return function (args) {
var id = String(args[0]), i = 0, l = length;
while (--l) { id += '\u0001' + args[++i]; }
return id;
};
};

88
node_modules/memoizee/normalizers/get.js generated vendored Normal file
View File

@@ -0,0 +1,88 @@
'use strict';
var indexOf = require('es5-ext/array/#/e-index-of')
, create = Object.create;
module.exports = function () {
var lastId = 0, map = [], cache = create(null);
return {
get: function (args) {
var index = 0, set = map, i, length = args.length;
if (length === 0) return set[length] || null;
if ((set = set[length])) {
while (index < (length - 1)) {
i = indexOf.call(set[0], args[index]);
if (i === -1) return null;
set = set[1][i];
++index;
}
i = indexOf.call(set[0], args[index]);
if (i === -1) return null;
return set[1][i] || null;
}
return null;
},
set: function (args) {
var index = 0, set = map, i, length = args.length;
if (length === 0) {
set[length] = ++lastId;
} else {
if (!set[length]) {
set[length] = [[], []];
}
set = set[length];
while (index < (length - 1)) {
i = indexOf.call(set[0], args[index]);
if (i === -1) {
i = set[0].push(args[index]) - 1;
set[1].push([[], []]);
}
set = set[1][i];
++index;
}
i = indexOf.call(set[0], args[index]);
if (i === -1) {
i = set[0].push(args[index]) - 1;
}
set[1][i] = ++lastId;
}
cache[lastId] = args;
return lastId;
},
delete: function (id) {
var index = 0, set = map, i, args = cache[id], length = args.length
, path = [];
if (length === 0) {
delete set[length];
} else if ((set = set[length])) {
while (index < (length - 1)) {
i = indexOf.call(set[0], args[index]);
if (i === -1) {
return;
}
path.push(set, i);
set = set[1][i];
++index;
}
i = indexOf.call(set[0], args[index]);
if (i === -1) {
return;
}
id = set[1][i];
set[0].splice(i, 1);
set[1].splice(i, 1);
while (!set[0].length && path.length) {
i = path.pop();
set = path.pop();
set[0].splice(i, 1);
set[1].splice(i, 1);
}
}
delete cache[id];
},
clear: function () {
map = [];
cache = create(null);
}
};
};

9
node_modules/memoizee/normalizers/primitive.js generated vendored Normal file
View File

@@ -0,0 +1,9 @@
'use strict';
module.exports = function (args) {
var id, i, length = args.length;
if (!length) return '\u0002';
id = String(args[i = 0]);
while (--length) id += '\u0001' + args[++i];
return id;
};

103
node_modules/memoizee/package.json generated vendored Normal file
View File

@@ -0,0 +1,103 @@
{
"_args": [
[
"memoizee@^0.3.9",
"/home/mitchell/Desktop/test-mywebsite/mywebsite/node_modules/cli-color"
]
],
"_from": "memoizee@>=0.3.9 <0.4.0",
"_id": "memoizee@0.3.9",
"_inCache": true,
"_installable": true,
"_location": "/memoizee",
"_nodeVersion": "0.12.7",
"_npmUser": {
"email": "medikoo+npm@medikoo.com",
"name": "medikoo"
},
"_npmVersion": "2.11.3",
"_phantomChildren": {},
"_requested": {
"name": "memoizee",
"raw": "memoizee@^0.3.9",
"rawSpec": "^0.3.9",
"scope": null,
"spec": ">=0.3.9 <0.4.0",
"type": "range"
},
"_requiredBy": [
"/cli-color"
],
"_resolved": "https://registry.npmjs.org/memoizee/-/memoizee-0.3.9.tgz",
"_shasum": "fc2b2f33ea39a07637eef76f40e3fc8b7072406c",
"_shrinkwrap": null,
"_spec": "memoizee@^0.3.9",
"_where": "/home/mitchell/Desktop/test-mywebsite/mywebsite/node_modules/cli-color",
"author": {
"email": "medikoo@medikoo.com",
"name": "Mariusz Nowak",
"url": "http://www.medikoo.com/"
},
"bugs": {
"url": "https://github.com/medikoo/memoize/issues"
},
"dependencies": {
"d": "~0.1.1",
"es5-ext": "~0.10.7",
"es6-weak-map": "~0.1.4",
"event-emitter": "~0.3.3",
"lru-queue": "0.1",
"next-tick": "~0.2.2",
"timers-ext": "0.1"
},
"description": "Memoize/cache function results",
"devDependencies": {
"tad": "~0.2.3",
"xlint": "~0.2.2",
"xlint-jslint-medikoo": "~0.1.4"
},
"directories": {},
"dist": {
"shasum": "fc2b2f33ea39a07637eef76f40e3fc8b7072406c",
"tarball": "http://registry.npmjs.org/memoizee/-/memoizee-0.3.9.tgz"
},
"gitHead": "4e310f91bb9a7539f697dcbb7c8bd85edfec83bc",
"homepage": "https://github.com/medikoo/memoize#readme",
"keywords": [
"async",
"cache",
"caching",
"collector",
"garbage",
"gc",
"hashing.",
"memcached",
"memo",
"memoization",
"memoize",
"memoizer",
"memory",
"storage",
"weak"
],
"license": "MIT",
"maintainers": [
{
"name": "medikoo",
"email": "medikoo+npm@medikoo.com"
}
],
"name": "memoizee",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git://github.com/medikoo/memoize.git"
},
"scripts": {
"lint": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --no-cache --no-stream",
"lint-console": "node node_modules/xlint/bin/xlint --linter=node_modules/xlint-jslint-medikoo/index.js --watch",
"test": "node node_modules/tad/bin/tad"
},
"version": "0.3.9"
}

35
node_modules/memoizee/plain.js generated vendored Normal file
View File

@@ -0,0 +1,35 @@
'use strict';
var callable = require('es5-ext/object/valid-callable')
, forEach = require('es5-ext/object/for-each')
, extensions = require('./lib/registered-extensions')
, configure = require('./lib/configure-map')
, resolveLength = require('./lib/resolve-length')
, hasOwnProperty = Object.prototype.hasOwnProperty;
module.exports = function self(fn/*, options */) {
var options, length, conf;
callable(fn);
options = Object(arguments[1]);
// Do not memoize already memoized function
if (hasOwnProperty.call(fn, '__memoized__') && !options.force) return fn;
// Resolve length;
length = resolveLength(options.length, fn.length, options.async && extensions.async);
// Configure cache map
conf = configure(fn, length, options);
// Bind eventual extensions
forEach(extensions, function (fn, name) {
if (options[name]) fn(options[name], conf, options);
});
if (self.__profiler__) self.__profiler__(conf);
conf.updateEnv();
return conf.memoized;
};

78
node_modules/memoizee/profile.js generated vendored Normal file
View File

@@ -0,0 +1,78 @@
// Gathers statistical data, and provides them in convinient form
'use strict';
var partial = require('es5-ext/function/#/partial')
, forEach = require('es5-ext/object/for-each')
, pad = require('es5-ext/string/#/pad')
, d = require('d')
, memoize = require('./plain')
, max = Math.max
, stats = exports.statistics = {};
Object.defineProperty(memoize, '__profiler__', d(function (conf) {
var id, stack, data;
stack = (new Error()).stack;
if (!stack || !stack.split('\n').slice(3).some(function (line) {
if ((line.indexOf('/memoizee/') === -1) &&
(line.indexOf(' (native)') === -1)) {
id = line.replace(/\n/g, "\\n").trim();
return true;
}
})) {
id = 'unknown';
}
if (!stats[id]) stats[id] = { initial: 0, cached: 0 };
data = stats[id];
conf.on('set', function () { ++data.initial; });
conf.on('get', function () { ++data.cached; });
}));
exports.log = function () {
var initial, cached, ordered, ipad, cpad, ppad, toPrc, log;
initial = cached = 0;
ordered = [];
toPrc = function (initial, cached) {
if (!initial && !cached) {
return '0.00';
}
return ((cached / (initial + cached)) * 100).toFixed(2);
};
log = "------------------------------------------------------------\n";
log += "Memoize statistics:\n\n";
forEach(stats, function (data, name) {
initial += data.initial;
cached += data.cached;
ordered.push([name, data]);
}, null, function (a, b) {
return (this[b].initial + this[b].cached) -
(this[a].initial + this[a].cached);
});
ipad = partial.call(pad, " ",
max(String(initial).length, "Init".length));
cpad = partial.call(pad, " ", max(String(cached).length, "Cache".length));
ppad = partial.call(pad, " ", "%Cache".length);
log += ipad.call("Init") + " " +
cpad.call("Cache") + " " +
ppad.call("%Cache") + " Source location\n";
log += ipad.call(initial) + " " +
cpad.call(cached) + " " +
ppad.call(toPrc(initial, cached)) + " (all)\n";
ordered.forEach(function (data) {
var name = data[0];
data = data[1];
log += ipad.call(data.initial) + " " +
cpad.call(data.cached) + " " +
ppad.call(toPrc(data.initial, data.cached)) + " " + name + "\n";
});
log += "------------------------------------------------------------\n";
return log;
};

277
node_modules/memoizee/test/ext/async.js generated vendored Normal file
View File

@@ -0,0 +1,277 @@
'use strict';
var memoize = require('../..')
, nextTick = require('next-tick');
module.exports = function () {
return {
Regular: {
Success: function (a, d) {
var mfn, fn, u = {}, i = 0, invoked = 0;
fn = function (x, y, cb) {
nextTick(function () {
++i;
cb(null, x + y);
});
return u;
};
mfn = memoize(fn, { async: true });
a(mfn(3, 7, function (err, res) {
++invoked;
a.deep([err, res], [null, 10], "Result #1");
}), u, "Initial");
a(mfn(3, 7, function (err, res) {
++invoked;
a.deep([err, res], [null, 10], "Result #2");
}), u, "Initial #2");
a(mfn(5, 8, function (err, res) {
++invoked;
a.deep([err, res], [null, 13], "Result B #1");
}), u, "Initial #2");
a(mfn(3, 7, function (err, res) {
++invoked;
a.deep([err, res], [null, 10], "Result #3");
}), u, "Initial #2");
a(mfn(5, 8, function (err, res) {
++invoked;
a.deep([err, res], [null, 13], "Result B #2");
}), u, "Initial #3");
nextTick(function () {
a(i, 2, "Init Called");
a(invoked, 5, "Cb Called");
a(mfn(3, 7, function (err, res) {
++invoked;
a.deep([err, res], [null, 10], "Again: Result");
}), u, "Again: Initial");
a(mfn(5, 8, function (err, res) {
++invoked;
a.deep([err, res], [null, 13], "Again B: Result");
}), u, "Again B: Initial");
nextTick(function () {
a(i, 2, "Init Called #2");
a(invoked, 7, "Cb Called #2");
mfn.delete(3, 7);
a(mfn(3, 7, function (err, res) {
++invoked;
a.deep([err, res], [null, 10], "Again: Result");
}), u, "Again: Initial");
a(mfn(5, 8, function (err, res) {
++invoked;
a.deep([err, res], [null, 13], "Again B: Result");
}), u, "Again B: Initial");
nextTick(function () {
a(i, 3, "Init After delete");
a(invoked, 9, "Cb After delete");
d();
});
});
});
},
Error: function (a, d) {
var mfn, fn, u = {}, i = 0, e = new Error("Test");
fn = function (x, y, cb) {
nextTick(function () {
++i;
cb(e);
});
return u;
};
mfn = memoize(fn, { async: true, dispose: a.never });
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [e, undefined], "Result #1");
}), u, "Initial");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [e, undefined], "Result #2");
}), u, "Initial #2");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [e, undefined], "Result B #1");
}), u, "Initial #2");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [e, undefined], "Result #3");
}), u, "Initial #2");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [e, undefined], "Result B #2");
}), u, "Initial #3");
nextTick(function () {
a(i, 2, "Called #2");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [e, undefined], "Again: Result");
}), u, "Again: Initial");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [e, undefined], "Again B: Result");
}), u, "Again B: Initial");
nextTick(function () {
a(i, 4, "Again Called #2");
d();
});
});
}
},
Primitive: {
Success: function (a, d) {
var mfn, fn, u = {}, i = 0;
fn = function (x, y, cb) {
nextTick(function () {
++i;
cb(null, x + y);
});
return u;
};
mfn = memoize(fn, { async: true, primitive: true });
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Result #1");
}), u, "Initial");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Result #2");
}), u, "Initial #2");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13], "Result B #1");
}), u, "Initial #2");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Result #3");
}), u, "Initial #2");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13], "Result B #2");
}), u, "Initial #3");
nextTick(function () {
a(i, 2, "Called #2");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Again: Result");
}), u, "Again: Initial");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13], "Again B: Result");
}), u, "Again B: Initial");
nextTick(function () {
a(i, 2, "Again Called #2");
mfn.delete(3, 7);
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Again: Result");
}), u, "Again: Initial");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13], "Again B: Result");
}), u, "Again B: Initial");
nextTick(function () {
a(i, 3, "Call After delete");
d();
});
});
});
},
Error: function (a, d) {
var mfn, fn, u = {}, i = 0, e = new Error("Test");
fn = function (x, y, cb) {
nextTick(function () {
++i;
cb(e);
});
return u;
};
mfn = memoize(fn, { async: true, primitive: true });
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [e, undefined], "Result #1");
}), u, "Initial");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [e, undefined], "Result #2");
}), u, "Initial #2");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [e, undefined], "Result B #1");
}), u, "Initial #2");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [e, undefined], "Result #3");
}), u, "Initial #2");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [e, undefined], "Result B #2");
}), u, "Initial #3");
nextTick(function () {
a(i, 2, "Called #2");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [e, undefined], "Again: Result");
}), u, "Again: Initial");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [e, undefined], "Again B: Result");
}), u, "Again B: Initial");
nextTick(function () {
a(i, 4, "Again Called #2");
d();
});
});
},
"Primitive null arg case": function (a, d) {
var x = {}, mfn = memoize(function f(id, cb) { cb(null, x); }, {
async: true,
primitive: true
});
mfn(null, function (err, res) {
a.deep([err, res], [null, x], "Args");
d();
});
}
},
"Sync Clear": function (a, d) {
var mfn, fn;
fn = function (x, cb) {
nextTick(function () {
cb(null, x);
});
};
mfn = memoize(fn, { async: true });
mfn(1, function (err, i) {
a(i, 1, "First");
});
mfn.clear();
mfn(2, function (err, i) {
a(i, 2, "Second");
d();
});
},
"Sync Clear: Primitive": function (a, d) {
var mfn, fn;
fn = function (x, cb) {
nextTick(function () {
cb(null, x);
});
};
mfn = memoize(fn, { async: true, primitive: true });
mfn(2, function (err, i) {
a(i, 2, "First");
});
mfn(1, function (err, i) {
a(i, 1, "Second");
nextTick(d);
});
mfn.clear();
mfn(2, function (err, i) {
a(i, 2, "Third");
});
}
};
};

173
node_modules/memoizee/test/ext/dispose.js generated vendored Normal file
View File

@@ -0,0 +1,173 @@
'use strict';
var memoize = require('../..')
, nextTick = require('next-tick');
module.exports = function () {
return {
Regular: {
Sync: function (a) {
var mfn, fn, value = [], x, invoked;
fn = function (x, y) { return x + y; };
mfn = memoize(fn, { dispose: function (val) { value.push(val); } });
mfn(3, 7);
mfn(5, 8);
mfn(12, 4);
a.deep(value, [], "Pre");
mfn.delete(5, 8);
a.deep(value, [13], "#1");
value = [];
mfn.delete(12, 4);
a.deep(value, [16], "#2");
value = [];
mfn(77, 11);
mfn.clear();
a.deep(value, [10, 88], "Clear all");
x = {};
invoked = false;
mfn = memoize(function () { return x; },
{ dispose: function (val) { invoked = val; } });
mfn.delete();
a(invoked, false, "No args: Post invalid delete");
mfn();
a(invoked, false, "No args: Post cache");
mfn.delete();
a(invoked, x, "No args: Pre delete");
},
"Ref counter": function (a) {
var mfn, fn, value = [];
fn = function (x, y) { return x + y; };
mfn = memoize(fn, { refCounter: true,
dispose: function (val) { value.push(val); } });
mfn(3, 7);
mfn(5, 8);
mfn(12, 4);
a.deep(value, [], "Pre");
mfn(5, 8);
mfn.deleteRef(5, 8);
a.deep(value, [], "Pre");
mfn.deleteRef(5, 8);
a.deep(value, [13], "#1");
value = [];
mfn.deleteRef(12, 4);
a.deep(value, [16], "#2");
value = [];
mfn(77, 11);
mfn.clear();
a.deep(value, [10, 88], "Clear all");
},
Async: function (a, d) {
var mfn, fn, u = {}, value = [];
fn = function (x, y, cb) {
nextTick(function () { cb(null, x + y); });
return u;
};
mfn = memoize(fn, { async: true,
dispose: function (val) { value.push(val); } });
mfn(3, 7, function () {
mfn(5, 8, function () {
mfn(12, 4, function () {
a.deep(value, [], "Pre");
mfn.delete(5, 8);
a.deep(value, [13], "#1");
value = [];
mfn.delete(12, 4);
a.deep(value, [16], "#2");
value = [];
mfn(77, 11, function () {
mfn.clear();
a.deep(value, [10, 88], "Clear all");
d();
});
});
});
});
}
},
Primitive: {
Sync: function (a) {
var mfn, fn, value = [];
fn = function (x, y) { return x + y; };
mfn = memoize(fn, { dispose: function (val) { value.push(val); } });
mfn(3, 7);
mfn(5, 8);
mfn(12, 4);
a.deep(value, [], "Pre");
mfn.delete(5, 8);
a.deep(value, [13], "#1");
value = [];
mfn.delete(12, 4);
a.deep(value, [16], "#2");
value = [];
mfn(77, 11);
mfn.clear();
a.deep(value, [10, 88], "Clear all");
},
"Ref counter": function (a) {
var mfn, fn, value = [];
fn = function (x, y) { return x + y; };
mfn = memoize(fn, { refCounter: true,
dispose: function (val) { value.push(val); } });
mfn(3, 7);
mfn(5, 8);
mfn(12, 4);
a.deep(value, [], "Pre");
mfn(5, 8);
mfn.deleteRef(5, 8);
a.deep(value, [], "Pre");
mfn.deleteRef(5, 8);
a.deep(value, [13], "#1");
value = [];
mfn.deleteRef(12, 4);
a.deep(value, [16], "#2");
value = [];
mfn(77, 11);
mfn.clear();
a.deep(value, [10, 88], "Clear all");
},
Async: function (a, d) {
var mfn, fn, u = {}, value = [];
fn = function (x, y, cb) {
nextTick(function () { cb(null, x + y); });
return u;
};
mfn = memoize(fn, { async: true,
dispose: function (val) { value.push(val); } });
mfn(3, 7, function () {
mfn(5, 8, function () {
mfn(12, 4, function () {
a.deep(value, [], "Pre");
mfn.delete(5, 8);
a.deep(value, [13], "#1");
value = [];
mfn.delete(12, 4);
a.deep(value, [16], "#2");
value = [];
mfn(77, 11, function () {
mfn.clear();
a.deep(value, [10, 88], "Clear all");
d();
});
});
});
});
}
}
};
};

418
node_modules/memoizee/test/ext/max-age.js generated vendored Normal file
View File

@@ -0,0 +1,418 @@
'use strict';
var memoize = require('../..')
, nextTick = require('next-tick');
require('../../ext/async');
module.exports = function () {
return {
Regular: {
Sync: function (a, d) {
var mfn, fn, i = 0;
fn = function (x, y) {
++i;
return x + y;
};
mfn = memoize(fn, { maxAge: 100 });
a(mfn(3, 7), 10, "Result #1");
a(i, 1, "Called #1");
a(mfn(3, 7), 10, "Result #2");
a(i, 1, "Called #2");
a(mfn(5, 8), 13, "Result B #1");
a(i, 2, "Called B #1");
a(mfn(3, 7), 10, "Result #3");
a(i, 2, "Called #3");
a(mfn(5, 8), 13, "Result B #2");
a(i, 2, "Called B #2");
setTimeout(function () {
a(mfn(3, 7), 10, "Result: Wait");
a(i, 2, "Called: Wait");
a(mfn(5, 8), 13, "Result: Wait B");
a(i, 2, "Called: Wait B");
a(mfn(9, 1), 10, "Result: C");
a(i, 3, "Called: C");
setTimeout(function () {
a(mfn(3, 7), 10, "Result: Wait After");
a(i, 4, "Called: Wait After");
a(mfn(5, 8), 13, "Result: Wait After B");
a(i, 5, "Called: Wait After B");
a(mfn(3, 7), 10, "Result: Wait After #2");
a(i, 5, "Called: Wait After #2");
a(mfn(5, 8), 13, "Result: Wait After B #2");
a(i, 5, "Called: Wait After B #2");
a(mfn(9, 1), 10, "Result: WiatC");
a(i, 5, "Called: Wait C");
d();
}, 90);
}, 20);
},
Async: function (a, d) {
var mfn, fn, u = {}, i = 0;
fn = function (x, y, cb) {
nextTick(function () {
++i;
cb(null, x + y);
});
return u;
};
mfn = memoize(fn, { async: true, maxAge: 100 });
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Result #1");
}), u, "Initial");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Result #2");
}), u, "Initial #2");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13], "Result B #1");
}), u, "Initial #2");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Result #3");
}), u, "Initial #2");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13], "Result B #2");
}), u, "Initial #3");
setTimeout(function () {
a(i, 2, "Called #2");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Again: Result");
}), u, "Again: Initial");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13], "Again B: Result");
}), u, "Again B: Initial");
setTimeout(function () {
a(i, 2, "Again Called #2");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Again: Result");
}), u, "Again: Initial");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13], "Again B: Result");
}), u, "Again B: Initial");
nextTick(function () {
a(i, 4, "Call After clear");
d();
});
}, 100);
}, 20);
}
},
Primitive: {
Sync: function (a, d) {
var mfn, fn, i = 0;
fn = function (x, y) {
++i;
return x + y;
};
mfn = memoize(fn, { primitive: true, maxAge: 100 });
a(mfn(3, 7), 10, "Result #1");
a(i, 1, "Called #1");
a(mfn(3, 7), 10, "Result #2");
a(i, 1, "Called #2");
a(mfn(5, 8), 13, "Result B #1");
a(i, 2, "Called B #1");
a(mfn(3, 7), 10, "Result #3");
a(i, 2, "Called #3");
a(mfn(5, 8), 13, "Result B #2");
a(i, 2, "Called B #2");
setTimeout(function () {
a(mfn(3, 7), 10, "Result: Wait");
a(i, 2, "Called: Wait");
a(mfn(5, 8), 13, "Result: Wait B");
a(i, 2, "Called: Wait B");
setTimeout(function () {
a(mfn(3, 7), 10, "Result: Wait After");
a(i, 3, "Called: Wait After");
a(mfn(5, 8), 13, "Result: Wait After B");
a(i, 4, "Called: Wait After B");
a(mfn(3, 7), 10, "Result: Wait After #2");
a(i, 4, "Called: Wait After #2");
a(mfn(5, 8), 13, "Result: Wait After B #2");
a(i, 4, "Called: Wait After B #2");
d();
}, 100);
}, 20);
},
Async: function (a, d) {
var mfn, fn, u = {}, i = 0;
fn = function (x, y, cb) {
nextTick(function () {
++i;
cb(null, x + y);
});
return u;
};
mfn = memoize(fn, { async: true, primitive: true, maxAge: 100 });
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Result #1");
}), u, "Initial");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Result #2");
}), u, "Initial #2");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13], "Result B #1");
}), u, "Initial #2");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Result #3");
}), u, "Initial #2");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13], "Result B #2");
}), u, "Initial #3");
setTimeout(function () {
a(i, 2, "Called #2");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Again: Result");
}), u, "Again: Initial");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13], "Again B: Result");
}), u, "Again B: Initial");
setTimeout(function () {
a(i, 2, "Again Called #2");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Again: Result");
}), u, "Again: Initial");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13], "Again B: Result");
}), u, "Again B: Initial");
nextTick(function () {
a(i, 4, "Call After clear");
d();
});
}, 100);
}, 20);
}
},
Refetch: {
Default: function (a, d) {
var mfn, fn, i = 0;
fn = function (x, y) {
++i;
return x + y;
};
mfn = memoize(fn, { maxAge: 600, preFetch: true });
a(mfn(3, 7), 10, "Result #1");
a(i, 1, "Called #1");
a(mfn(3, 7), 10, "Result #2");
a(i, 1, "Called #2");
a(mfn(5, 8), 13, "Result B #1");
a(i, 2, "Called B #1");
a(mfn(3, 7), 10, "Result #3");
a(i, 2, "Called #3");
a(mfn(5, 8), 13, "Result B #2");
a(i, 2, "Called B #2");
setTimeout(function () {
a(mfn(3, 7), 10, "Result: Wait");
a(i, 2, "Called: Wait");
a(mfn(5, 8), 13, "Result: Wait B");
a(i, 2, "Called: Wait B");
setTimeout(function () {
a(mfn(3, 7), 10, "Result: Wait After");
a(i, 2, "Called: Wait After");
a(mfn(5, 8), 13, "Result: Wait After B");
a(i, 2, "Called: Wait After B");
a(mfn(3, 7), 10, "Result: Wait After #2");
a(i, 2, "Called: Wait After #2");
a(mfn(5, 8), 13, "Result: Wait After B #2");
a(i, 2, "Called: Wait After B #2");
setTimeout(function () {
a(i, 4, "Called: After Refetch: Before");
a(mfn(3, 7), 10, "Result: After Refetch");
a(i, 4, "Called: After Refetch: After");
a(mfn(5, 8), 13, "Result: After Refetch B");
a(i, 4, "Called: After Refetch B: After");
setTimeout(function () {
a(mfn(3, 7), 10, "Result: After Refetch #2");
a(i, 4, "Called: After Refetch #2");
a(mfn(5, 8), 13, "Result: After Refetch #2 B");
a(i, 4, "Called: After Refetch #2 B");
a(mfn(3, 7), 10, "Result: After Refetch #3");
a(i, 4, "Called: After Refetch #3");
a(mfn(5, 8), 13, "Result: After Refetch #3 B");
a(i, 4, "Called: After Refetch #3 B");
d();
}, 200);
}, 200);
}, 200);
}, 300);
},
Async: function (a, d) {
var mfn, fn, i = 0;
fn = function (x, y, cb) {
++i;
setTimeout(function () { cb(null, x + y); }, 0);
};
mfn = memoize(fn, { maxAge: 600, preFetch: true, async: true });
mfn(3, 7, function (err, result) {
a(result, 10, "Result #1");
a(i, 1, "Called #1");
mfn(3, 7, function (err, result) {
a(result, 10, "Result #2");
a(i, 1, "Called #2");
mfn(5, 8, function (err, result) {
a(result, 13, "Result B #1");
a(i, 2, "Called B #1");
mfn(3, 7, function (err, result) {
a(result, 10, "Result #3");
a(i, 2, "Called #3");
mfn(5, 8, function (err, result) {
a(result, 13, "Result B #2");
a(i, 2, "Called B #2");
setTimeout(function () {
mfn(3, 7, function (err, result) {
a(result, 10, "Result: Wait");
a(i, 2, "Called: Wait");
mfn(5, 8, function (err, result) {
a(result, 13, "Result: Wait B");
a(i, 2, "Called: Wait B");
setTimeout(function () {
mfn(3, 7, function (err, result) {
a(result, 10, "Result: Wait After");
a(i, 2, "Called: Wait After");
mfn(5, 8, function (err, result) {
a(result, 13, "Result: Wait After B");
a(i, 2, "Called: Wait After B");
mfn(3, 7, function (err, result) {
a(result, 10, "Result: Wait After #2");
a(i, 2, "Called: Wait After #2");
mfn(5, 8, function (err, result) {
a(result, 13, "Result: Wait After B #2");
a(i, 2, "Called: Wait After B #2");
setTimeout(function () {
a(i, 4, "Called: After Refetch: Before");
mfn(3, 7, function (err, result) {
a(result, 10, "Result: After Refetch");
a(i, 4, "Called: After Refetch: After");
mfn(5, 8, function (err, result) {
a(result, 13, "Result: After Refetch B");
a(i, 4, "Called: After Refetch B: After");
setTimeout(function () {
mfn(3, 7, function (err, result) {
a(result, 10, "Result: After Refetch #2");
a(i, 4, "Called: After Refetch #2");
mfn(5, 8, function (err, result) {
a(result, 13, "Result: After Refetch #2 B");
a(i, 4, "Called: After Refetch #2 B");
mfn(3, 7, function (err, result) {
a(result, 10, "Result: After Refetch #3");
a(i, 4, "Called: After Refetch #3");
mfn(5, 8, function (err, result) {
a(result, 13, "Result: After Refetch #3 B");
a(i, 4, "Called: After Refetch #3 B");
d();
});
});
});
});
}, 200);
});
});
}, 200);
});
});
});
});
}, 200);
});
});
}, 300);
});
});
});
});
});
},
Custom: function (a, d) {
var mfn, fn, i = 0;
fn = function (x, y) {
++i;
return x + y;
};
mfn = memoize(fn, { maxAge: 600, preFetch: 1 / 6 });
a(mfn(3, 7), 10, "Result #1");
a(i, 1, "Called #1");
a(mfn(3, 7), 10, "Result #2");
a(i, 1, "Called #2");
a(mfn(5, 8), 13, "Result B #1");
a(i, 2, "Called B #1");
a(mfn(3, 7), 10, "Result #3");
a(i, 2, "Called #3");
a(mfn(5, 8), 13, "Result B #2");
a(i, 2, "Called B #2");
setTimeout(function () {
a(mfn(3, 7), 10, "Result: Wait");
a(i, 2, "Called: Wait");
a(mfn(5, 8), 13, "Result: Wait B");
a(i, 2, "Called: Wait B");
setTimeout(function () {
a(mfn(3, 7), 10, "Result: Wait After");
a(i, 2, "Called: Wait After");
a(mfn(5, 8), 13, "Result: Wait After B");
a(i, 2, "Called: Wait After B");
a(mfn(3, 7), 10, "Result: Wait After #2");
a(i, 2, "Called: Wait After #2");
a(mfn(5, 8), 13, "Result: Wait After B #2");
a(i, 2, "Called: Wait After B #2");
setTimeout(function () {
a(i, 4, "Called: After Refetch: Before");
a(mfn(3, 7), 10, "Result: After Refetch");
a(i, 4, "Called: After Refetch: After");
a(mfn(5, 8), 13, "Result: After Refetch B");
a(i, 4, "Called: After Refetch B: After");
setTimeout(function () {
a(mfn(3, 7), 10, "Result: After Refetch #2");
a(i, 4, "Called: After Refetch #2");
a(mfn(5, 8), 13, "Result: After Refetch #2 B");
a(i, 4, "Called: After Refetch #2 B");
a(mfn(3, 7), 10, "Result: After Refetch #3");
a(i, 4, "Called: After Refetch #3");
a(mfn(5, 8), 13, "Result: After Refetch #3 B");
a(i, 4, "Called: After Refetch #3 B");
d();
}, 200);
}, 300);
}, 100);
}, 450);
}
}
};
};

361
node_modules/memoizee/test/ext/max.js generated vendored Normal file
View File

@@ -0,0 +1,361 @@
'use strict';
var memoize = require('../..')
, nextTick = require('next-tick');
module.exports = function () {
return {
Regular: {
Sync: function (a) {
var mfn, fn, i = 0;
fn = function (x, y) {
++i;
return x + y;
};
mfn = memoize(fn, { max: 3 });
a(mfn(3, 7), 10, "Result #1");
a(i, 1, "Called #1");
a(mfn(3, 7), 10, "Result #2");
a(i, 1, "Called #2");
a(mfn(5, 8), 13, "Result B #1");
a(i, 2, "Called B #1");
a(mfn(3, 7), 10, "Result #3");
a(i, 2, "Called #3");
a(mfn(5, 8), 13, "Result B #2");
a(i, 2, "Called B #2");
a(mfn(12, 4), 16, "Result C #1");
a(i, 3, "Called C #1");
a(mfn(3, 7), 10, "Result #4");
a(i, 3, "Called #4");
a(mfn(5, 8), 13, "Result B #3");
a(i, 3, "Called B #3");
a(mfn(77, 11), 88, "Result D #1"); // Delete 12, 4
a(i, 4, "Called D #1");
a(mfn(5, 8), 13, "Result B #4");
a(i, 4, "Called B #4");
a(mfn(12, 4), 16, "Result C #2"); // Delete 3, 7
a(i, 5, "Called C #2");
a(mfn(3, 7), 10, "Result #5"); // Delete 77, 11
a(i, 6, "Called #5");
a(mfn(77, 11), 88, "Result D #2"); // Delete 5, 8
a(i, 7, "Called D #2");
a(mfn(12, 4), 16, "Result C #3");
a(i, 7, "Called C #3");
a(mfn(5, 8), 13, "Result B #5"); // Delete 3, 7
a(i, 8, "Called B #5");
a(mfn(77, 11), 88, "Result D #3");
a(i, 8, "Called D #3");
mfn.delete(77, 11);
a(mfn(77, 11), 88, "Result D #4");
a(i, 9, "Called D #4");
mfn.clear();
a(mfn(5, 8), 13, "Result B #6");
a(i, 10, "Called B #6");
a(mfn(77, 11), 88, "Result D #5");
a(i, 11, "Called D #5");
},
Async: function (a, d) {
var mfn, fn, u = {}, i = 0;
fn = function (x, y, cb) {
nextTick(function () {
++i;
cb(null, x + y);
});
return u;
};
mfn = memoize(fn, { async: true, max: 3 });
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Result #1");
a(i, 1, "Called #1");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Result #2");
a(i, 1, "Called #2");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13], "Result B #1");
a(i, 2, "Called B #1");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Result #3");
a(i, 2, "Called #3");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13], "Result B #2");
a(i, 2, "Called B #2");
a(mfn(12, 4, function (err, res) {
a.deep([err, res], [null, 16], "Result C #1");
a(i, 3, "Called C #1");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Result #4");
a(i, 3, "Called #4");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13], "Result B #3");
a(i, 3, "Called B #3");
a(mfn(77, 11, function (err, res) {
a.deep([err, res], [null, 88], "Result D #1");
a(i, 4, "Called D #1");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13], "Result B #4");
a(i, 4, "Called B #4");
a(mfn(12, 4, function (err, res) {
a.deep([err, res], [null, 16], "Result C #2");
a(i, 5, "Called C #2");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Result #5");
a(i, 6, "Called #5");
a(mfn(77, 11, function (err, res) {
a.deep([err, res], [null, 88],
"Result D #2");
a(i, 7, "Called D #2");
a(mfn(12, 4, function (err, res) {
a.deep([err, res], [null, 16],
"Result C #3");
a(i, 7, "Called C #3");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13],
"Result B #5");
a(i, 8, "Called B #5");
a(mfn(77, 11, function (err, res) {
a.deep([err, res], [null, 88],
"Result D #3");
a(i, 8, "Called D #3");
mfn.delete(77, 11);
a(mfn(77, 11, function (err, res) {
a.deep([err, res], [null, 88],
"Result D #4");
a(i, 9, "Called D #4");
mfn.clear();
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13],
"Result B #6");
a(i, 10, "Called B #6");
a(mfn(77, 11,
function (err, res) {
a.deep([err, res], [null, 88],
"Result D #5");
a(i, 11, "Called D #5");
d();
}), u, "Initial D #5");
}), u, "Initial B #6");
}), u, "Initial D #4");
}), u, "Initial D #3");
}), u, "Initial B #5");
}), u, "Initial C #3");
}), u, "Initial D #2");
}), u, "Initial #5");
}), u, "Initial C #2");
}), u, "Initial B #4");
}), u, "Initial D #1");
}), u, "Initial B #3");
}), u, "Initial #4");
}), u, "Initial C #1");
}), u, "Initial B #2");
}), u, "Initial #3");
}), u, "Initial B #1");
}), u, "Initial #2");
}), u, "Initial #1");
}
},
Primitive: {
Sync: function (a) {
var mfn, fn, i = 0;
fn = function (x, y) {
++i;
return x + y;
};
mfn = memoize(fn, { primitive: true, max: 3 });
a(mfn(3, 7), 10, "Result #1");
a(i, 1, "Called #1");
a(mfn(3, 7), 10, "Result #2");
a(i, 1, "Called #2");
a(mfn(5, 8), 13, "Result B #1");
a(i, 2, "Called B #1");
a(mfn(3, 7), 10, "Result #3");
a(i, 2, "Called #3");
a(mfn(5, 8), 13, "Result B #2");
a(i, 2, "Called B #2");
a(mfn(12, 4), 16, "Result C #1");
a(i, 3, "Called C #1");
a(mfn(3, 7), 10, "Result #4");
a(i, 3, "Called #4");
a(mfn(5, 8), 13, "Result B #3");
a(i, 3, "Called B #3");
a(mfn(77, 11), 88, "Result D #1"); // Delete 12, 4
a(i, 4, "Called D #1");
a(mfn(5, 8), 13, "Result B #4");
a(i, 4, "Called B #4");
a(mfn(12, 4), 16, "Result C #2"); // Delete 3, 7
a(i, 5, "Called C #2");
a(mfn(3, 7), 10, "Result #5"); // Delete 77, 11
a(i, 6, "Called #5");
a(mfn(77, 11), 88, "Result D #2"); // Delete 5, 8
a(i, 7, "Called D #2");
a(mfn(12, 4), 16, "Result C #3");
a(i, 7, "Called C #3");
a(mfn(5, 8), 13, "Result B #5"); // Delete 3, 7
a(i, 8, "Called B #5");
a(mfn(77, 11), 88, "Result D #3");
a(i, 8, "Called D #3");
mfn.delete(77, 11);
a(mfn(77, 11), 88, "Result D #4");
a(i, 9, "Called D #4");
mfn.clear();
a(mfn(5, 8), 13, "Result B #6");
a(i, 10, "Called B #6");
a(mfn(77, 11), 88, "Result D #5");
a(i, 11, "Called D #5");
},
Async: function (a, d) {
var mfn, fn, u = {}, i = 0;
fn = function (x, y, cb) {
nextTick(function () {
++i;
cb(null, x + y);
});
return u;
};
mfn = memoize(fn, { async: true, primitive: true, max: 3 });
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Result #1");
a(i, 1, "Called #1");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Result #2");
a(i, 1, "Called #2");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13], "Result B #1");
a(i, 2, "Called B #1");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Result #3");
a(i, 2, "Called #3");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13], "Result B #2");
a(i, 2, "Called B #2");
a(mfn(12, 4, function (err, res) {
a.deep([err, res], [null, 16], "Result C #1");
a(i, 3, "Called C #1");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Result #4");
a(i, 3, "Called #4");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13], "Result B #3");
a(i, 3, "Called B #3");
a(mfn(77, 11, function (err, res) {
a.deep([err, res], [null, 88], "Result D #1");
a(i, 4, "Called D #1");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13], "Result B #4");
a(i, 4, "Called B #4");
a(mfn(12, 4, function (err, res) {
a.deep([err, res], [null, 16], "Result C #2");
a(i, 5, "Called C #2");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Result #5");
a(i, 6, "Called #5");
a(mfn(77, 11, function (err, res) {
a.deep([err, res], [null, 88],
"Result D #2");
a(i, 7, "Called D #2");
a(mfn(12, 4, function (err, res) {
a.deep([err, res], [null, 16],
"Result C #3");
a(i, 7, "Called C #3");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13],
"Result B #5");
a(i, 8, "Called B #5");
a(mfn(77, 11, function (err, res) {
a.deep([err, res], [null, 88],
"Result D #3");
a(i, 8, "Called D #3");
mfn.delete(77, 11);
a(mfn(77, 11, function (err, res) {
a.deep([err, res], [null, 88],
"Result D #4");
a(i, 9, "Called D #4");
mfn.clear();
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13],
"Result B #6");
a(i, 10, "Called B #6");
a(mfn(77, 11,
function (err, res) {
a.deep([err, res], [null, 88],
"Result D #5");
a(i, 11, "Called D #5");
d();
}), u, "Initial D #5");
}), u, "Initial B #6");
}), u, "Initial D #4");
}), u, "Initial D #3");
}), u, "Initial B #5");
}), u, "Initial C #3");
}), u, "Initial D #2");
}), u, "Initial #5");
}), u, "Initial C #2");
}), u, "Initial B #4");
}), u, "Initial D #1");
}), u, "Initial B #3");
}), u, "Initial #4");
}), u, "Initial C #1");
}), u, "Initial B #2");
}), u, "Initial #3");
}), u, "Initial B #1");
}), u, "Initial #2");
}), u, "Initial #1");
}
}
};
};

173
node_modules/memoizee/test/ext/ref-counter.js generated vendored Normal file
View File

@@ -0,0 +1,173 @@
'use strict';
var memoize = require('../..')
, nextTick = require('next-tick');
module.exports = function () {
return {
Regular: function (a) {
var i = 0, fn = function (x, y, z) { ++i; return x + y + z; }, mfn;
mfn = memoize(fn, { refCounter: true });
a(mfn.deleteRef(3, 5, 7), null, "Delete before");
a(mfn(3, 5, 7), 15, "Initial");
a(mfn(3, 5, 7), 15, "Cache");
a(mfn.deleteRef(3, 5, 7), false, "Delete #1");
mfn(3, 5, 7);
a(mfn.deleteRef(3, 5, 7), false, "Delete #2");
mfn(3, 5, 7);
a(mfn.deleteRef(3, 5, 7), false, "Delete #3");
mfn(3, 5, 7);
a(i, 1, "Not deleteed");
a(mfn.deleteRef(3, 5, 7), false, "Delete #4");
a(mfn.deleteRef(3, 5, 7), true, "Delete final");
mfn(3, 5, 7);
a(i, 2, "Restarted");
mfn(3, 5, 7);
a(i, 2, "Cached again");
},
"Regular: Async": function (a, d) {
var mfn, fn, u = {}, i = 0;
fn = function (x, y, cb) {
nextTick(function () {
++i;
cb(null, x + y);
});
return u;
};
mfn = memoize(fn, { async: true, refCounter: true });
a(mfn.deleteRef(3, 7), null, "Delete ref before");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Result #1");
}), u, "Initial");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Result #2");
}), u, "Initial #2");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13], "Result B #1");
}), u, "Initial #2");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Result #3");
}), u, "Initial #2");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13], "Result B #2");
}), u, "Initial #3");
nextTick(function () {
a(i, 2, "Called #2");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Again: Result");
}), u, "Again: Initial");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13], "Again B: Result");
}), u, "Again B: Initial");
nextTick(function () {
a(i, 2, "Again Called #2");
a(mfn.deleteRef(3, 7), false, "Delete ref #1");
a(mfn.deleteRef(3, 7), false, "Delete ref #2");
a(mfn.deleteRef(3, 7), false, "Delete ref #3");
a(mfn.deleteRef(3, 7), true, "Delete ref Final");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Again: Result");
}), u, "Again: Initial");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13], "Again B: Result");
}), u, "Again B: Initial");
nextTick(function () {
a(i, 3, "Call After delete");
d();
});
});
});
},
Primitive: function (a) {
var i = 0, fn = function (x, y, z) { ++i; return x + y + z; }, mfn;
mfn = memoize(fn, { primitive: true, refCounter: true });
a(mfn.deleteRef(3, 5, 7), null, "Delete before");
a(mfn(3, 5, 7), 15, "Initial");
a(mfn(3, 5, 7), 15, "Cache");
a(mfn.deleteRef(3, 5, 7), false, "Delete #1");
mfn(3, 5, 7);
a(mfn.deleteRef(3, 5, 7), false, "Delete #2");
mfn(3, 5, 7);
a(mfn.deleteRef(3, 5, 7), false, "Delete #3");
mfn(3, 5, 7);
a(i, 1, "Not deleteed");
a(mfn.deleteRef(3, 5, 7), false, "Delete #4");
a(mfn.deleteRef(3, 5, 7), true, "Delete final");
mfn(3, 5, 7);
a(i, 2, "Restarted");
mfn(3, 5, 7);
a(i, 2, "Cached again");
},
"Primitive: Async": function (a, d) {
var mfn, fn, u = {}, i = 0;
fn = function (x, y, cb) {
nextTick(function () {
++i;
cb(null, x + y);
});
return u;
};
mfn = memoize(fn, { async: true, primitive: true, refCounter: true });
a(mfn.deleteRef(3, 7), null, "Delete ref before");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Result #1");
}), u, "Initial");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Result #2");
}), u, "Initial #2");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13], "Result B #1");
}), u, "Initial #2");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Result #3");
}), u, "Initial #2");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13], "Result B #2");
}), u, "Initial #3");
nextTick(function () {
a(i, 2, "Called #2");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Again: Result");
}), u, "Again: Initial");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13], "Again B: Result");
}), u, "Again B: Initial");
nextTick(function () {
a(i, 2, "Again Called #2");
a(mfn.deleteRef(3, 7), false, "Delete ref #1");
a(mfn.deleteRef(3, 7), false, "Delete ref #2");
a(mfn.deleteRef(3, 7), false, "Delete ref #3");
a(mfn.deleteRef(3, 7), true, "Delete ref Final");
a(mfn(3, 7, function (err, res) {
a.deep([err, res], [null, 10], "Again: Result");
}), u, "Again: Initial");
a(mfn(5, 8, function (err, res) {
a.deep([err, res], [null, 13], "Again B: Result");
}), u, "Again B: Initial");
nextTick(function () {
a(i, 3, "Call After delete");
d();
});
});
});
}
};
};

1357
node_modules/memoizee/test/index.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

76
node_modules/memoizee/test/lib/configure-map.js generated vendored Normal file
View File

@@ -0,0 +1,76 @@
'use strict';
var aFrom = require('es5-ext/array/from')
, memoize = require('../..');
module.exports = function () {
return {
"One arg": function (a) {
var i = 0, fn = function (x) { ++i; return x; }, mfn
, y = { toString: function () { return 'foo'; } };
mfn = memoize(fn, { primitive: true });
a(mfn(y), y, "#1");
a(mfn('foo'), y, "#2");
a(i, 1, "Called once");
},
"Clear cache": function (a) {
var i = 0, fn = function (x, y, z) { ++i; return x + y + z; }, mfn
, y = { toString: function () { return 'foo'; } };
mfn = memoize(fn, { primitive: true });
a(mfn(y, 'bar', 'zeta'), 'foobarzeta', "#1");
a(mfn('foo', 'bar', 'zeta'), 'foobarzeta', "#2");
a(i, 1, "Called once");
mfn.delete('foo', { toString: function () { return 'bar'; } },
'zeta');
a(mfn(y, 'bar', 'zeta'), 'foobarzeta', "#3");
a(i, 2, "Called twice");
},
Circular: function (a) {
var i = 0, fn;
fn = memoize(function (x) {
if (++i < 2) fn(x);
});
a.throws(function () {
fn('foo');
}, 'CIRCULAR_INVOCATION');
i = 0;
fn = memoize(function (x, y) {
if (++i < 2) fn(x, y);
});
a.throws(function () {
fn('foo', 'bar');
}, 'CIRCULAR_INVOCATION');
},
Resolvers: function () {
var i = 0, fn, r;
fn = memoize(function () { ++i; return arguments; },
{ length: 3, resolvers: [Boolean, String] });
return {
"No args": function (a) {
i = 0;
a.deep(aFrom(r = fn()), [false, 'undefined'], "First");
a(fn(), r, "Second");
a(fn(), r, "Third");
a(i, 1, "Called once");
},
"Some Args": function (a) {
var x = {};
i = 0;
a.deep(aFrom(r = fn(0, 34, x, 45)), [false, '34', x, 45], "First");
a(fn(0, 34, x, 22), r, "Second");
a(fn(0, 34, x, false), r, "Third");
a(i, 1, "Called once");
return {
Other: function (a) {
a.deep(aFrom(r = fn(1, 34, x, 34)),
[true, '34', x, 34], "Second");
a(fn(1, 34, x, 89), r, "Third");
a(i, 2, "Called once");
}
};
}
};
}
};
};

36
node_modules/memoizee/test/lib/methods.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
'use strict';
var d = require('d')
, memoize = require('../..');
require('../ext/dispose');
require('../ext/ref-counter');
module.exports = function (t, a) {
var value = [], obj = {};
t = t(memoize);
Object.defineProperties(obj, t({
someFn: d(function (x, y) { a(this, obj); return x + y; },
{ refCounter: true,
dispose: function (val) { value.push(val); } })
}));
obj = Object.create(obj);
obj.someFn(3, 7);
obj.someFn(5, 8);
obj.someFn(12, 4);
a.deep(value, [], "Pre");
obj.someFn(5, 8);
obj.someFn.deleteRef(5, 8);
a.deep(value, [], "Pre");
obj.someFn.deleteRef(5, 8);
a.deep(value, [13], "#1");
value = [];
obj.someFn.deleteRef(12, 4);
a.deep(value, [16], "#2");
value = [];
obj.someFn(77, 11);
obj.someFn.clear();
a.deep(value, [10, 88], "Clear");
};

View File

@@ -0,0 +1,6 @@
'use strict';
module.exports = function (t, a) {
require('../../ext/async');
a(typeof t.async, 'function');
};

10
node_modules/memoizee/test/lib/resolve-length.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
'use strict';
module.exports = function (t, a) {
a(t(1, 2), 1, "Options");
a(t(1, 2, true), 1, "Options: Async ");
a(t(undefined, 2), 2, "Function");
a(t(undefined, 2, true), 1, "Function: Async");
a(t(undefined, undefined, false), 1, "Unknown");
a(t(undefined, undefined, true), 1, "Unknown: async");
};

6
node_modules/memoizee/test/lib/resolve-normalize.js generated vendored Normal file
View File

@@ -0,0 +1,6 @@
'use strict';
module.exports = function (t, a) {
var fn = function () {};
a.deep(t(fn), { get: fn, set: fn });
};

5
node_modules/memoizee/test/lib/resolve-resolve.js generated vendored Normal file
View File

@@ -0,0 +1,5 @@
'use strict';
module.exports = function (t, a) {
a.deep(t([String, null, Number])([23, 'foo', '45', 'elo']), ['23', 'foo', 45, 'elo']);
};

39
node_modules/memoizee/test/lib/weak.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
'use strict';
var memoize = require('../..');
require('../ext/dispose');
require('../ext/ref-counter');
module.exports = function (t, a) {
var value = [], obj = {}, memoized, count = 0, x, y, z;
t = t(memoize);
memoized = t(function (arg, x, y) { a(arg, obj); return x + y; },
{ refCounter: true, dispose: function (val) { value.push(val); } });
a(memoized(obj, 3, 7), 10);
a(memoized(obj, 5, 8), 13);
a(memoized(obj, 12, 4), 16);
a.deep(value, [], "Pre");
a(memoized(obj, 5, 8), 13);
memoized.deleteRef(obj, 5, 8);
a.deep(value, [], "Pre");
memoized.deleteRef(obj, 5, 8);
a.deep(value, [13], "#1");
value = [];
memoized.deleteRef(obj, 12, 4);
a.deep(value, [16], "#2");
value = [];
memoized(obj, 77, 11);
x = {};
y = {};
z = {};
memoized = t(function (arg) { return ++count; });
a(memoized(x), 1);
a(memoized(y), 2);
a(memoized(x), 1);
a(memoized(z), 3);
a(count, 3);
};

34
node_modules/memoizee/test/methods-plain.js generated vendored Normal file
View File

@@ -0,0 +1,34 @@
'use strict';
var d = require('d');
require('../ext/dispose');
require('../ext/ref-counter');
module.exports = function (t, a) {
var value = [], obj = {};
Object.defineProperties(obj, t({
someFn: d(function (x, y) { a(this, obj); return x + y; },
{ refCounter: true,
dispose: function (val) { value.push(val); } })
}));
obj = Object.create(obj);
obj.someFn(3, 7);
obj.someFn(5, 8);
obj.someFn(12, 4);
a.deep(value, [], "Pre");
obj.someFn(5, 8);
obj.someFn.deleteRef(5, 8);
a.deep(value, [], "Pre");
obj.someFn.deleteRef(5, 8);
a.deep(value, [13], "#1");
value = [];
obj.someFn.deleteRef(12, 4);
a.deep(value, [16], "#2");
value = [];
obj.someFn(77, 11);
obj.someFn.clear();
a.deep(value, [10, 88], "Clear all");
};

31
node_modules/memoizee/test/methods.js generated vendored Normal file
View File

@@ -0,0 +1,31 @@
'use strict';
var d = require('d');
module.exports = function (t, a) {
var value = [], obj = {};
Object.defineProperties(obj, t({
someFn: d(function (x, y) { a(this, obj); return x + y; },
{ refCounter: true,
dispose: function (val) { value.push(val); } })
}));
obj = Object.create(obj);
obj.someFn(3, 7);
obj.someFn(5, 8);
obj.someFn(12, 4);
a.deep(value, [], "Pre");
obj.someFn(5, 8);
obj.someFn.deleteRef(5, 8);
a.deep(value, [], "Pre");
obj.someFn.deleteRef(5, 8);
a.deep(value, [13], "#1");
value = [];
obj.someFn.deleteRef(12, 4);
a.deep(value, [16], "#2");
value = [];
obj.someFn(77, 11);
obj.someFn.clear();
a.deep(value, [10, 88], "Clear all");
};

56
node_modules/memoizee/test/normalizers/get-1.js generated vendored Normal file
View File

@@ -0,0 +1,56 @@
'use strict';
var memoize = require('../..');
module.exports = {
"": function (t, a) {
var i = 0, fn = function (x) { ++i; return x; };
fn = memoize(fn);
return {
"No arg": function () {
i = 0;
a(fn(), undefined, "First");
a(fn(), undefined, "Second");
a(fn(), undefined, "Third");
a(i, 1, "Called once");
},
Arg: function () {
var x = {};
i = 0;
a(fn(x, 8), x, "First");
a(fn(x, 4), x, "Second");
a(fn(x, 2), x, "Third");
a(i, 1, "Called once");
},
"Other Arg": function () {
var x = {};
i = 0;
a(fn(x, 2), x, "First");
a(fn(x, 9), x, "Second");
a(fn(x, 3), x, "Third");
a(i, 1, "Called once");
}
};
},
Delete: function (a) {
var i = 0, fn, mfn, x = {};
fn = function (a, b, c) {
return a + (++i);
};
mfn = memoize(fn, { length: 1 });
a(mfn(3), 4, "Init");
a(mfn(4, x, 1), 6, "Init #2");
mfn.delete(4);
a(mfn(3, x, 1), 4, "Cached");
mfn(3, x, 1);
a(i, 2, "Pre clear");
mfn.delete(3, x, 1);
a(i, 2, "After clear");
a(mfn(3, x, 1), 6, "Reinit");
a(i, 3, "Reinit count");
a(mfn(3, x, 1), 6, "Reinit Cached");
a(i, 3, "Reinit count");
}
};

91
node_modules/memoizee/test/normalizers/get-fixed.js generated vendored Normal file
View File

@@ -0,0 +1,91 @@
'use strict';
var memoize = require('../..');
module.exports = {
"": function (a) {
var i = 0, fn = function (x, y, z) { ++i; return [x, y, z]; }, r;
fn = memoize(fn);
return {
"No args": function () {
i = 0;
a.deep(r = fn(), [undefined, undefined, undefined], "First");
a(fn(), r, "Second");
a(fn(), r, "Third");
a(i, 1, "Called once");
},
"Some Args": function () {
var x = {};
i = 0;
a.deep(r = fn(x, 8), [x, 8, undefined], "First");
a(fn(x, 8), r, "Second");
a(fn(x, 8), r, "Third");
a(i, 1, "Called once");
return {
Other: function () {
a.deep(r = fn(x, 5), [x, 5, undefined], "Second");
a(fn(x, 5), r, "Third");
a(i, 2, "Called once");
}
};
},
"Full stuff": function () {
var x = {};
i = 0;
a.deep(r = fn(x, 8, 23, 98), [x, 8, 23], "First");
a(fn(x, 8, 23, 43), r, "Second");
a(fn(x, 8, 23, 9), r, "Third");
a(i, 1, "Called once");
return {
Other: function () {
a.deep(r = fn(x, 23, 8, 13), [x, 23, 8], "Second");
a(fn(x, 23, 8, 22), r, "Third");
a(i, 2, "Called once");
}
};
}
};
},
Delete: function (a) {
var i = 0, fn, mfn, x = {};
fn = function (a, b, c) {
return a + (++i);
};
mfn = memoize(fn);
a(mfn(3, x, 1), 4, "Init");
a(mfn(4, x, 1), 6, "Init #2");
mfn.delete(4, x, 1);
a(mfn(3, x, 1), 4, "Cached");
mfn(3, x, 1);
a(i, 2, "Pre clear");
mfn.delete(3, x, 1);
a(i, 2, "After clear");
a(mfn(3, x, 1), 6, "Reinit");
a(i, 3, "Reinit count");
a(mfn(3, x, 1), 6, "Reinit Cached");
a(i, 3, "Reinit count");
},
Clear: function (a) {
var i = 0, fn, x = {};
fn = function () {
++i;
return arguments;
};
fn = memoize(fn, { length: 3 });
fn(1, x, 3);
fn(1, x, 4);
fn(1, x, 3);
fn(1, x, 4);
a(i, 2, "Pre clear");
fn.clear();
fn(1, x, 3);
fn(1, x, 4);
fn(1, x, 3);
fn(1, x, 4);
a(i, 4, "After clear");
}
};

View File

@@ -0,0 +1,43 @@
'use strict';
var memoize = require('../..');
module.exports = {
"": function (a) {
var i = 0, fn = function (x, y, z) { ++i; return x + y + z; }, mfn
, y = { toString: function () { return 'foo'; } };
mfn = memoize(fn, { primitive: true });
a(mfn(y, 'bar', 'zeta'), 'foobarzeta', "#1");
a(mfn('foo', 'bar', 'zeta'), 'foobarzeta', "#2");
a(i, 1, "Called once");
},
Delete: function (a) {
var i = 0, fn = function (x, y, z) { ++i; return x + y + z; }, mfn
, y = { toString: function () { return 'foo'; } };
mfn = memoize(fn, { primitive: true });
a(mfn(y, 'bar', 'zeta'), 'foobarzeta', "#1");
a(mfn('foo', 'bar', 'zeta'), 'foobarzeta', "#2");
a(i, 1, "Called once");
mfn.delete('foo', { toString: function () { return 'bar'; } },
'zeta');
a(mfn(y, 'bar', 'zeta'), 'foobarzeta', "#3");
a(i, 2, "Called twice");
},
Clear: function (a) {
var i = 0, fn;
fn = memoize(function (x) {
if (++i < 2) fn(x);
});
a.throws(function () {
fn('foo');
}, 'CIRCULAR_INVOCATION');
i = 0;
fn = memoize(function (x, y) {
if (++i < 2) fn(x, y);
});
a.throws(function () {
fn('foo', 'bar');
}, 'CIRCULAR_INVOCATION');
}
};

59
node_modules/memoizee/test/normalizers/get.js generated vendored Normal file
View File

@@ -0,0 +1,59 @@
'use strict';
var aFrom = require('es5-ext/array/from')
, memoize = require('../..');
module.exports = function () {
return {
"": function (a) {
var i = 0, fn = function () { ++i; return arguments; }, r;
fn = memoize(fn, { length: false });
return {
"No args": function () {
i = 0;
a.deep(aFrom(r = fn()), [], "First");
a(fn(), r, "Second");
a(fn(), r, "Third");
a(i, 1, "Called once");
},
"Some Args": function () {
var x = {};
i = 0;
a.deep(aFrom(r = fn(x, 8)), [x, 8], "First");
a(fn(x, 8), r, "Second");
a(fn(x, 8), r, "Third");
a(i, 1, "Called once");
},
"Many args": function () {
var x = {};
i = 0;
a.deep(aFrom(r = fn(x, 8, 23, 98)), [x, 8, 23, 98], "First");
a(fn(x, 8, 23, 98), r, "Second");
a(fn(x, 8, 23, 98), r, "Third");
a(i, 1, "Called once");
}
};
},
Delete: function (a) {
var i = 0, fn, mfn, x = {};
fn = function (a, b, c) {
return a + (++i);
};
mfn = memoize(fn, { length: false });
a(mfn(3, x, 1), 4, "Init");
a(mfn(4, x, 1), 6, "Init #2");
mfn.delete(4, x, 1);
a(mfn(3, x, 1), 4, "Cached");
mfn(3, x, 1);
a(i, 2, "Pre clear");
mfn.delete(3, x, 1);
a(i, 2, "After clear");
a(mfn(3, x, 1), 6, "Reinit");
a(i, 3, "Reinit count");
a(mfn(3, x, 1), 6, "Reinit Cached");
a(i, 3, "Reinit count");
}
};
};

18
node_modules/memoizee/test/normalizers/primitive.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
'use strict';
var memoize = require('../..')
, join = Array.prototype.join;
module.exports = function (a) {
var i = 0, fn = function () { ++i; return join.call(arguments, '|'); }
, y = { toString: function () { return 'foo'; } }, mfn;
mfn = memoize(fn, { primitive: true, length: false });
a(mfn(y, 'bar', 'zeta'), 'foo|bar|zeta', "#1");
a(mfn('foo', 'bar', 'zeta'), 'foo|bar|zeta', "#2");
a(i, 1, "Called once");
a(mfn(y, 'bar'), 'foo|bar', "#3");
a(i, 2, "Called twice");
a(mfn(y, 'bar'), 'foo|bar', "#4");
a(i, 2, "Called twice #2");
};

29
node_modules/memoizee/test/plain.js generated vendored Normal file
View File

@@ -0,0 +1,29 @@
'use strict';
module.exports = function (t) {
return {
"": function (a) {
var i = 0, fn = function (x) { ++i; return x; }, mfn
, y = { toString: function () { return 'foo'; } };
mfn = t(fn, { primitive: true });
a(typeof mfn, 'function', "Returns");
a(mfn.__memoized__, true, "Marked");
a(t(mfn), mfn, "Do not memoize memoized");
a(mfn(y), y, "#1");
a(mfn('foo'), y, "#2");
a(i, 1, "Called once");
},
"Clear cache": function (a) {
var i = 0, fn = function (x, y, z) { ++i; return x + y + z; }, mfn
, y = { toString: function () { return 'foo'; } };
mfn = t(fn, { primitive: true });
a(mfn(y, 'bar', 'zeta'), 'foobarzeta', "#1");
a(mfn('foo', 'bar', 'zeta'), 'foobarzeta', "#2");
a(i, 1, "Called once");
mfn.delete('foo', { toString: function () { return 'bar'; } },
'zeta');
a(mfn(y, 'bar', 'zeta'), 'foobarzeta', "#3");
a(i, 2, "Called twice");
}
};
};

11
node_modules/memoizee/test/profile.js generated vendored Normal file
View File

@@ -0,0 +1,11 @@
'use strict';
var memoize = require('../plain');
module.exports = function (t, a) {
memoize(function () {})();
a(typeof t.statistics, 'object', "Access to statistics");
a(Object.keys(t.statistics).length > 0, true, "Statistics collected");
a(typeof t.log, 'function', "Access to log function");
a(typeof t.log(), 'string', "Log outputs string");
};

36
node_modules/memoizee/test/weak-plain.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
'use strict';
require('../ext/dispose');
require('../ext/ref-counter');
module.exports = function (t, a) {
var value = [], obj = {}, memoized, count = 0, x, y, z;
memoized = t(function (arg, x, y) { a(arg, obj); return x + y; },
{ refCounter: true, dispose: function (val) { value.push(val); } });
a(memoized(obj, 3, 7), 10);
a(memoized(obj, 5, 8), 13);
a(memoized(obj, 12, 4), 16);
a.deep(value, [], "Pre");
a(memoized(obj, 5, 8), 13);
memoized.deleteRef(obj, 5, 8);
a.deep(value, [], "Pre");
memoized.deleteRef(obj, 5, 8);
a.deep(value, [13], "#1");
value = [];
memoized.deleteRef(obj, 12, 4);
a.deep(value, [16], "#2");
value = [];
memoized(obj, 77, 11);
x = {};
y = {};
z = {};
memoized = t(function (arg) { return ++count; });
a(memoized(x), 1);
a(memoized(y), 2);
a(memoized(x), 1);
a(memoized(z), 3);
a(count, 3);
};

33
node_modules/memoizee/test/weak.js generated vendored Normal file
View File

@@ -0,0 +1,33 @@
'use strict';
module.exports = function (t, a) {
var value = [], obj = {}, memoized, count = 0, x, y, z;
memoized = t(function (arg, x, y) { a(arg, obj); return x + y; },
{ refCounter: true, dispose: function (val) { value.push(val); } });
a(memoized(obj, 3, 7), 10);
a(memoized(obj, 5, 8), 13);
a(memoized(obj, 12, 4), 16);
a.deep(value, [], "Pre");
a(memoized(obj, 5, 8), 13);
memoized.deleteRef(obj, 5, 8);
a.deep(value, [], "Pre");
memoized.deleteRef(obj, 5, 8);
a.deep(value, [13], "#1");
value = [];
memoized.deleteRef(obj, 12, 4);
a.deep(value, [16], "#2");
value = [];
memoized(obj, 77, 11);
x = {};
y = {};
z = {};
memoized = t(function (arg) { return ++count; });
a(memoized(x), 1);
a(memoized(y), 2);
a(memoized(x), 1);
a(memoized(z), 3);
a(count, 3);
};

3
node_modules/memoizee/weak-plain.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
'use strict';
module.exports = require('./lib/weak')(require('./plain'));

3
node_modules/memoizee/weak.js generated vendored Normal file
View File

@@ -0,0 +1,3 @@
'use strict';
module.exports = require('./lib/weak')(require('./'));