UNPKG

trie-memoize

Version:

A memoization algorithm in which each function argument represents a new key, creating a trie of caches as defined by the array in your first argument.

3 lines (2 loc) 938 B
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t=t||self).trieMemoize=e()}(this,(function(){"use strict";var t=function(t){try{return new t}catch(t){var e={};return{set:function(t,n){e[t]=n},get:function(t){return e[t]}}}};return function(e,n){var r,o,u,i,f,c,s,d,g,v=(s=(o=e).length,d=t(o[0]),g=1===s,3>s?{g:function(t){return void 0===(u=d.get(t[0]))||g?u:u.get(t[1])},s:function(e,n){return g?d.set(e[0],n):void 0===(u=d.get(e[0]))?((i=t(o[1])).set(e[1],n),d.set(e[0],i)):u.set(e[1],n),n}}:{g:function(t){for(c=d,f=0;s>f;f++)if(void 0===(c=c.get(t[f])))return;return c},s:function(e,n){for(c=d,f=0;s-1>f;f++)void 0===(i=c.get(e[f]))?(i=t(o[f+1]),c.set(e[f],i),c=i):c=i;return c.set(e[s-1],n),n}}),l=v.g,p=v.s;return function(){return void 0===(r=l(arguments))?p(arguments,n.apply(null,arguments)):r}}})); //# sourceMappingURL=trie-memoize.js.map