memoizerific
Advanced tools
Comparing version 1.8.6 to 1.9.0
(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){ | ||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var i;i="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,i.mapOrSimilar=t()}}(function(){var t,i,e;return function t(i,e,s){function n(o,l){if(!e[o]){if(!i[o]){var a="function"==typeof _dereq_&&_dereq_;if(!l&&a)return a(o,!0);if(r)return r(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var h=e[o]={exports:{}};i[o][0].call(h.exports,function(t){var e=i[o][1][t];return n(e?e:t)},h,h.exports,t,i,e,s)}return e[o].exports}for(var r="function"==typeof _dereq_&&_dereq_,o=0;o<s.length;o++)n(s[o]);return n}({1:[function(t,i,e){i.exports=function(i){if("function"!=typeof Map||i){var e=t("./similar");return new e}return new Map}},{"./similar":2}],2:[function(t,i,e){function s(){return this.list=[],this.lastItem=void 0,this.size=0,this}s.prototype.get=function(t){var i;return this.lastItem&&this.isEqual(this.lastItem.key,t)?this.lastItem.val:(i=this.indexOf(t),i>=0?(this.lastItem=this.list[i],this.list[i].val):void 0)},s.prototype.set=function(t,i){var e;return this.lastItem&&this.isEqual(this.lastItem.key,t)?(this.lastItem.val=i,this):(e=this.indexOf(t),e>=0?(this.lastItem=this.list[e],this.list[e].val=i,this):(this.lastItem={key:t,val:i},this.list.push(this.lastItem),this.size++,this))},s.prototype.delete=function(t){var i;if(this.lastItem&&this.isEqual(this.lastItem.key,t)&&(this.lastItem=void 0),i=this.indexOf(t),i>=0)return this.size--,this.list.splice(i,1)[0]},s.prototype.has=function(t){var i;return!(!this.lastItem||!this.isEqual(this.lastItem.key,t))||(i=this.indexOf(t),i>=0&&(this.lastItem=this.list[i],!0))},s.prototype.forEach=function(t,i){var e;for(e=0;e<this.size;e++)t.call(i||this,this.list[e].val,this.list[e].key,this)},s.prototype.indexOf=function(t){var i;for(i=0;i<this.size;i++)if(this.isEqual(this.list[i].key,t))return i;return-1},s.prototype.isEqual=function(t,i){return t===i||t!==t&&i!==i},i.exports=s},{}]},{},[1])(1)}); | ||
module.exports = function(forceSimilar) { | ||
if (typeof Map !== 'function' || forceSimilar) { | ||
var Similar = _dereq_('./similar'); | ||
return new Similar(); | ||
} | ||
else { | ||
return new Map(); | ||
} | ||
} | ||
},{}],2:[function(_dereq_,module,exports){ | ||
},{"./similar":2}],2:[function(_dereq_,module,exports){ | ||
function Similar() { | ||
this.list = []; | ||
this.lastItem = undefined; | ||
this.size = 0; | ||
return this; | ||
} | ||
Similar.prototype.get = function(key) { | ||
var index; | ||
if (this.lastItem && this.isEqual(this.lastItem.key, key)) { | ||
return this.lastItem.val; | ||
} | ||
index = this.indexOf(key); | ||
if (index >= 0) { | ||
this.lastItem = this.list[index]; | ||
return this.list[index].val; | ||
} | ||
return undefined; | ||
}; | ||
Similar.prototype.set = function(key, val) { | ||
var index; | ||
if (this.lastItem && this.isEqual(this.lastItem.key, key)) { | ||
this.lastItem.val = val; | ||
return this; | ||
} | ||
index = this.indexOf(key); | ||
if (index >= 0) { | ||
this.lastItem = this.list[index]; | ||
this.list[index].val = val; | ||
return this; | ||
} | ||
this.lastItem = { key: key, val: val }; | ||
this.list.push(this.lastItem); | ||
this.size++; | ||
return this; | ||
}; | ||
Similar.prototype.delete = function(key) { | ||
var index; | ||
if (this.lastItem && this.isEqual(this.lastItem.key, key)) { | ||
this.lastItem = undefined; | ||
} | ||
index = this.indexOf(key); | ||
if (index >= 0) { | ||
this.size--; | ||
return this.list.splice(index, 1)[0]; | ||
} | ||
return undefined; | ||
}; | ||
// important that has() doesn't use get() in case an existing key has a falsy value, in which case has() would return false | ||
Similar.prototype.has = function(key) { | ||
var index; | ||
if (this.lastItem && this.isEqual(this.lastItem.key, key)) { | ||
return true; | ||
} | ||
index = this.indexOf(key); | ||
if (index >= 0) { | ||
this.lastItem = this.list[index]; | ||
return true; | ||
} | ||
return false; | ||
}; | ||
Similar.prototype.forEach = function(callback, thisArg) { | ||
var i; | ||
for (i = 0; i < this.size; i++) { | ||
callback.call(thisArg || this, this.list[i].val, this.list[i].key, this); | ||
} | ||
}; | ||
Similar.prototype.indexOf = function(key) { | ||
var i; | ||
for (i = 0; i < this.size; i++) { | ||
if (this.isEqual(this.list[i].key, key)) { | ||
return i; | ||
} | ||
} | ||
return -1; | ||
}; | ||
// check if the numbers are equal, or whether they are both precisely NaN (isNaN returns true for all non-numbers) | ||
Similar.prototype.isEqual = function(val1, val2) { | ||
return val1 === val2 || (val1 !== val1 && val2 !== val2); | ||
}; | ||
module.exports = Similar; | ||
},{}],3:[function(_dereq_,module,exports){ | ||
var MapOrSimilar = _dereq_('map-or-similar'); | ||
@@ -144,3 +256,3 @@ | ||
} | ||
},{"map-or-similar":1}]},{},[2])(2) | ||
},{"map-or-similar":1}]},{},[3])(3) | ||
}); |
@@ -1,8 +0,6 @@ | ||
� ��JX�WM��6��W�>8$L���e�������0�L��H�BR�lm��EI�lm���� ����p<K+�X�$��(R4W���)��%Wi���J[�X�+y�0�uu�r��#lU�E8�ၳ��?[�V�Yq�~�v{b���W�s:��Iȃz��G4���o�cR��<ݺ��f��P�/�E*�A]�܄c '"��VZݷ�"����D"E�̙ة�_�f��0:���_*��v�=�b�p돁��;��d��9���)��Zi4��I�l )�o�K������fZ=U��������_�>�v�ǧ��?��~N���˩��ۚFǺ�]��>LX���+72�m�Q��wv��%�؊���伳A��[-��X���3g� ^D�u�nu�s�h�X-�X"�@�C��q��h۲�����/�� ϿOx�X؆��1�.c�1\�+���9�.�)�$)����y�w��z�2����ʳ�-U�� | ||
��V�L�2��WY�Y����auF]�cV��{Vg/���Fq�j���7��H6`�ǫc�sy�j�F$&���cr | ||
L6H:p{�Ln�>��%�{O=9>��t��y�h�h<3��Ћz�����M�'7ס�L���ւca�c�k��3���U�C��BM��u��R+�\��#���&��vkN�{��K�r4�~��p�l�¯p��~��o�)� �-]o��i�ŎwY�gG> �0t3 | ||
�t�����U��7����,�w��,�~ll���#KX�>� | ||
��dcU|.�r�]@r�9�|��@���b������(��B\�ɘ2 ��a��)��Θy��34q:�^ �N/��*���;^� ]�%�$�\��S�m�q,��X�������,��]�~۰'Pq^��|�Ȁ���qi�PK[����©�z�lWUJ�KiM�)<���Ψ��{�C��c��5nD�t�3�Զ���%�-%������!�@�N �l��t�4swd݈�ӏ�������4g�kГ�/�3ֱSyv�z0s��T�����]F�P�$� ���K$嫛Xz�}vѡ>��Ny��ܺ))��j�_�[&��/E��`LY)�:_G�Z�����m����r9����� ����T0�f¬ | ||
.�iQ[mHB�i͞Q���+_��JCY���9�@� | ||
�_C*n��F�ˇ���><�LU�!`�{6�ܑ���l ��< |