Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

memoizee

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

memoizee - npm Package Compare versions

Comparing version 0.3.7 to 0.3.8

lib/resolve-normalize.js

51

lib/configure-map.js
'use strict';
var toArray = require('es5-ext/array/to-array')
, customError = require('es5-ext/error/custom')
, defineLength = require('es5-ext/function/_define-length')
, callable = require('es5-ext/object/valid-callable')
, d = require('d')
, ee = require('event-emitter').methods
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')
, slice = Array.prototype.slice
, apply = Function.prototype.apply, call = Function.prototype.call
, create = Object.create, hasOwnProperty = Object.prototype.hasOwnProperty
, defineProperties = Object.defineProperties
, on = ee.on, emit = ee.emit, resolveArgs;
, on = ee.on, emit = ee.emit;
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 (original, length, options) {
var cache = create(null), conf, memLength, get, set, del, clear, extDel
, getListeners, setListeners, deleteListeners, memoized, resolve, resolvers;
var cache = create(null), conf, memLength, get, set, del, clear, extDel, normalizer
, getListeners, setListeners, deleteListeners, memoized, resolve;
if (length !== false) memLength = length;

@@ -30,24 +23,10 @@ else if (isNaN(original.length)) memLength = 1;

if (options.normalizer) {
if (typeof options.normalizer === 'function') {
set = get = options.normalizer;
} else {
get = callable(options.normalizer.get);
if (options.normalizer.set !== undefined) {
set = callable(options.normalizer.set);
del = callable(options.normalizer.delete);
clear = callable(options.normalizer.clear);
} else {
set = get;
}
}
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 (options.resolvers != null) {
resolvers = toArray(options.resolvers);
resolvers.forEach(function (r) {
if (r != null) callable(r);
});
resolve = resolveArgs.bind(resolvers);
}
if (get) {

@@ -54,0 +33,0 @@ memoized = defineLength(function (arg) {

{
"name": "memoizee",
"version": "0.3.7",
"version": "0.3.8",
"description": "Memoize/cache function results",

@@ -30,6 +30,7 @@ "author": "Mariusz Nowak <medikoo@medikoo.com> (http://www.medikoo.com/)",

"es5-ext": "~0.10.4",
"es6-weak-map": "~0.1.2",
"event-emitter": "~0.3.1",
"lru-queue": "0.1.x",
"lru-queue": "0.1",
"next-tick": "~0.2.2",
"timers-ext": "0.1.x"
"timers-ext": "0.1"
},

@@ -39,3 +40,3 @@ "devDependencies": {

"xlint": "~0.2.1",
"xlint-jslint-medikoo": "0.1.x"
"xlint-jslint-medikoo": "~0.1.2"
},

@@ -42,0 +43,0 @@ "scripts": {

@@ -15,2 +15,3 @@ # Memoize

* [__Primitive mode__](#primitive-mode) which assures fast performance when arguments are conversible to strings.
* [__WeakMap based mode__](#weak-map) for garbage collection friendly configuration
* Can be configured [__for methods__](#memoizing-a-method) (when `this` counts in)

@@ -161,2 +162,19 @@ * Cache [__can be cleared manually__](#manual-clean-up) or [__after specified timeout__](#expire-cache-after-given-period-of-time)

#### WeakMap based configurations
In that 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 with [dispose callback](#registering-dispose-callback) registered.
```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

@@ -340,3 +358,3 @@

### Tests [![Build Status](https://travis-ci.org/medikoo/memoize.svn)](https://travis-ci.org/medikoo/memoize)
### Tests [![Build Status](https://travis-ci.org/medikoo/memoize.svg)](https://travis-ci.org/medikoo/memoize)

@@ -343,0 +361,0 @@ $ npm test

@@ -8,4 +8,4 @@ 'use strict';

return {
"Regular": {
"Success": function (a, d) {
Regular: {
Success: function (a, d) {
var mfn, fn, u = {}, i = 0, invoked = 0;

@@ -79,3 +79,3 @@ fn = function (x, y, cb) {

},
"Error": function (a, d) {
Error: function (a, d) {
var mfn, fn, u = {}, i = 0, e = new Error("Test");

@@ -125,4 +125,4 @@ fn = function (x, y, cb) {

},
"Primitive": {
"Success": function (a, d) {
Primitive: {
Success: function (a, d) {
var mfn, fn, u = {}, i = 0;

@@ -184,3 +184,3 @@ fn = function (x, y, cb) {

},
"Error": function (a, d) {
Error: function (a, d) {
var mfn, fn, u = {}, i = 0, e = new Error("Test");

@@ -187,0 +187,0 @@ fn = function (x, y, cb) {

@@ -8,4 +8,4 @@ 'use strict';

return {
"Regular": {
"Sync": function (a) {
Regular: {
Sync: function (a) {
var mfn, fn, value = [], x, invoked;

@@ -66,3 +66,3 @@ fn = function (x, y) { return x + y; };

},
"Async": function (a, d) {
Async: function (a, d) {
var mfn, fn, u = {}, value = [];

@@ -98,4 +98,4 @@ fn = function (x, y, cb) {

},
"Primitive": {
"Sync": function (a) {
Primitive: {
Sync: function (a) {
var mfn, fn, value = [];

@@ -144,3 +144,3 @@ fn = function (x, y) { return x + y; };

},
"Async": function (a, d) {
Async: function (a, d) {
var mfn, fn, u = {}, value = [];

@@ -147,0 +147,0 @@ fn = function (x, y, cb) {

@@ -10,4 +10,4 @@ 'use strict';

return {
"Regular": {
"Sync": function (a, d) {
Regular: {
Sync: function (a, d) {
var mfn, fn, i = 0;

@@ -56,3 +56,3 @@ fn = function (x, y) {

},
"Async": function (a, d) {
Async: function (a, d) {
var mfn, fn, u = {}, i = 0;

@@ -113,4 +113,4 @@ fn = function (x, y, cb) {

},
"Primitive": {
"Sync": function (a, d) {
Primitive: {
Sync: function (a, d) {
var mfn, fn, i = 0;

@@ -154,3 +154,3 @@ fn = function (x, y) {

},
"Async": function (a, d) {
Async: function (a, d) {
var mfn, fn, u = {}, i = 0;

@@ -211,4 +211,4 @@ fn = function (x, y, cb) {

},
"Refetch": {
"Default": function (a, d) {
Refetch: {
Default: function (a, d) {
var mfn, fn, i = 0;

@@ -273,3 +273,3 @@ fn = function (x, y) {

},
"Async": function (a, d) {
Async: function (a, d) {
var mfn, fn, i = 0;

@@ -363,3 +363,3 @@ fn = function (x, y, cb) {

},
"Custom": function (a, d) {
Custom: function (a, d) {
var mfn, fn, i = 0;

@@ -366,0 +366,0 @@ fn = function (x, y) {

@@ -8,4 +8,4 @@ 'use strict';

return {
"Regular": {
"Sync": function (a) {
Regular: {
Sync: function (a) {
var mfn, fn, i = 0;

@@ -65,3 +65,3 @@ fn = function (x, y) {

},
"Async": function (a, d) {
Async: function (a, d) {
var mfn, fn, u = {}, i = 0;

@@ -186,4 +186,4 @@ fn = function (x, y, cb) {

},
"Primitive": {
"Sync": function (a) {
Primitive: {
Sync: function (a) {
var mfn, fn, i = 0;

@@ -243,3 +243,3 @@ fn = function (x, y) {

},
"Async": function (a, d) {
Async: function (a, d) {
var mfn, fn, u = {}, i = 0;

@@ -246,0 +246,0 @@ fn = function (x, y, cb) {

@@ -8,3 +8,3 @@ 'use strict';

return {
"Regular": function (a) {
Regular: function (a) {
var i = 0, fn = function (x, y, z) { ++i; return x + y + z; }, mfn;

@@ -91,3 +91,3 @@ mfn = memoize(fn, { refCounter: true });

},
"Primitive": function (a) {
Primitive: function (a) {
var i = 0, fn = function (x, y, z) { ++i; return x + y + z; }, mfn;

@@ -94,0 +94,0 @@ mfn = memoize(fn, { primitive: true, refCounter: true });

@@ -31,3 +31,3 @@ 'use strict';

},
"Arg": function () {
Arg: function () {
var x = {};

@@ -70,3 +70,3 @@ i = 0;

return {
"Other": function () {
Other: function () {
a.deep(r = fn(x, 5), [x, 5, undefined], "Second");

@@ -86,3 +86,3 @@ a(fn(x, 5), r, "Third");

return {
"Other": function () {
Other: function () {
a.deep(r = fn(x, 23, 8, 13), [x, 23, 8], "Second");

@@ -107,3 +107,3 @@ a(fn(x, 23, 8, 22), r, "Third");

},
"Dynamic": function () {
Dynamic: function () {
var i = 0, fn = function () { ++i; return arguments; }, r;

@@ -138,3 +138,3 @@

},
"Resolvers": function () {
Resolvers: function () {
var i = 0, fn, r;

@@ -160,3 +160,3 @@ fn = t(function () { ++i; return arguments; },

return {
"Other": function () {
Other: function () {
a.deep(aFrom(r = fn(1, 34, x, 34)),

@@ -172,3 +172,3 @@ [true, '34', x, 34], "Second");

"Clear Cache": {
"Specific": function () {
Specific: function () {
var i = 0, fn, mfn, x = {};

@@ -204,3 +204,3 @@

},
"All": function () {
All: function () {
var i = 0, fn, x = {};

@@ -227,3 +227,3 @@

},
"Primitive": {
Primitive: {
"No args": function (a) {

@@ -266,3 +266,3 @@ var i = 0, fn = function () { ++i; return arguments[0]; }, mfn;

"Reference counter": {
"Regular": function (a) {
Regular: function (a) {
var i = 0, fn = function (x, y, z) { ++i; return x + y + z; }, mfn;

@@ -287,3 +287,3 @@ mfn = t(fn, { refCounter: true });

},
"Primitive": function (a) {
Primitive: function (a) {
var i = 0, fn = function (x, y, z) { ++i; return x + y + z; }, mfn;

@@ -309,5 +309,5 @@ mfn = t(fn, { primitive: true, refCounter: true });

},
"Async": {
"Regular": {
"Success": function (a, d) {
Async: {
Regular: {
Success: function (a, d) {
var mfn, fn, u = {}, i = 0, invoked = 0;

@@ -443,3 +443,3 @@ fn = function (x, y, cb) {

},
"Error": function (a, d) {
Error: function (a, d) {
var mfn, fn, u = {}, i = 0, e = new Error("Test");

@@ -489,4 +489,4 @@ fn = function (x, y, cb) {

},
"Primitive": {
"Success": function (a, d) {
Primitive: {
Success: function (a, d) {
var mfn, fn, u = {}, i = 0;

@@ -610,3 +610,3 @@ fn = function (x, y, cb) {

},
"Error": function (a, d) {
Error: function (a, d) {
var mfn, fn, u = {}, i = 0, e = new Error("Test");

@@ -657,5 +657,5 @@ fn = function (x, y, cb) {

},
"MaxAge": {
"Regular": {
"Sync": function (a, d) {
MaxAge: {
Regular: {
Sync: function (a, d) {
var mfn, fn, i = 0;

@@ -699,3 +699,3 @@ fn = function (x, y) {

},
"Async": function (a, d) {
Async: function (a, d) {
var mfn, fn, u = {}, i = 0;

@@ -756,4 +756,4 @@ fn = function (x, y, cb) {

},
"Primitive": {
"Sync": function (a, d) {
Primitive: {
Sync: function (a, d) {
var mfn, fn, i = 0;

@@ -797,3 +797,3 @@ fn = function (x, y) {

},
"Async": function (a, d) {
Async: function (a, d) {
var mfn, fn, u = {}, i = 0;

@@ -855,5 +855,5 @@ fn = function (x, y, cb) {

},
"Max": {
"Regular": {
"Sync": function (a) {
Max: {
Regular: {
Sync: function (a) {
var mfn, fn, i = 0;

@@ -913,3 +913,3 @@ fn = function (x, y) {

},
"Async": function (a, d) {
Async: function (a, d) {
var mfn, fn, u = {}, i = 0;

@@ -1034,4 +1034,4 @@ fn = function (x, y, cb) {

},
"Primitive": {
"Sync": function (a) {
Primitive: {
Sync: function (a) {
var mfn, fn, i = 0;

@@ -1091,3 +1091,3 @@ fn = function (x, y) {

},
"Async": function (a, d) {
Async: function (a, d) {
var mfn, fn, u = {}, i = 0;

@@ -1213,5 +1213,5 @@ fn = function (x, y, cb) {

},
"Dispose": {
"Regular": {
"Sync": function (a) {
Dispose: {
Regular: {
Sync: function (a) {
var mfn, fn, value = [], x, invoked;

@@ -1272,3 +1272,3 @@ fn = function (x, y) { return x + y; };

},
"Async": function (a, d) {
Async: function (a, d) {
var mfn, fn, u = {}, value = [];

@@ -1304,4 +1304,4 @@ fn = function (x, y, cb) {

},
"Primitive": {
"Sync": function (a) {
Primitive: {
Sync: function (a) {
var mfn, fn, value = [];

@@ -1350,3 +1350,3 @@ fn = function (x, y) { return x + y; };

},
"Async": function (a, d) {
Async: function (a, d) {
var mfn, fn, u = {}, value = [];

@@ -1353,0 +1353,0 @@ fn = function (x, y, cb) {

@@ -28,3 +28,3 @@ 'use strict';

},
"Circular": function (a) {
Circular: function (a) {
var i = 0, fn;

@@ -46,3 +46,3 @@ fn = memoize(function (x) {

},
"Resolvers": function () {
Resolvers: function () {
var i = 0, fn, r;

@@ -67,3 +67,3 @@ fn = memoize(function () { ++i; return arguments; },

return {
"Other": function (a) {
Other: function (a) {
a.deep(aFrom(r = fn(1, 34, x, 34)),

@@ -70,0 +70,0 @@ [true, '34', x, 34], "Second");

@@ -18,3 +18,3 @@ 'use strict';

},
"Arg": function () {
Arg: function () {
var x = {};

@@ -37,3 +37,3 @@ i = 0;

},
"Delete": function (a) {
Delete: function (a) {
var i = 0, fn, mfn, x = {};

@@ -40,0 +40,0 @@

@@ -26,3 +26,3 @@ 'use strict';

return {
"Other": function () {
Other: function () {
a.deep(r = fn(x, 5), [x, 5, undefined], "Second");

@@ -42,3 +42,3 @@ a(fn(x, 5), r, "Third");

return {
"Other": function () {
Other: function () {
a.deep(r = fn(x, 23, 8, 13), [x, 23, 8], "Second");

@@ -52,3 +52,3 @@ a(fn(x, 23, 8, 22), r, "Third");

},
"Delete": function (a) {
Delete: function (a) {
var i = 0, fn, mfn, x = {};

@@ -73,3 +73,3 @@

},
"Clear": function (a) {
Clear: function (a) {
var i = 0, fn, x = {};

@@ -76,0 +76,0 @@

@@ -14,3 +14,3 @@ 'use strict';

},
"Delete": function (a) {
Delete: function (a) {
var i = 0, fn = function (x, y, z) { ++i; return x + y + z; }, mfn

@@ -27,3 +27,3 @@ , y = { toString: function () { return 'foo'; } };

},
"Clear": function (a) {
Clear: function (a) {
var i = 0, fn;

@@ -30,0 +30,0 @@ fn = memoize(function (x) {

@@ -38,3 +38,3 @@ 'use strict';

},
"Delete": function (a) {
Delete: function (a) {
var i = 0, fn, mfn, x = {};

@@ -41,0 +41,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc