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

moize

Package Overview
Dependencies
Maintainers
2
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

moize - npm Package Compare versions

Comparing version 6.0.0 to 6.0.1

10

__tests__/default.ts

@@ -99,2 +99,12 @@ import { sameValueZeroEqual } from 'fast-equals';

});
it('should copy static properties from the source function', () => {
const fn = (a: any, b: any) => [a, b];
fn.foo = 'bar';
const memoized = moize(fn);
expect(memoized.foo).toBe(fn.foo);
});
});

@@ -101,0 +111,0 @@

4

CHANGELOG.md

@@ -1,3 +0,5 @@

# moize CHANGELOG
## 6.0.1
- [#146](https://github.com/planttheidea/moize/issues/146) - Fix reading deprecated properties on function object
## 6.0.0

@@ -4,0 +6,0 @@

@@ -524,2 +524,5 @@ 'use strict';

var ALWAYS_SKIPPED_PROPERTIES = {
arguments: true,
callee: true,
caller: true,
constructor: true,

@@ -526,0 +529,0 @@ length: true,

@@ -518,2 +518,5 @@ import memoize from 'micro-memoize';

var ALWAYS_SKIPPED_PROPERTIES = {
arguments: true,
callee: true,
caller: true,
constructor: true,

@@ -520,0 +523,0 @@ length: true,

@@ -525,2 +525,5 @@ (function (global, factory) {

var ALWAYS_SKIPPED_PROPERTIES = {
arguments: true,
callee: true,
caller: true,
constructor: true,

@@ -527,0 +530,0 @@ length: true,

@@ -1,2 +0,2 @@

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("micro-memoize"),require("fast-equals")):"function"==typeof define&&define.amd?define(["micro-memoize","fast-equals"],n):(e="undefined"!=typeof globalThis?globalThis:e||self).moize=n(e.memoize,e.fe)}(this,(function(e,n){"use strict";function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=t(e);function i(){return(i=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}var o={isDeepEqual:!1,isPromise:!1,isReact:!1,isSerialized:!1,isShallowEqual:!1,matchesArg:void 0,matchesKey:void 0,maxAge:void 0,maxArgs:void 0,maxSize:1,onExpire:void 0,profileName:void 0,serializer:void 0,updateCacheForKey:void 0,transformArgs:void 0,updateExpire:!1};function a(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce((function(e,n){return"function"==typeof e?"function"==typeof n?function(){e.apply(this,arguments),n.apply(this,arguments)}:e:"function"==typeof n?n:void 0}))}function u(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce((function(e,n){return"function"==typeof e?"function"==typeof n?function(){return e(n.apply(this,arguments))}:e:"function"==typeof n?n:void 0}))}function s(e,n){for(var t=0;t<e.length;t++)if(e[t].key===n)return t;return-1}function c(e,n){var t="function"==typeof n?n:function(n,t){for(var r=0;r<t.length;r++)if(!e(n[r],t[r]))return!1;return!0};return function(e,n){for(var r=0;r<e.length;r++)if(e[r].length===n.length&&t(e[r],n))return r;return-1}}function f(e,n){return n&&n!==o?i({},e,n,{onCacheAdd:a(e.onCacheAdd,n.onCacheAdd),onCacheChange:a(e.onCacheChange,n.onCacheChange),onCacheHit:a(e.onCacheHit,n.onCacheHit),transformArgs:u(e.transformArgs,n.transformArgs)}):e}function l(e,n,t){var r=s(e,n);-1!==r&&(clearTimeout(e[r].timeoutId),t&&e.splice(r,1))}function p(e,n){var t=setTimeout(e,n);return"function"==typeof t.unref&&t.unref(),t}function m(e,n){return function(t){var r=t.keys[0],i=s(e,r);~i&&(l(e,r,!1),e[i].timeoutId=p(e[i].expirationMethod,n.maxAge))}}function h(e,n,t,r){var i="number"==typeof n.maxAge&&isFinite(n.maxAge)?function(e,n,t,r){var i=n.maxAge;return function o(a,u,f){var m=a.keys[0];if(-1===s(e,m)){var h=function(){var i=c(t,r)(a.keys,m),s=a.values[i];~i&&(a.keys.splice(i,1),a.values.splice(i,1),"function"==typeof n.onCacheChange&&n.onCacheChange(a,u,f)),l(e,m,!0),"function"==typeof n.onExpire&&!1===n.onExpire(m)&&(a.keys.unshift(m),a.values.unshift(s),o(a,u,f),"function"==typeof n.onCacheChange&&n.onCacheChange(a,u,f))};e.push({expirationMethod:h,key:m,timeoutId:p(h,i)})}}}(e,n,t,r):void 0;return{onCacheAdd:i,onCacheHit:i&&n.updateExpire?m(e,n):void 0}}var g={anonymousProfileNameCounter:1,isCollectingStats:!1,profiles:{}},y=!1;function d(e){e?delete g.profiles[e]:g.profiles={}}function v(e){var n=e.profileName;return function(){n&&!g.profiles[n]&&(g.profiles[n]={calls:0,hits:0}),g.profiles[n].calls++}}function x(e){return function(){var n=g.profiles,t=e.profileName;n[t]||(n[t]={calls:0,hits:0}),n[t].calls++,n[t].hits++}}function C(e){var n=(new Error).stack,t=e.displayName||e.name||"Anonymous "+g.anonymousProfileNameCounter++;if(!n)return t;for(var r,i,o=n.split("\n").slice(3),a=0;a<o.length;a++)if(-1===(r=o[a]).indexOf("/moize/")&&-1===r.indexOf(" (native)")&&-1===r.indexOf(" Function.")){i=r.replace(/\n/g,"\\n").trim();break}return i?t+" "+i:t}function A(e,n){return e?(n/e*100).toFixed(4)+"%":"0.0000%"}function z(e){g.isCollectingStats||y||(console.warn('Stats are not currently being collected, please run "collectStats" to enable them.'),y=!0);var n=g.profiles;if(e){if(!n[e])return{calls:0,hits:0,usage:"0.0000%"};var t=n[e];return i({},t,{usage:A(t.calls,t.hits)})}var r=Object.keys(g.profiles).reduce((function(e,t){return e.calls+=n[t].calls,e.hits+=n[t].hits,e}),{calls:0,hits:0});return i({},r,{profiles:Object.keys(n).reduce((function(e,n){return e[n]=z(n),e}),{}),usage:A(r.calls,r.hits)})}var S={constructor:!0,length:!0,name:!0,prototype:!0};function b(e,n,t){void 0===t&&(t=[]),Object.getOwnPropertyNames(e).forEach((function(r){if(!S[r]&&-1===t.indexOf(r)){var i=Object.getOwnPropertyDescriptor(e,r);i.get||i.set?Object.defineProperty(n,r,i):n[r]=e[r]}}))}function E(e,n){return function(e,n){var t=n.expirations,r=e.options,i=c(r.isEqual,r.isMatchingKey),o=e;o.clear=function(){var e=o._microMemoizeOptions.onCacheChange,n=o.cache;return n.keys.length=0,n.values.length=0,e&&e(n,o.options,o),!0},o.clearStats=function(){d(o.options.profileName)},o.get=function(e){var n=o._microMemoizeOptions.transformKey,t=o.cache,r=n?n(e):e;return-1!==i(t.keys,r)?o.apply(this,e):void 0},o.getStats=function(){return z(o.options.profileName)},o.has=function(e){var n=o._microMemoizeOptions.transformKey,t=n?n(e):e;return-1!==i(o.cache.keys,t)},o.keys=function(){return o.cacheSnapshot.keys},o.remove=function(e){var n=o._microMemoizeOptions,r=n.onCacheChange,a=n.transformKey,u=o.cache,s=i(u.keys,a?a(e):e);if(-1===s)return!1;var c=u.keys[s];return u.keys.splice(s,1),u.values.splice(s,1),r&&r(u,o.options,o),l(t,c,!0),!0},o.set=function(e,n){var t=o._microMemoizeOptions,r=o.cache,a=o.options,u=t.onCacheAdd,s=t.onCacheChange,c=t.transformKey,f=c?c(e):e,l=i(r.keys,f);if(-1===l){var p=a.maxSize-1;r.size>p&&(r.keys.length=p,r.values.length=p),r.keys.unshift(f),r.values.unshift(n),a.isPromise&&r.updateAsyncCache(o),u&&u(r,a,o),s&&s(r,a,o)}else{var m=r.keys[l];r.values[l]=n,l>0&&r.orderByLru(m,n,l),a.isPromise&&r.updateAsyncCache(o),"function"==typeof s&&s(r,a,o)}},o.values=function(){return o.cacheSnapshot.values}}(e,n),function(e,n){var t=n.expirations,r=n.options,i=n.originalFunction,o=e.options;Object.defineProperties(e,{_microMemoizeOptions:{configurable:!0,get:function(){return o}},cacheSnapshot:{configurable:!0,get:function(){var n=e.cache;return{keys:n.keys.slice(0),size:n.size,values:n.values.slice(0)}}},expirations:{configurable:!0,get:function(){return t}},expirationsSnapshot:{configurable:!0,get:function(){return t.slice(0)}},isMoized:{configurable:!0,get:function(){return!0}},options:{configurable:!0,get:function(){return r}},originalFunction:{configurable:!0,get:function(){return i}}}),b(i,e)}(e,n),e}var k="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function O(e,n){for(var t=e.length,r=0;r<t;++r)if(e[r]===n)return r+1;return 0}function q(e){var n,t,r=typeof e;return!e||"object"!==r&&"function"!==r?e:JSON.stringify(e,(n=[],t=[],function(e,r){var i=typeof r;if("function"===i||"symbol"===i)return r.toString();if("object"==typeof r){if(n.length){var o=O(n,this);0===o?n[n.length]=this:(n.splice(o),t.splice(o)),t[t.length]=e;var a=O(n,r);if(0!==a)return"[ref="+(t.slice(0,a).join(".")||".")+"]"}else n[0]=r,t[0]=e;return r}return""+r}))}function K(e){for(var n="|",t=0;t<e.length;t++)n+=q(e[t])+"|";return[n]}function N(e,n){return e[0]===n[0]}function w(e){if("function"==typeof e)return function(n,t,r){return e(r.cache,r.options,r)}}function M(e){return u(e.isSerialized&&function(e){return"function"==typeof e.serializer?e.serializer:K}(e),"function"==typeof e.transformArgs&&e.transformArgs,"number"==typeof e.maxArgs&&(n=e.maxArgs,function(e){if(n>=e.length)return e;if(0===n)return[];if(1===n)return[e[0]];if(2===n)return[e[0],e[1]];if(3===n)return[e[0],e[1],e[2]];for(var t=[],r=0;r<n;r++)t[r]=e[r];return t}));var n}var j=function e(t,u){var s=u||o;if(function(e){return"function"==typeof e&&e.isMoized}(t)){var c=t.originalFunction,l=f(t.options,s);return e(c,l)}if("object"==typeof t)return function(n,r){if("function"==typeof n){var i=f(t,r);return e(n,i)}var o=f(t,n);return e(o)};if(s.isReact)return function(e,n,t){var r=e(i({maxArgs:2,isShallowEqual:!0},t,{isReact:!1}));function o(e,t,i){this.props=e,this.context=t,this.updater=i,this.MoizedComponent=r(n)}return n.displayName||(n.displayName=n.name||"Component"),o.prototype.isReactComponent={},o.prototype.render=function(){return{$$typeof:k,type:this.MoizedComponent,props:this.props,ref:null,key:null,_owner:null}},b(n,o,["contextType","contextTypes"]),o.displayName="Moized("+(n.displayName||n.name||"Component")+")",o}(e,t,s);var p=i({},o,s,{maxAge:"number"==typeof s.maxAge&&s.maxAge>=0?s.maxAge:o.maxAge,maxArgs:"number"==typeof s.maxArgs&&s.maxArgs>=0?s.maxArgs:o.maxArgs,maxSize:"number"==typeof s.maxSize&&s.maxSize>=0?s.maxSize:o.maxSize,profileName:s.profileName||C(t)}),m=[],y=(p.matchesArg,p.isDeepEqual,p.isPromise),d=(p.isReact,p.isSerialized,p.isShallowEqual,p.matchesKey,p.maxAge,p.maxArgs,p.maxSize),A=p.onCacheAdd,z=p.onCacheChange,S=p.onCacheHit,O=(p.onExpire,p.profileName,p.serializer,p.updateCacheForKey),q=(p.transformArgs,p.updateExpire,function(e,n){if(null==e)return{};var t,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)t=o[r],n.indexOf(t)>=0||(i[t]=e[t]);return i}(p,["matchesArg","isDeepEqual","isPromise","isReact","isSerialized","isShallowEqual","matchesKey","maxAge","maxArgs","maxSize","onCacheAdd","onCacheChange","onCacheHit","onExpire","profileName","serializer","updateCacheForKey","transformArgs","updateExpire"])),K=function(e){return e.matchesArg||e.isDeepEqual&&n.deepEqual||e.isShallowEqual&&n.shallowEqual||n.sameValueZeroEqual}(p),j=function(e){return e.matchesKey||e.isSerialized&&N||void 0}(p),P=h(m,p,K,j),F=function(e){return g.isCollectingStats?{onCacheAdd:v(e),onCacheHit:x(e)}:{}}(p),H=M(p),R=i({},q,{isEqual:K,isMatchingKey:j,isPromise:y,maxSize:d,onCacheAdd:w(a(A,P.onCacheAdd,F.onCacheAdd)),onCacheChange:w(z),onCacheHit:w(a(S,P.onCacheHit,F.onCacheHit)),transformKey:H}),_=E(r.default(t,R),{expirations:m,options:p,originalFunction:t});return O?function(e){var n=e.options.updateCacheForKey;function t(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];if(!n(r))return e.apply(this,r);var o=e.fn.apply(this,r);return e.set(r,o),o}return b(e,t),t}(_):_};return j.clearStats=d,j.collectStats=function(e){void 0===e&&(e=!0),g.isCollectingStats=e},j.compose=function(){return u.apply(void 0,arguments)||j},j.deep=j({isDeepEqual:!0}),j.getStats=z,j.infinite=j({maxSize:1/0}),j.isCollectingStats=function(){return g.isCollectingStats},j.isMoized=function(e){return"function"==typeof e&&!!e.isMoized},j.matchesArg=function(e){return j({matchesArg:e})},j.matchesKey=function(e){return j({matchesKey:e})},j.maxAge=function(e,n){if(!0===n)return j({maxAge:e,updateExpire:n});if("object"==typeof n){var t=n.onExpire,r=n.updateExpire;return j({maxAge:e,onExpire:t,updateExpire:r})}return j("function"==typeof n?{maxAge:e,onExpire:n,updateExpire:!0}:{maxAge:e})},j.maxArgs=function(e){return j({maxArgs:e})},j.maxSize=function(e){return j({maxSize:e})},j.profile=function(e){return j({profileName:e})},j.promise=j({isPromise:!0,updateExpire:!0}),j.react=j({isReact:!0}),j.serialize=j({isSerialized:!0}),j.serializeWith=function(e){return j({isSerialized:!0,serializer:e})},j.shallow=j({isShallowEqual:!0}),j.transformArgs=function(e){return j({transformArgs:e})},j.updateCacheForKey=function(e){return j({updateCacheForKey:e})},j}));
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("micro-memoize"),require("fast-equals")):"function"==typeof define&&define.amd?define(["micro-memoize","fast-equals"],n):(e="undefined"!=typeof globalThis?globalThis:e||self).moize=n(e.memoize,e.fe)}(this,(function(e,n){"use strict";function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=t(e);function i(){return(i=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}var o={isDeepEqual:!1,isPromise:!1,isReact:!1,isSerialized:!1,isShallowEqual:!1,matchesArg:void 0,matchesKey:void 0,maxAge:void 0,maxArgs:void 0,maxSize:1,onExpire:void 0,profileName:void 0,serializer:void 0,updateCacheForKey:void 0,transformArgs:void 0,updateExpire:!1};function a(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce((function(e,n){return"function"==typeof e?"function"==typeof n?function(){e.apply(this,arguments),n.apply(this,arguments)}:e:"function"==typeof n?n:void 0}))}function u(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return n.reduce((function(e,n){return"function"==typeof e?"function"==typeof n?function(){return e(n.apply(this,arguments))}:e:"function"==typeof n?n:void 0}))}function s(e,n){for(var t=0;t<e.length;t++)if(e[t].key===n)return t;return-1}function c(e,n){var t="function"==typeof n?n:function(n,t){for(var r=0;r<t.length;r++)if(!e(n[r],t[r]))return!1;return!0};return function(e,n){for(var r=0;r<e.length;r++)if(e[r].length===n.length&&t(e[r],n))return r;return-1}}function f(e,n){return n&&n!==o?i({},e,n,{onCacheAdd:a(e.onCacheAdd,n.onCacheAdd),onCacheChange:a(e.onCacheChange,n.onCacheChange),onCacheHit:a(e.onCacheHit,n.onCacheHit),transformArgs:u(e.transformArgs,n.transformArgs)}):e}function l(e,n,t){var r=s(e,n);-1!==r&&(clearTimeout(e[r].timeoutId),t&&e.splice(r,1))}function p(e,n){var t=setTimeout(e,n);return"function"==typeof t.unref&&t.unref(),t}function m(e,n){return function(t){var r=t.keys[0],i=s(e,r);~i&&(l(e,r,!1),e[i].timeoutId=p(e[i].expirationMethod,n.maxAge))}}function h(e,n,t,r){var i="number"==typeof n.maxAge&&isFinite(n.maxAge)?function(e,n,t,r){var i=n.maxAge;return function o(a,u,f){var m=a.keys[0];if(-1===s(e,m)){var h=function(){var i=c(t,r)(a.keys,m),s=a.values[i];~i&&(a.keys.splice(i,1),a.values.splice(i,1),"function"==typeof n.onCacheChange&&n.onCacheChange(a,u,f)),l(e,m,!0),"function"==typeof n.onExpire&&!1===n.onExpire(m)&&(a.keys.unshift(m),a.values.unshift(s),o(a,u,f),"function"==typeof n.onCacheChange&&n.onCacheChange(a,u,f))};e.push({expirationMethod:h,key:m,timeoutId:p(h,i)})}}}(e,n,t,r):void 0;return{onCacheAdd:i,onCacheHit:i&&n.updateExpire?m(e,n):void 0}}var g={anonymousProfileNameCounter:1,isCollectingStats:!1,profiles:{}},y=!1;function d(e){e?delete g.profiles[e]:g.profiles={}}function v(e){var n=e.profileName;return function(){n&&!g.profiles[n]&&(g.profiles[n]={calls:0,hits:0}),g.profiles[n].calls++}}function x(e){return function(){var n=g.profiles,t=e.profileName;n[t]||(n[t]={calls:0,hits:0}),n[t].calls++,n[t].hits++}}function C(e){var n=(new Error).stack,t=e.displayName||e.name||"Anonymous "+g.anonymousProfileNameCounter++;if(!n)return t;for(var r,i,o=n.split("\n").slice(3),a=0;a<o.length;a++)if(-1===(r=o[a]).indexOf("/moize/")&&-1===r.indexOf(" (native)")&&-1===r.indexOf(" Function.")){i=r.replace(/\n/g,"\\n").trim();break}return i?t+" "+i:t}function A(e,n){return e?(n/e*100).toFixed(4)+"%":"0.0000%"}function z(e){g.isCollectingStats||y||(console.warn('Stats are not currently being collected, please run "collectStats" to enable them.'),y=!0);var n=g.profiles;if(e){if(!n[e])return{calls:0,hits:0,usage:"0.0000%"};var t=n[e];return i({},t,{usage:A(t.calls,t.hits)})}var r=Object.keys(g.profiles).reduce((function(e,t){return e.calls+=n[t].calls,e.hits+=n[t].hits,e}),{calls:0,hits:0});return i({},r,{profiles:Object.keys(n).reduce((function(e,n){return e[n]=z(n),e}),{}),usage:A(r.calls,r.hits)})}var S={arguments:!0,callee:!0,caller:!0,constructor:!0,length:!0,name:!0,prototype:!0};function b(e,n,t){void 0===t&&(t=[]),Object.getOwnPropertyNames(e).forEach((function(r){if(!S[r]&&-1===t.indexOf(r)){var i=Object.getOwnPropertyDescriptor(e,r);i.get||i.set?Object.defineProperty(n,r,i):n[r]=e[r]}}))}function E(e,n){return function(e,n){var t=n.expirations,r=e.options,i=c(r.isEqual,r.isMatchingKey),o=e;o.clear=function(){var e=o._microMemoizeOptions.onCacheChange,n=o.cache;return n.keys.length=0,n.values.length=0,e&&e(n,o.options,o),!0},o.clearStats=function(){d(o.options.profileName)},o.get=function(e){var n=o._microMemoizeOptions.transformKey,t=o.cache,r=n?n(e):e;return-1!==i(t.keys,r)?o.apply(this,e):void 0},o.getStats=function(){return z(o.options.profileName)},o.has=function(e){var n=o._microMemoizeOptions.transformKey,t=n?n(e):e;return-1!==i(o.cache.keys,t)},o.keys=function(){return o.cacheSnapshot.keys},o.remove=function(e){var n=o._microMemoizeOptions,r=n.onCacheChange,a=n.transformKey,u=o.cache,s=i(u.keys,a?a(e):e);if(-1===s)return!1;var c=u.keys[s];return u.keys.splice(s,1),u.values.splice(s,1),r&&r(u,o.options,o),l(t,c,!0),!0},o.set=function(e,n){var t=o._microMemoizeOptions,r=o.cache,a=o.options,u=t.onCacheAdd,s=t.onCacheChange,c=t.transformKey,f=c?c(e):e,l=i(r.keys,f);if(-1===l){var p=a.maxSize-1;r.size>p&&(r.keys.length=p,r.values.length=p),r.keys.unshift(f),r.values.unshift(n),a.isPromise&&r.updateAsyncCache(o),u&&u(r,a,o),s&&s(r,a,o)}else{var m=r.keys[l];r.values[l]=n,l>0&&r.orderByLru(m,n,l),a.isPromise&&r.updateAsyncCache(o),"function"==typeof s&&s(r,a,o)}},o.values=function(){return o.cacheSnapshot.values}}(e,n),function(e,n){var t=n.expirations,r=n.options,i=n.originalFunction,o=e.options;Object.defineProperties(e,{_microMemoizeOptions:{configurable:!0,get:function(){return o}},cacheSnapshot:{configurable:!0,get:function(){var n=e.cache;return{keys:n.keys.slice(0),size:n.size,values:n.values.slice(0)}}},expirations:{configurable:!0,get:function(){return t}},expirationsSnapshot:{configurable:!0,get:function(){return t.slice(0)}},isMoized:{configurable:!0,get:function(){return!0}},options:{configurable:!0,get:function(){return r}},originalFunction:{configurable:!0,get:function(){return i}}}),b(i,e)}(e,n),e}var k="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function O(e,n){for(var t=e.length,r=0;r<t;++r)if(e[r]===n)return r+1;return 0}function q(e){var n,t,r=typeof e;return!e||"object"!==r&&"function"!==r?e:JSON.stringify(e,(n=[],t=[],function(e,r){var i=typeof r;if("function"===i||"symbol"===i)return r.toString();if("object"==typeof r){if(n.length){var o=O(n,this);0===o?n[n.length]=this:(n.splice(o),t.splice(o)),t[t.length]=e;var a=O(n,r);if(0!==a)return"[ref="+(t.slice(0,a).join(".")||".")+"]"}else n[0]=r,t[0]=e;return r}return""+r}))}function K(e){for(var n="|",t=0;t<e.length;t++)n+=q(e[t])+"|";return[n]}function N(e,n){return e[0]===n[0]}function w(e){if("function"==typeof e)return function(n,t,r){return e(r.cache,r.options,r)}}function M(e){return u(e.isSerialized&&function(e){return"function"==typeof e.serializer?e.serializer:K}(e),"function"==typeof e.transformArgs&&e.transformArgs,"number"==typeof e.maxArgs&&(n=e.maxArgs,function(e){if(n>=e.length)return e;if(0===n)return[];if(1===n)return[e[0]];if(2===n)return[e[0],e[1]];if(3===n)return[e[0],e[1],e[2]];for(var t=[],r=0;r<n;r++)t[r]=e[r];return t}));var n}var j=function e(t,u){var s=u||o;if(function(e){return"function"==typeof e&&e.isMoized}(t)){var c=t.originalFunction,l=f(t.options,s);return e(c,l)}if("object"==typeof t)return function(n,r){if("function"==typeof n){var i=f(t,r);return e(n,i)}var o=f(t,n);return e(o)};if(s.isReact)return function(e,n,t){var r=e(i({maxArgs:2,isShallowEqual:!0},t,{isReact:!1}));function o(e,t,i){this.props=e,this.context=t,this.updater=i,this.MoizedComponent=r(n)}return n.displayName||(n.displayName=n.name||"Component"),o.prototype.isReactComponent={},o.prototype.render=function(){return{$$typeof:k,type:this.MoizedComponent,props:this.props,ref:null,key:null,_owner:null}},b(n,o,["contextType","contextTypes"]),o.displayName="Moized("+(n.displayName||n.name||"Component")+")",o}(e,t,s);var p=i({},o,s,{maxAge:"number"==typeof s.maxAge&&s.maxAge>=0?s.maxAge:o.maxAge,maxArgs:"number"==typeof s.maxArgs&&s.maxArgs>=0?s.maxArgs:o.maxArgs,maxSize:"number"==typeof s.maxSize&&s.maxSize>=0?s.maxSize:o.maxSize,profileName:s.profileName||C(t)}),m=[],y=(p.matchesArg,p.isDeepEqual,p.isPromise),d=(p.isReact,p.isSerialized,p.isShallowEqual,p.matchesKey,p.maxAge,p.maxArgs,p.maxSize),A=p.onCacheAdd,z=p.onCacheChange,S=p.onCacheHit,O=(p.onExpire,p.profileName,p.serializer,p.updateCacheForKey),q=(p.transformArgs,p.updateExpire,function(e,n){if(null==e)return{};var t,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)t=o[r],n.indexOf(t)>=0||(i[t]=e[t]);return i}(p,["matchesArg","isDeepEqual","isPromise","isReact","isSerialized","isShallowEqual","matchesKey","maxAge","maxArgs","maxSize","onCacheAdd","onCacheChange","onCacheHit","onExpire","profileName","serializer","updateCacheForKey","transformArgs","updateExpire"])),K=function(e){return e.matchesArg||e.isDeepEqual&&n.deepEqual||e.isShallowEqual&&n.shallowEqual||n.sameValueZeroEqual}(p),j=function(e){return e.matchesKey||e.isSerialized&&N||void 0}(p),P=h(m,p,K,j),F=function(e){return g.isCollectingStats?{onCacheAdd:v(e),onCacheHit:x(e)}:{}}(p),H=M(p),R=i({},q,{isEqual:K,isMatchingKey:j,isPromise:y,maxSize:d,onCacheAdd:w(a(A,P.onCacheAdd,F.onCacheAdd)),onCacheChange:w(z),onCacheHit:w(a(S,P.onCacheHit,F.onCacheHit)),transformKey:H}),_=E(r.default(t,R),{expirations:m,options:p,originalFunction:t});return O?function(e){var n=e.options.updateCacheForKey;function t(){for(var t=arguments.length,r=new Array(t),i=0;i<t;i++)r[i]=arguments[i];if(!n(r))return e.apply(this,r);var o=e.fn.apply(this,r);return e.set(r,o),o}return b(e,t),t}(_):_};return j.clearStats=d,j.collectStats=function(e){void 0===e&&(e=!0),g.isCollectingStats=e},j.compose=function(){return u.apply(void 0,arguments)||j},j.deep=j({isDeepEqual:!0}),j.getStats=z,j.infinite=j({maxSize:1/0}),j.isCollectingStats=function(){return g.isCollectingStats},j.isMoized=function(e){return"function"==typeof e&&!!e.isMoized},j.matchesArg=function(e){return j({matchesArg:e})},j.matchesKey=function(e){return j({matchesKey:e})},j.maxAge=function(e,n){if(!0===n)return j({maxAge:e,updateExpire:n});if("object"==typeof n){var t=n.onExpire,r=n.updateExpire;return j({maxAge:e,onExpire:t,updateExpire:r})}return j("function"==typeof n?{maxAge:e,onExpire:n,updateExpire:!0}:{maxAge:e})},j.maxArgs=function(e){return j({maxArgs:e})},j.maxSize=function(e){return j({maxSize:e})},j.profile=function(e){return j({profileName:e})},j.promise=j({isPromise:!0,updateExpire:!0}),j.react=j({isReact:!0}),j.serialize=j({isSerialized:!0}),j.serializeWith=function(e){return j({isSerialized:!0,serializer:e})},j.shallow=j({isShallowEqual:!0}),j.transformArgs=function(e){return j({transformArgs:e})},j.updateCacheForKey=function(e){return j({updateCacheForKey:e})},j}));
//# sourceMappingURL=moize.min.js.map

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

"types": "./index.d.ts",
"version": "6.0.0"
"version": "6.0.1"
}

@@ -9,4 +9,2 @@ > moize

**NOTE**: This documentation is for the next major version of `moize`, please go to the [`v5` branch](https://github.com/planttheidea/moize/tree/v5) to see documentation on the current major version. To learn about changes that may impact your code when migrating to v6, please see the [changelog](CHANGELOG.md#600).
- [Importing](#importing)

@@ -80,3 +78,3 @@ - [ESM in browsers](#esm-in-browsers)

```
$ npm i moize@next --save
$ npm i moize --save
```

@@ -83,0 +81,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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