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

memoizerific

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

memoizerific - npm Package Compare versions

Comparing version 1.4.0 to 1.5.0

tests/complex-args.js

2

memoizerific.js

@@ -170,2 +170,4 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.memoizerific = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(_dereq_,module,exports){

memoizerific.limit = limit;
memoizerific.wasMemoized = false;
memoizerific.cache = cache;

@@ -172,0 +174,0 @@ memoizerific.lru = lru;

14

memoizerific.min.gzip.js

@@ -1,7 +0,7 @@

�e��V�V[o�6~߯����0��ɛT�� �4C�>B��Tĕ�4�J����;�͖���bQG������T��BoE����O[�R�Z�<��E���L�Rmx"�x��c�oJ�q��[Uj�4|��:�=b�2�4O�e��:"���}fz�CN�Y}j����GpN�I�L���Y �e�r?�M�!��x��\�D�΃�B}hpM�ND��-�u�F����%1����5���O��gb��_�����;�dR��^ ��9vr��T+s� U�et�u���S*�#pyӦh�Λ����áMu�2J�8�@xo�>|�x����������>x$����;ݶ9 �U:��ȏ��Hv�&��
Z+.����pi$V"��"��o���U��3�}�����/��<d�/�z�iȦS��qA�)Th��{��8����ڸe�nW�<��=�\=CX]r�A�������۫?�>����x�yu� �����L{8�#�| .��\����@������0����_��7�g�9�Ѽ(hڜ+�e�;�'n�q�x8�n�&��������v5�>C�!Nk!��~�,�K:_�!����w̛���=��!]3�Kx[f��0:aLymH�0o2��E4^ڂ�� ^�o�Eiҡ*ާl:m��°�[�s��Lйr�\��=Gj6;�o
)b�o�a ti�M���"��WU�H Ƌ��g�9]����!�ä�g˪��+�EE�]m����/�l�} S�,b((�jZ
h��
��:���y=�̒�3Α\���M��ƴ��������[Z7Ǯ���6�����B�gD�|���!�f&` �)����%��Y�)�]�����i�E�a�t�c�ۍ��Ü���?�V�*�q��b��Y?S�}�O�[/E�����F����њ/��XS)�eƕ���lA2z�5{E�t�I�Q��( '� �I�.`q�~%����)]{�C^���c3��,H�zR�a8� &%M�5C؏�S@�'� 88��!I�ϊB�"UJIz5|b3���0��.����l
��+��p ��Y'ڐ.a"�j2�H�O��� 3�͟� ���:��6 =�/uIɫ��У�U�ڐ�/#�.q��_��Fq�
��V�V[o�6~߯����0��ɛT�� �4C�>B��T�U"5�J����;�͖���bQG�����㤔�J"��"A�z���֣Ծ\%#��Pښ��+�'B�7�>�jSf7�U��g��^��GlP&���|��#ZG�6W��L�x��9�/Bn�˪y�4�2�ȲU�8�ax���O`Sa�s�+�k���yPU� ��X‰5�������"����D#FṮX��9���`Jz&&��U
Ai���&���Jϱ��N&[�CM��/�k��F�oLJeG��M��7eSC�j�2J�Xm ��w�~�~�tw�����O<�T/��;ݶ9 �U:��ȏY���K79� wU�Zq�mԅK#������fQ�]�j9���*O��7�"��C����O6 �t�52.�=�
m�z����=x_����
�bn��ۃ��34��%�@��_�������ۛ�W�W��������i�`�"ۃ��E��S�}]���W�~&���e�f��9}Vb3�7BM�se|�l�s��g���n2����+8oWC�34�B���w �����뙯yǼyq 8h�C��5���e���Ɣ��q�� s�&sq�\DC��-�,q����_�&��}ʦ��( �q�.q� :W.�����H�f�M�����[`]چtSf~�����UU0���(x-�Fn�@���}�k)�0i�ٲ�o��lQ�}W�ih��7�x_�Զ�ʻ�&����Zb)C t�N��x^�:�d��s$�2rs��1�G�;¨��E��9�V���ͱ+�.��Mau�������5�-"b��� Xq��t5u "g�h�g��$A��{n�C}�>����v�&�0�g3���U�
`�欘)=�gj���Ir�(��::^܈5:���z9�5�R�[�\�n��$�WZ�W�N��.E�r�.������g�GP
z0�Z�ҵ:��UI�:6i��ʂ$�'�� �`RҤ_s1��=����Gv;�Q波�^�,���j��f� øZ� �����)8� $ǁh�f�hC����ɤ"�?]��fn�?c���<SЊ����@xTS6�9P�%DU�[�G�,��u(Y_F]�
��� ��+

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

!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.memoizerific=t()}}(function(){var t,e,i;return function t(e,i,s){function r(a,o){if(!i[a]){if(!e[a]){var u="function"==typeof require&&require;if(!o&&u)return u(a,!0);if(n)return n(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var l=i[a]={exports:{}};e[a][0].call(l.exports,function(t){var i=e[a][1][t];return r(i?i:t)},l,l.exports,t,e,i,s)}return i[a].exports}for(var n="function"==typeof require&&require,a=0;a<s.length;a++)r(s[a]);return r}({1:[function(t,e,i){"function"!=typeof Map||process&&process.env&&"true"===process.env.TEST_MAPORSIMILAR?e.exports=t("./similar"):e.exports=Map},{"./similar":2}],2:[function(t,e,i){function s(){return this.list=[],this.lastItem=void 0,this.size=0,this}s.prototype.get=function(t){var e;return this.lastItem&&this.lastItem.key===t?this.lastItem.val:(e=this.indexOf(t),e>=0?(this.lastItem=this.list[e],this.list[e].val):void 0)},s.prototype.set=function(t,e){var i;return this.lastItem&&this.lastItem.key===t?(this.lastItem.val=e,this):(i=this.indexOf(t),i>=0?(this.lastItem=this.list[i],this.list[i].val=e,this):(this.lastItem={key:t,val:e},this.list.push(this.lastItem),this.size++,this))},s.prototype.delete=function(t){var e;return this.lastItem&&this.lastItem.key===t&&(this.lastItem=void 0),e=this.indexOf(t),e>=0?(this.size--,this.list.splice(e,1)[0]):void 0},s.prototype.has=function(t){var e;return this.lastItem&&this.lastItem.key===t?!0:(e=this.indexOf(t),e>=0?(this.lastItem=this.list[e],!0):!1)},s.prototype.indexOf=function(t){var e;for(e=0;e<this.size;e++)if(this.list[e].key===t)return e;return-1},e.exports=s},{}],3:[function(t,e,i){function s(t,e){var i=t.length,s=e.length,r,n,a;for(n=0;i>n;n++){for(r=!0,a=0;s>a;a++)if(t[n][a].arg!==e[a].arg){r=!1;break}if(r)break}t.push(t.splice(n,1)[0])}function r(t){var e=t.length,i=t[e-1],s,r;for(i.cacheItem.delete(i.arg),r=e-2;r>=0&&(i=t[r],s=i.cacheItem.get(i.arg),!s||!s.size);r--)i.cacheItem.delete(i.arg)}var n=t("map-or-similar");e.exports=function(t){var e=new n,i=[];return function(a){var o=function(){var u=e,f,l,h=arguments.length-1,m=Array(h+1),c=!0,p;for(p=0;h>p;p++)m[p]={cacheItem:u,arg:arguments[p]},u.has(arguments[p])?u=u.get(arguments[p]):(c=!1,f=new n,u.set(arguments[p],f),u=f);return c&&(u.has(arguments[h])?l=u.get(arguments[h]):c=!1),c||(l=a.apply(null,arguments),u.set(arguments[h],l)),t>0&&(m[h]={cacheItem:u,arg:arguments[h]},c?s(i,m):i.push(m),i.length>t&&r(i.shift())),o.wasMemoized=c,l};return o.cache=e,o.lru=i,o}}},{"map-or-similar":1}]},{},[3])(3)});
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.memoizerific=t()}}(function(){var t,e,i;return function t(e,i,s){function r(a,o){if(!i[a]){if(!e[a]){var u="function"==typeof require&&require;if(!o&&u)return u(a,!0);if(n)return n(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var l=i[a]={exports:{}};e[a][0].call(l.exports,function(t){var i=e[a][1][t];return r(i?i:t)},l,l.exports,t,e,i,s)}return i[a].exports}for(var n="function"==typeof require&&require,a=0;a<s.length;a++)r(s[a]);return r}({1:[function(t,e,i){"function"!=typeof Map||process&&process.env&&"true"===process.env.TEST_MAPORSIMILAR?e.exports=t("./similar"):e.exports=Map},{"./similar":2}],2:[function(t,e,i){function s(){return this.list=[],this.lastItem=void 0,this.size=0,this}s.prototype.get=function(t){var e;return this.lastItem&&this.lastItem.key===t?this.lastItem.val:(e=this.indexOf(t),e>=0?(this.lastItem=this.list[e],this.list[e].val):void 0)},s.prototype.set=function(t,e){var i;return this.lastItem&&this.lastItem.key===t?(this.lastItem.val=e,this):(i=this.indexOf(t),i>=0?(this.lastItem=this.list[i],this.list[i].val=e,this):(this.lastItem={key:t,val:e},this.list.push(this.lastItem),this.size++,this))},s.prototype.delete=function(t){var e;return this.lastItem&&this.lastItem.key===t&&(this.lastItem=void 0),e=this.indexOf(t),e>=0?(this.size--,this.list.splice(e,1)[0]):void 0},s.prototype.has=function(t){var e;return this.lastItem&&this.lastItem.key===t?!0:(e=this.indexOf(t),e>=0?(this.lastItem=this.list[e],!0):!1)},s.prototype.indexOf=function(t){var e;for(e=0;e<this.size;e++)if(this.list[e].key===t)return e;return-1},e.exports=s},{}],3:[function(t,e,i){function s(t,e){var i=t.length,s=e.length,r,n,a;for(n=0;i>n;n++){for(r=!0,a=0;s>a;a++)if(t[n][a].arg!==e[a].arg){r=!1;break}if(r)break}t.push(t.splice(n,1)[0])}function r(t){var e=t.length,i=t[e-1],s,r;for(i.cacheItem.delete(i.arg),r=e-2;r>=0&&(i=t[r],s=i.cacheItem.get(i.arg),!s||!s.size);r--)i.cacheItem.delete(i.arg)}var n=t("map-or-similar");e.exports=function(t){var e=new n,i=[];return function(a){var o=function(){var u=e,f,l,h=arguments.length-1,m=Array(h+1),c=!0,p;for(p=0;h>p;p++)m[p]={cacheItem:u,arg:arguments[p]},u.has(arguments[p])?u=u.get(arguments[p]):(c=!1,f=new n,u.set(arguments[p],f),u=f);return c&&(u.has(arguments[h])?l=u.get(arguments[h]):c=!1),c||(l=a.apply(null,arguments),u.set(arguments[h],l)),t>0&&(m[h]={cacheItem:u,arg:arguments[h]},c?s(i,m):i.push(m),i.length>t&&r(i.shift())),o.wasMemoized=c,l};return o.limit=t,o.wasMemoized=!1,o.cache=e,o.lru=i,o}}},{"map-or-similar":1}]},{},[3])(3)});
{
"name": "memoizerific",
"version": "1.4.0",
"version": "1.5.1",
"description": "Fastest, smallest, most-efficient JavaScript memoization lib to memoize JS functions",

@@ -17,3 +17,6 @@ "author": "@thinkloop",

"scripts": {
"prebuild": "npm run test",
"test": "npm run -s test:map && npm run -s test:similar",
"test:map": "TEST_MAPORSIMILAR=false JASMINE_CONFIG_PATH=jasmine.json jasmine",
"test:similar": "TEST_MAPORSIMILAR=true JASMINE_CONFIG_PATH=jasmine.json jasmine",
"prebuild": "npm run -s test",
"build": "npm run -s build:browserify | tee memoizerific.js | npm run -s build:minify | tee memoizerific.min.js | npm run -s build:gzip > memoizerific.min.gzip.js",

@@ -23,5 +26,3 @@ "build:browserify": "browserify src/memoizerific.js --detectGlobals false --standalone memoizerific | derequire",

"build:gzip": "gzip --best -v -c",
"test": "npm run test:map && npm run test:similar",
"test:map": "TEST_MAPORSIMILAR=false JASMINE_CONFIG_PATH=jasmine.json jasmine",
"test:similar": "TEST_MAPORSIMILAR=true JASMINE_CONFIG_PATH=jasmine.json jasmine"
"prepublish": "npm run build && git add --all && git commit -m 'build & publish' && npm version patch && git push && git push --tags"
},

@@ -36,3 +37,4 @@ "keywords": [

"lru",
"cache"
"cache",
"fast"
],

@@ -39,0 +41,0 @@ "dependencies": {

@@ -10,8 +10,17 @@ # Memoizerific.js

without re-running the function when it is called again with the same arguments.
This has become especially useful with the rise of [redux-philosophy](https://github.com/rackt/redux),
and the push to calculate all derived data on the fly, while maintaining the minimum state possible.
## Install
```javascript
```
npm install memoizerific --save
```
Or use one of the compiled distributions compatible in any environment (umd):
- [memoizerific.js](https://raw.githubusercontent.com/thinkloop/memoizerific/master/memoizerific.js)
- [memoizerific.min.js](https://raw.githubusercontent.com/thinkloop/memoizerific/master/memoizerific.min.js) (minified)
- [memoizerific.min.gzip.js](https://github.com/thinkloop/memoizerific/raw/master/memoizerific.min.gzip.js) (minified + gzipped)
## Use

@@ -25,8 +34,18 @@ ```javascript

myExpensiveFunction(1, 2, 3); // damn, that took looooong to process
myExpensiveFunction(1, 2, 3); // wow, that one was instant!
myExpensiveFunction(2, 3, 4); // expensive again :(
myExpensiveFunction(2, 3, 4); // woah, this one was dirt cheap, I'll take 2!
myExpensiveFunctionMemoized(1, 2, 3); // that took looooong to process
myExpensiveFunctionMemoized(1, 2, 3); // wow, that one was instant!
myExpensiveFunctionMemoized(2, 3, 4); // expensive again :(
myExpensiveFunctionMemoized(2, 3, 4); // woah, this one was dirt cheap, I'll take 2!
```
Or with complex arguments:
```javascript
var complexArg1 = { a: { b: { c: 99 }}},
complexArg2 = [{ z: 1}, { q: [{ x: 3 }]}],
complexArg3 = new Map([['d', 55],['e', 66]]),
complexArg4 = new Set();
myExpensiveFunctionMemoized(complexArg1, complexArg2, complexArg3, complexArg4); // slow
myExpensiveFunctionMemoized(complexArg1, complexArg2, complexArg3, complexArg4); // instant!
```
## Options

@@ -59,2 +78,19 @@ There is one option available:

## Internals
The internals of the memoized function are available for introspection.
They should not be manipulated directly, but can be useful to read.
The following properties are available:
```Slim
memoizedFn.limit : The cache limit that was passed in. This will never change.
memoizedFn.wasMemoized : Returns true if the last invocation was a cache hit, otherwise false.
memoizedFn.cache : The cache object that stores all the memoized results.
memoizedFn.lru : The lru object that stores the most recent arguments called.
```
Given a memoized function:
```Javascript
var memoizedFn = memoizerific(20)(function(arg1) {});
```
## Comparison

@@ -145,2 +181,6 @@ There are many memoization libs available for JavaScript. Some of them have specialized use-cases, such as memoizing file-system access, or server async requests.

Memoizerific was the performance winner. It is built with complex real-world use in mind.
I would, of course, recommend it for serious production use.
I would, of course, recommend it for serious production use.
## License
Released under an MIT license.

@@ -70,2 +70,4 @@ var MapOrSimilar = require('map-or-similar');

memoizerific.limit = limit;
memoizerific.wasMemoized = false;
memoizerific.cache = cache;

@@ -72,0 +74,0 @@ memoizerific.lru = lru;

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