Comparing version 1.1.0 to 1.2.0
@@ -1,2 +0,2 @@ | ||
!function(t,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define("iteratez",[],r):"object"==typeof exports?exports.iteratez=r():t.iteratez=r()}(this,function(){return function(t){var r={};function n(e){if(r[e])return r[e].exports;var o=r[e]={i:e,l:!1,exports:{}};return t[e].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=r,n.d=function(t,r,e){n.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:e})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,r){if(1&r&&(t=n(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var e=Object.create(null);if(n.r(e),Object.defineProperty(e,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var o in t)n.d(e,o,function(r){return t[r]}.bind(null,o));return e},n.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(r,"a",r),r},n.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},n.p="",n(n.s=3)}([function(t,r,n){"use strict";n.d(r,"a",function(){return i}),n.d(r,"j",function(){return u}),n.d(r,"i",function(){return c}),n.d(r,"b",function(){return a}),n.d(r,"d",function(){return f}),n.d(r,"c",function(){return s}),n.d(r,"g",function(){return p}),n.d(r,"h",function(){return h}),n.d(r,"e",function(){return l}),n.d(r,"f",function(){return v});var e=n(1),o=function(t){var r="function"==typeof Symbol&&t[Symbol.iterator],n=0;return r?r.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}},i=[function(t){return t instanceof e.a&&t},function(t){return!!Array.isArray(t)&&e.a.array(t)},function(t){return t instanceof Set&&e.a.set(t)},function(t){return t instanceof Map&&e.a.map(t)},function(t){return!(!t||!t[Symbol.iterator])&&e.a.iterable(t)},function(t){return!(!t||!t.entries)&&e.a.hasEntries(t)},function(t){return null==t&&e.a.empty()},function(t){return"object"==typeof t&&e.a.object(t)},function(t){return e.a.array([t])}];function u(t){var r,n;try{for(var e=o(i),u=e.next();!u.done;u=e.next()){var c=(0,u.value)(t);if(!1!==c)return c}}catch(t){r={error:t}}finally{try{u&&!u.done&&(n=e.return)&&n.call(e)}finally{if(r)throw r.error}}}function c(t){return"function"==typeof t}function a(t,r,n,e,o,i){var u=!o(n),c=!o(e);return u!==c?(r?u:c)?-1:1:u?0:t?i(n,e):i(e,n)}function f(t,r,n,e){var o=!n(t);return o===!n(r)&&(!!o||e(t,r))}function s(t,r,n){void 0===n&&(n=!1);var e=null==t;if(e!==(null==r))return e?1:-1;if(e)return 0;var o=typeof t;if(o!==typeof r){if(n)return-1;throw new Error("You must implement your own comparator for unknown or mixed values.")}if("string"===o)return t.localeCompare(r);if("number"===o)return t-r;if("boolean"===o)return(t?1:0)-(r?1:0);if(t instanceof Date&&r instanceof Date)return t.getTime()-r.getTime();if(!n)throw new Error("You must implement your own comparator for unknown or mixed values.");if(t instanceof Array){if(0!==(c=t.length-r.length))return c;for(var i=0;i<t.length;i++)if(0!==(c=s(t[i],r[i],n)))return c;return 0}if("object"===o){for(var u in t)if(!(u in r))return-1;for(var u in r){if(!(u in t))return-1;var c;if(0!==(c=s(t[u],r[u],n)))return c}}return 0}function p(t,r){void 0===t&&(t=!0),void 0===r&&(r=!1);var n=function(t){return"number"==typeof t&&isFinite(t)},e=function(t,r){return t-r};return function(o,i){return a(t,r,o,i,n,e)}}function h(t,r,n){void 0===t&&(t=!0),void 0===r&&(r=!0),void 0===n&&(n=!1);var e=function(t){return"string"==typeof t},o=t?function(t,r){return t.localeCompare(r)}:function(t,r){return t.toLowerCase().localeCompare(r.toLowerCase())};return function(t,i){return a(r,n,t,i,e,o)}}function l(t,r){void 0===t&&(t=!0),void 0===r&&(r=!1);var n=function(t){return t instanceof Date},e=function(t,r){return t.getTime()-r.getTime()};return function(o,i){return a(t,r,o,i,n,e)}}function v(t,r){void 0===t&&(t=1),void 0===r&&(r=!0);var n=function(t){return t instanceof Date},e=r?function(t){return t.getTime()}:function(t){return t.getTime()+6e4*t.getTimezoneOffset()},o=function(r,n){return e(r)%t==e(n)%t};return function(t,r){return f(t,r,n,o)}}},function(t,r,n){"use strict";n.d(r,"a",function(){return c});var e=n(0),o=function(t,r){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var e,o,i=n.call(t),u=[];try{for(;(void 0===r||r-- >0)&&!(e=i.next()).done;)u.push(e.value)}catch(t){o={error:t}}finally{try{e&&!e.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return u},i=function(){for(var t=[],r=0;r<arguments.length;r++)t=t.concat(o(arguments[r]));return t},u=function(t){var r="function"==typeof Symbol&&t[Symbol.iterator],n=0;return r?r.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}},c=function(){function t(t,r){this.result=null,this.source=t,r&&(this.equality=r.equality,this.comparator=r.comparator)}return t.prototype.clone=function(){return new t(this.source,this)},t.prototype.act=function(t,r){return this.action=0,this.replaceWith=null,this.callback(t,r,this),this.action},t.prototype.stop=function(t){return this.result=t,this.action=1,this},t.prototype.isStopped=function(){return 1===this.action},t.prototype.replace=function(t){return this.replaceWith=t,this.action=3,this},t.prototype.remove=function(){return this.action=2,this},t.prototype.withEquality=function(t){return this.equality=t,this},t.prototype.withComparator=function(t){return this.comparator=t,this.equality||(this.equality=function(r,n){return 0===t(r,n)}),this},t.prototype.withLogic=function(t,r){return this.comparator=t,this.equality=r||function(r,n,e,o){return 0===t(r,n,e,o)},this},t.prototype.numbers=function(t,r){return void 0===t&&(t=!0),void 0===r&&(r=!1),this.withLogic(Object(e.g)(t,r))},t.prototype.strings=function(t,r,n){return void 0===t&&(t=!0),void 0===r&&(r=!0),void 0===n&&(n=!1),this.withLogic(Object(e.h)(t,r,n))},t.prototype.dates=function(t,r,n,o){return void 0===t&&(t=1),void 0===r&&(r=!0),void 0===n&&(n=!0),void 0===o&&(o=!1),this.withLogic(Object(e.e)(n,o),Object(e.f)(t,r))},t.prototype.desc=function(t){var r=t||this.comparator;return this.comparator=function(t,n,e,o){return r(n,t,o,e)},this},t.prototype.getEquality=function(t){return t||this.equality||function(t,r){return 0===Object(e.c)(t,r,!0)}},t.prototype.getComparator=function(t){return t||this.comparator||function(t,r){return Object(e.c)(t,r,!1)}},t.prototype.empty=function(t){var r=!this.each(function(t,r,n){return n.stop()}).isStopped();return t?(t(r),this):r},t.prototype.has=function(t){var r=this.each(function(t,r,n){return n.stop()}).isStopped();return t?(t(r),this):r},t.prototype.contains=function(t,r){var n=this.getEquality(),e=this.where(function(r,e){return n(r,t,e)}).has();return r?(r(e),this):e},t.prototype.count=function(t){var r=0;return this.each(function(){return r++}),t?(t(r),this):r},t.prototype.first=function(t){var r=this.each(function(t,r,n){return n.stop(t)}).result;return t?(t(r),this):r},t.prototype.last=function(t){var r=null;return this.each(function(t){return r=t}),t?(t(r),this):r},t.prototype.array=function(t,r){void 0===t&&(t=[]);var n=Object(e.i)(t)?[]:t,o=Object(e.i)(t)?t:r;return this.each(function(t){return n.push(t)}),o?(o(n),this):n},t.prototype.entries=function(t,r){void 0===t&&(t=[]);var n=Object(e.i)(t)?[]:t,o=Object(e.i)(t)?t:r;return this.each(function(t,r){return n.push([r,t])}),o?(o(n),this):n},t.prototype.object=function(t,r,n){void 0===r&&(r=Object.create(null));var o=Object(e.i)(r)?Object.create(null):r,i=Object(e.i)(r)?r:n;return this.each(function(r){return o[t(r)]=r}),i?(i(o),this):o},t.prototype.set=function(t,r){void 0===t&&(t=new Set);var n=Object(e.i)(t)?new Set:t,o=Object(e.i)(t)?t:r;return this.each(function(t){return n.add(t)}),o?(o(n),this):n},t.prototype.map=function(t,r){void 0===t&&(t=new Map);var n=Object(e.i)(t)?new Map:t,o=Object(e.i)(t)?t:r;return this.each(function(t,r){return n.set(r,t)}),o?(o(n),this):n},t.prototype.group=function(t,r,n){void 0===r&&(r=Object.create(null));var o=Object(e.i)(r)?Object.create(null):r,i=Object(e.i)(r)?r:n;return this.each(function(r){var n=t(r);n in o?o[n].push(r):o[n]=[r]}),i?(i(o),this):o},t.prototype.reduce=function(t,r,n){var e=t;return this.each(function(t){return e=r(t,e)}),n?(n(e),this):e},t.prototype.min=function(t){var r=this.getComparator(),n=this.reduce(null,function(t,n){return null===n||r(t,n)<0?t:n});return t?(t(n),this):n},t.prototype.max=function(t){var r=this.getComparator(),n=this.reduce(null,function(t,n){return null===n||r(t,n)>0?t:n});return t?(t(n),this):n},t.prototype.delete=function(){return this.each(function(t,r,n){return n.remove()})},t.prototype.extract=function(r){var n=[];this.each(function(t,r,e){return n.push([r,t])&&e.remove()});var e=t.entries(n);return r?(r(e),this):e},t.prototype.overwrite=function(t){return this.each(function(r,n,e){return e.replace(t)})},t.prototype.update=function(t){return this.each(function(r,n,e){return e.replace(t(r,n))})},t.prototype.fork=function(t){return t(this),this},t.prototype.split=function(t,r){var n=this.where(t),e=this.not(t);return r?(r(n,e),this):{pass:n,fail:e}},t.prototype.unzip=function(t){var r=this.keys(),n=this.values();return t?(t(r,n),this):{keys:r,values:n}},t.prototype.keys=function(){var r=this;return new t(function(t){var n=0;r.each(function(r,e,o){switch(t.act(e,n++)){case 1:o.stop();break;case 2:o.remove()}})})},t.prototype.values=function(){var r=this;return new t(function(t){r.each(function(r,n,e){var o=0;switch(t.act(r,o++)){case 1:e.stop();break;case 2:e.remove();break;case 3:e.replace(t.replaceWith)}})},this)},t.prototype.view=function(r,n,e,o){var i=this;return new t(function(t){var u=r();i.each(function(r,i,c){if(n(u,r,i)){switch(t.act(r,i)){case 1:c.stop();break;case 2:c.remove();break;case 3:c.replace(t.replaceWith)}e&&e(u,r,i,c)}else o&&o(u,r,i,c)})},this)},t.prototype.take=function(r){return r<=0?t.empty():this.view(function(){return{amount:r}},function(t){return t.amount>0},function(t){return t.amount--},function(t,r,n,e){return e.stop()})},t.prototype.skip=function(t){return this.view(function(){return{skipped:0}},function(r){return r.skipped>=t},function(t){return t.skipped++},function(t){return t.skipped++})},t.prototype.drop=function(t){return this.reverse().skip(t).reverse()},t.prototype.append=function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return t.join.apply(t,i([this],r))},t.prototype.prepend=function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return t.join.apply(t,i(r,[this]))},t.prototype.where=function(t){return this.view(function(){return null},function(r,n,e){return t(n,e)})},t.prototype.not=function(t){return this.view(function(){return null},function(r,n,e){return!t(n,e)})},t.prototype.gt=function(t,r){var n=this;return this.view(function(){return n.getComparator(r)},function(r,n,e){return r(n,t,e)>0})},t.prototype.gte=function(t,r){var n=this;return this.view(function(){return n.getComparator(r)},function(r,n,e){return r(n,t,e)>=0})},t.prototype.lt=function(t,r){var n=this;return this.view(function(){return n.getComparator(r)},function(r,n,e){return r(n,t,e)<0})},t.prototype.lte=function(t,r){var n=this;return this.view(function(){return n.getComparator(r)},function(r,n,e){return r(n,t,e)<=0})},t.prototype.exclude=function(t,r){var n=this;return this.view(function(){return Object(e.j)(t).withEquality(n.getEquality(r))},function(t,r){return!t.contains(r)})},t.prototype.intersect=function(t,r){var n=this;return this.view(function(){return Object(e.j)(t).withEquality(n.getEquality(r))},function(t,r){return t.contains(r)})},t.prototype.unique=function(t){var r=this;return this.view(function(){return{existing:[],isEqual:r.getEquality(t)}},function(t,r,n){var e=t.existing,i=t.isEqual;return-1===e.findIndex(function(t){var e=o(t,2),u=e[0],c=e[1];return i(c,r,u,n)})},function(t,r,n){return t.existing.push([n,r])})},t.prototype.duplicates=function(t,r){var n=this;return void 0===t&&(t=!1),this.view(function(){return{existing:[],once:[],isEqual:n.getEquality(r)}},function(r,n,e){var i=r.existing,u=r.once,c=r.isEqual,a=i.findIndex(function(t){var r=o(t,2),i=r[0],u=r[1];return c(u,n,i,e)}),f=-1!==a;return f?(u[a]&&t&&(f=!1),u[a]=!0):i.push([e,n]),f})},t.prototype.readonly=function(){var r=this;return new t(function(t){r.each(function(r,n,e){1===t.act(r,n)&&e.stop()})},this)},t.prototype.copy=function(){return t.entries(this.entries())},t.prototype.viewResolved=function(r){var n=this;return new t(function(t){var e=n.entries(),o=[],i=[],u=[],c=!1;if(r(e,function(r,n,e){var a=t.act(r,n);return 3!==a&&2!==a||(c=!0,u[e]=r,o[e]=a,i[e]=t.replaceWith),a}),c){var a=0;n.each(function(t,r,n){switch(o[a]){case 2:t===u[a]&&n.remove();break;case 3:t===u[a]&&n.replace(i[a])}a++})}},this)},t.prototype.sorted=function(t){var r=this;return this.viewResolved(function(n,e){var i,c,a=r.getComparator(t),f=n.map(function(t,r){var n=o(t,2);return{key:n[0],value:n[1],index:r}});f.sort(function(t,r){return a(t.value,r.value)});try{for(var s=u(f),p=s.next();!p.done;p=s.next()){var h=p.value,l=h.key;if(1===e(h.value,l,h.index))return}}catch(t){i={error:t}}finally{try{p&&!p.done&&(c=s.return)&&c.call(s)}finally{if(i)throw i.error}}})},t.prototype.shuffle=function(t){void 0===t&&(t=1);var r=function(t,r,n){var e=t[r];t[r]=t[n],t[n]=e};return this.viewResolved(function(n,e){for(var i=[],u=n.length,c=0;c<u;c++)i.push(c);for(var a=0;a<t;a++)for(var f=0;f<u;f++){var s=Math.floor(Math.random()*u);r(n,s,f),r(i,s,f)}for(c=0;c<u;c++){var p=o(n[c],2),h=p[0];if(1===e(p[1],h,i[c]))return}})},t.prototype.reverse=function(){return this.viewResolved(function(t,r){for(var n=t.length-1;n>=0;n--){var e=o(t[n],2),i=e[0];if(1===r(e[1],i,n))return}})},t.prototype.transform=function(r,n){var e=this;return void 0===n&&(n=null),new t(function(t){e.each(function(e,o,i){var u=r(e,o,i);if(void 0!==u)switch(t.act(u,o)){case 1:i.stop();break;case 2:i.remove();break;case 3:n&&i.replace(n(t.replaceWith,u,e,o))}})})},t.prototype.each=function(t){return this.result=void 0,this.callback=t,this.action=0,this.source(this),this.callback=null,this},t.prototype.withResult=function(t){return this.result&&t(this.result),this},t.prototype[Symbol.iterator]=function(){return this.array().values()},t.entries=function(r){return void 0===r&&(r=[]),new t(function(t){for(var n=0;n<r.length;n++){var e=o(r[n],2),i=e[0],u=e[1];switch(t.act(u,i)){case 1:return;case 2:r.splice(n,1),n--;break;case 3:r.splice(n,1,[i,t.replaceWith])}}})},t.array=function(r){return void 0===r&&(r=[]),new t(function(t){for(var n=0;n<r.length;n++)switch(t.act(r[n],n)){case 1:return;case 2:r.splice(n,1),n--;break;case 3:r.splice(n,1,t.replaceWith)}})},t.zip=function(r,n){var o=Object(e.j)(r),i=Object(e.j)(n);return new t(function(t){var r=o.array(),n=[],e=0;if(i.each(function(o,i,u){if(e>=r.length)u.stop();else switch(t.act(o,r[e])){case 1:return;case 2:u.remove(),n.push(e);break;case 3:u.replace(t.replaceWith)}e++}),n.length>0){var u=0;o.each(function(t,r,e){u===n[0]?(e.remove(),n.shift()):0===n.length&&e.stop(),u++})}})},t.hasEntries=function(r,n,e){return new t(function(t){for(var i=r.entries(),u=i.next();!u.done;u=i.next()){var c=o(u.value,2),a=c[0],f=c[1];switch(t.act(f,a)){case 1:return;case 2:n&&n(r,a,f);break;case 3:e&&e(r,a,f,t.replaceWith)}}})},t.map=function(r){return void 0===r&&(r=new Map),t.hasEntries(r,function(t,r){return t.delete(r)},function(t,r,n,e){return t.set(r,e)})},t.set=function(r){return void 0===r&&(r=new Set),t.hasEntries(r,function(t,r){return t.delete(r)},function(t,n,e,o){return r.delete(e)&&r.add(o)})},t.iterable=function(r){return new t(function(t){for(var n=r[Symbol.iterator](),e=0,o=n.next();!o.done&&1!==t.act(o.value,e);o=n.next(),e++);})},t.object=function(r,n){return void 0===n&&(n=!0),new t(function(t){for(var e in r)if(!n||r.hasOwnProperty(e))switch(t.act(r[e],e)){case 1:return;case 2:delete r[e];break;case 3:r[e]=t.replaceWith}})},t.linked=function(r,n,e,o,i){return i||(i=function(t){return r(t)}),function(u,c){return void 0===c&&(c=!0),new t(function(t){for(var a=u,f=n(u);f&&f!==u;){var s=n(f),p=!1;switch(t.act(r(f),i(f))){case 1:return;case 2:if(e)e(f,a),p=!0;else if(c)throw new Error("remove is required for linked list iteration");break;case 3:if(o)o(f,t.replaceWith);else if(c)throw new Error("replace is required for linked list iteration")}p||(a=f),f=s}})}},t.tree=function(r,n,e,o){o||(o=function(t){return r(t)});var i=t.empty(),u=function(r){var e=n(r);return e?Array.isArray(e)?t.array(e):e:i},c=function(t,n,i,u,c){switch(n.act(r(t),o(t))){case 1:return c&&c.stop(),!1;case 3:if(e)e(t,n.replaceWith);else if(i)throw new Error("replaceValue is required when replacing a value in a tree");break;case 2:if(c)c.remove();else if(i&&u)throw new Error("remove is not supported for breadth-first iteration")}return!0},a=function(t,r,n,e){return!!c(t,r,n,!1,e)&&!u(t).each(function(t,e,o){return a(t,r,n,o)}).isStopped()};return function(r,n,e){return void 0===n&&(n=!0),void 0===e&&(e=!0),new t(function(t){return n?a(r,t,e):function(t,r,n){var e=[];for(e.push(t);e.length>0;){var o=e.shift();if(!c(o,r,n,!0))break;u(o).array(e)}}(r,t,e)})}},t.join=function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return new t(function(t){var n,o,i=r.map(e.j);try{for(var c=u(i),a=c.next();!a.done;a=c.next()){var f=a.value;if(f.each(function(r,n,e){switch(t.act(r,n)){case 2:e.remove();break;case 1:e.stop();break;case 3:e.replace(t.replaceWith)}}),1===f.action)return}}catch(t){n={error:t}}finally{try{a&&!a.done&&(o=c.return)&&o.call(c)}finally{if(n)throw n.error}}})},t.empty=function(){return new t(function(t){})},t.func=function(t){return function(r){for(var n=[],o=1;o<arguments.length;o++)n[o-1]=arguments[o];var u,c=Object(e.j)(r);return t.apply(void 0,i([c,function(t){return u=t}],n)),u}},t}()},function(t,r){},function(t,r,n){"use strict";n.r(r);var e=n(0);n.d(r,"Generators",function(){return e.a}),n.d(r,"iterate",function(){return e.j}),n.d(r,"isFunction",function(){return e.i}),n.d(r,"compare",function(){return e.b}),n.d(r,"equals",function(){return e.d}),n.d(r,"defaultCompare",function(){return e.c}),n.d(r,"getNumberComparator",function(){return e.g}),n.d(r,"getStringComparator",function(){return e.h}),n.d(r,"getDateComparator",function(){return e.e}),n.d(r,"getDateEquality",function(){return e.f});var o=n(2);for(var i in o)["Generators","iterate","isFunction","compare","equals","defaultCompare","getNumberComparator","getStringComparator","getDateComparator","getDateEquality","default"].indexOf(i)<0&&function(t){n.d(r,t,function(){return o[t]})}(i);var u=n(1);n.d(r,"Iterate",function(){return u.a}),r.default=e.j}])}); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("iteratez",[],e):"object"==typeof exports?exports.iteratez=e():t.iteratez=e()}(this,function(){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=3)}([function(t,e,r){"use strict";r.d(e,"a",function(){return i}),r.d(e,"j",function(){return u}),r.d(e,"i",function(){return a}),r.d(e,"b",function(){return c}),r.d(e,"d",function(){return s}),r.d(e,"c",function(){return f}),r.d(e,"g",function(){return p}),r.d(e,"h",function(){return h}),r.d(e,"e",function(){return l}),r.d(e,"f",function(){return v});var n=r(1),o=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}},i=[function(t){return t instanceof n.a&&t},function(t){return!!Array.isArray(t)&&n.a.array(t)},function(t){return t instanceof Set&&n.a.set(t)},function(t){return t instanceof Map&&n.a.map(t)},function(t){return!(!t||!t[Symbol.iterator])&&n.a.iterable(t)},function(t){return!(!t||!t.entries)&&n.a.hasEntries(t)},function(t){return null==t&&n.a.empty()},function(t){return"object"==typeof t&&n.a.object(t)},function(t){return n.a.array([t])}];function u(t){var e,r;try{for(var n=o(i),u=n.next();!u.done;u=n.next()){var a=(0,u.value)(t);if(!1!==a)return a}}catch(t){e={error:t}}finally{try{u&&!u.done&&(r=n.return)&&r.call(n)}finally{if(e)throw e.error}}}function a(t){return"function"==typeof t}function c(t,e,r,n,o,i){var u=!o(r),a=!o(n);return u!==a?(e?u:a)?-1:1:u?0:t?i(r,n):i(n,r)}function s(t,e,r,n){var o=!r(t);return o===!r(e)&&(!!o||n(t,e))}function f(t,e,r){void 0===r&&(r=!1);var n=null==t;if(n!==(null==e))return n?1:-1;if(n)return 0;var o=typeof t;if(o!==typeof e){if(r)return-1;throw new Error("You must implement your own comparator for unknown or mixed values.")}if("string"===o)return t.localeCompare(e);if("number"===o)return t-e;if("boolean"===o)return(t?1:0)-(e?1:0);if(t instanceof Date&&e instanceof Date)return t.getTime()-e.getTime();if(!r)throw new Error("You must implement your own comparator for unknown or mixed values.");if(t instanceof Array){if(0!==(a=t.length-e.length))return a;for(var i=0;i<t.length;i++)if(0!==(a=f(t[i],e[i],r)))return a;return 0}if("object"===o){for(var u in t)if(!(u in e))return-1;for(var u in e){if(!(u in t))return-1;var a;if(0!==(a=f(t[u],e[u],r)))return a}}return 0}function p(t,e){void 0===t&&(t=!0),void 0===e&&(e=!1);var r=function(t){return"number"==typeof t&&isFinite(t)},n=function(t,e){return t-e};return function(o,i){return c(t,e,o,i,r,n)}}function h(t,e,r){void 0===t&&(t=!0),void 0===e&&(e=!0),void 0===r&&(r=!1);var n=function(t){return"string"==typeof t},o=t?function(t,e){return t.localeCompare(e)}:function(t,e){return t.toLowerCase().localeCompare(e.toLowerCase())};return function(t,i){return c(e,r,t,i,n,o)}}function l(t,e){void 0===t&&(t=!0),void 0===e&&(e=!1);var r=function(t){return t instanceof Date},n=function(t,e){return t.getTime()-e.getTime()};return function(o,i){return c(t,e,o,i,r,n)}}function v(t,e){void 0===t&&(t=1),void 0===e&&(e=!0);var r=function(t){return t instanceof Date},n=e?function(t){return t.getTime()}:function(t){return t.getTime()+6e4*t.getTimezoneOffset()},o=function(e,r){return n(e)%t==n(r)%t};return function(t,e){return s(t,e,r,o)}}},function(t,e,r){"use strict";r.d(e,"a",function(){return a});var n=r(0),o=function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],r=0;return e?e.call(t):{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}}},i=function(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return u},u=function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(i(arguments[e]));return t},a=function(){function t(t,e){this.result=null,this.source=t,e&&(this.equality=e.equality,this.comparator=e.comparator)}return t.prototype.onReset=function(t){return this.handleReset=t,this},t.prototype.canReset=function(){return!!this.handleReset},t.prototype.reset=function(t,e){if(void 0===e&&(e=!0),this.handleReset)this.handleReset(t);else if(e)throw new Error("This iterator does not support reset.");return this},t.prototype.clone=function(){return new t(this.source,this)},t.prototype.act=function(t,e){return this.action=0,this.replaceWith=null,this.callback(t,e,this),this.action},t.prototype.stop=function(t){return this.result=t,this.action=1,this},t.prototype.isStopped=function(){return 1===this.action},t.prototype.replace=function(t){return this.replaceWith=t,this.action=3,this},t.prototype.remove=function(){return this.action=2,this},t.prototype.withEquality=function(t){return this.equality=t,this},t.prototype.withComparator=function(t){return this.comparator=t,this.equality||(this.equality=function(e,r){return 0===t(e,r)}),this},t.prototype.withLogic=function(t,e){return this.comparator=t,this.equality=e||function(e,r,n,o){return 0===t(e,r,n,o)},this},t.prototype.numbers=function(t,e){return void 0===t&&(t=!0),void 0===e&&(e=!1),this.withLogic(Object(n.g)(t,e))},t.prototype.strings=function(t,e,r){return void 0===t&&(t=!0),void 0===e&&(e=!0),void 0===r&&(r=!1),this.withLogic(Object(n.h)(t,e,r))},t.prototype.dates=function(t,e,r,o){return void 0===t&&(t=1),void 0===e&&(e=!0),void 0===r&&(r=!0),void 0===o&&(o=!1),this.withLogic(Object(n.e)(r,o),Object(n.f)(t,e))},t.prototype.desc=function(t){var e=t||this.comparator;return this.comparator=function(t,r,n,o){return e(r,t,o,n)},this},t.prototype.getEquality=function(t){return t||this.equality||function(t,e){return 0===Object(n.c)(t,e,!0)}},t.prototype.getComparator=function(t){return t||this.comparator||function(t,e){return Object(n.c)(t,e,!1)}},t.prototype.empty=function(t){var e=!this.each(function(t,e,r){return r.stop()}).isStopped();return t?(t(e),this):e},t.prototype.has=function(t){var e=this.each(function(t,e,r){return r.stop()}).isStopped();return t?(t(e),this):e},t.prototype.contains=function(t,e){var r=this.getEquality(),n=this.where(function(e,n){return r(e,t,n)}).has();return e?(e(n),this):n},t.prototype.count=function(t){var e=0;return this.each(function(){return e++}),t?(t(e),this):e},t.prototype.first=function(t){var e=this.each(function(t,e,r){return r.stop(t)}).result;return t?(t(e),this):e},t.prototype.last=function(t){var e=null;return this.each(function(t){return e=t}),t?(t(e),this):e},t.prototype.array=function(t,e){void 0===t&&(t=[]);var r=Object(n.i)(t)?[]:t,o=Object(n.i)(t)?t:e;return this.each(function(t){return r.push(t)}),o?(o(r),this):r},t.prototype.entries=function(t,e){void 0===t&&(t=[]);var r=Object(n.i)(t)?[]:t,o=Object(n.i)(t)?t:e;return this.each(function(t,e){return r.push([e,t])}),o?(o(r),this):r},t.prototype.object=function(t,e,r){void 0===e&&(e=Object.create(null));var o=Object(n.i)(e)?Object.create(null):e,i=Object(n.i)(e)?e:r;return this.each(function(e){return o[t(e)]=e}),i?(i(o),this):o},t.prototype.set=function(t,e){void 0===t&&(t=new Set);var r=Object(n.i)(t)?new Set:t,o=Object(n.i)(t)?t:e;return this.each(function(t){return r.add(t)}),o?(o(r),this):r},t.prototype.map=function(t,e){void 0===t&&(t=new Map);var r=Object(n.i)(t)?new Map:t,o=Object(n.i)(t)?t:e;return this.each(function(t,e){return r.set(e,t)}),o?(o(r),this):r},t.prototype.group=function(t,e,r){void 0===e&&(e=Object.create(null));var o=Object(n.i)(e)?Object.create(null):e,i=Object(n.i)(e)?e:r;return this.each(function(e){var r=t(e);r in o?o[r].push(e):o[r]=[e]}),i?(i(o),this):o},t.prototype.reduce=function(t,e,r){var n=t;return this.each(function(t){return n=e(t,n)}),r?(r(n),this):n},t.prototype.min=function(t){var e=this.getComparator(),r=this.reduce(null,function(t,r){return null===r||e(t,r)<0?t:r});return t?(t(r),this):r},t.prototype.max=function(t){var e=this.getComparator(),r=this.reduce(null,function(t,r){return null===r||e(t,r)>0?t:r});return t?(t(r),this):r},t.prototype.changes=function(t,e,r,n){var u,a,c=this;this.history||(this.history=new Map);var s=new Map(this.history);this.each(function(e,o,i){var u=n?n(e,o,i):e;c.history.has(u)?r(e,o,i):(t(e,o,i),2!==i.result&&c.history.set(u,[o,e])),s.delete(u)});try{for(var f=o(s.values()),p=f.next();!p.done;p=f.next()){var h=i(p.value,2),l=h[0];e(h[1],l,this)}}catch(t){u={error:t}}finally{try{p&&!p.done&&(a=f.return)&&a.call(f)}finally{if(u)throw u.error}}return this},t.prototype.delete=function(){return this.each(function(t,e,r){return r.remove()})},t.prototype.extract=function(e){var r=[];this.each(function(t,e,n){return r.push([e,t])&&n.remove()});var n=t.entries(r);return e?(e(n),this):n},t.prototype.overwrite=function(t){return this.each(function(e,r,n){return n.replace(t)})},t.prototype.update=function(t){return this.each(function(e,r,n){return n.replace(t(e,r))})},t.prototype.fork=function(t){return t(this),this},t.prototype.split=function(t,e){var r=this.where(t),n=this.not(t);return e?(e(r,n),this):{pass:r,fail:n}},t.prototype.unzip=function(t){var e=this.keys(),r=this.values();return t?(t(e,r),this):{keys:e,values:r}},t.prototype.keys=function(){var e=this;return new t(function(t){var r=0;e.each(function(e,n,o){switch(t.act(n,r++)){case 1:o.stop();break;case 2:o.remove()}})}).onReset(this.handleReset)},t.prototype.values=function(){var e=this;return new t(function(t){e.each(function(e,r,n){var o=0;switch(t.act(e,o++)){case 1:n.stop();break;case 2:n.remove();break;case 3:n.replace(t.replaceWith)}})},this).onReset(this.handleReset)},t.prototype.view=function(e,r,n,o){var i=this;return new t(function(t){var u=e();i.each(function(e,i,a){if(r(u,e,i)){switch(t.act(e,i)){case 1:a.stop();break;case 2:a.remove();break;case 3:a.replace(t.replaceWith)}n&&n(u,e,i,a)}else o&&o(u,e,i,a)})},this).onReset(this.handleReset)},t.prototype.take=function(e){return e<=0?t.empty():this.view(function(){return{amount:e}},function(t){return t.amount>0},function(t){return t.amount--},function(t,e,r,n){return n.stop()})},t.prototype.skip=function(t){return this.view(function(){return{skipped:0}},function(e){return e.skipped>=t},function(t){return t.skipped++},function(t){return t.skipped++})},t.prototype.drop=function(t){return this.reverse().skip(t).reverse()},t.prototype.append=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return t.join.apply(t,u([this],e)).onReset(this.handleReset)},t.prototype.prepend=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return t.join.apply(t,u(e,[this])).onReset(this.handleReset)},t.prototype.where=function(t){return this.view(function(){return null},function(e,r,n){return t(r,n)})},t.prototype.not=function(t){return this.view(function(){return null},function(e,r,n){return!t(r,n)})},t.prototype.gt=function(t,e){var r=this;return this.view(function(){return r.getComparator(e)},function(e,r,n){return e(r,t,n)>0})},t.prototype.gte=function(t,e){var r=this;return this.view(function(){return r.getComparator(e)},function(e,r,n){return e(r,t,n)>=0})},t.prototype.lt=function(t,e){var r=this;return this.view(function(){return r.getComparator(e)},function(e,r,n){return e(r,t,n)<0})},t.prototype.lte=function(t,e){var r=this;return this.view(function(){return r.getComparator(e)},function(e,r,n){return e(r,t,n)<=0})},t.prototype.exclude=function(t,e){var r=this;return this.view(function(){return Object(n.j)(t).withEquality(r.getEquality(e))},function(t,e){return!t.contains(e)})},t.prototype.intersect=function(t,e){var r=this;return this.view(function(){return Object(n.j)(t).withEquality(r.getEquality(e))},function(t,e){return t.contains(e)})},t.prototype.unique=function(t){var e=this;return this.view(function(){return{existing:[],isEqual:e.getEquality(t)}},function(t,e,r){var n=t.existing,o=t.isEqual;return-1===n.findIndex(function(t){var n=i(t,2),u=n[0],a=n[1];return o(a,e,u,r)})},function(t,e,r){return t.existing.push([r,e])})},t.prototype.duplicates=function(t,e){var r=this;return void 0===t&&(t=!1),this.view(function(){return{existing:[],once:[],isEqual:r.getEquality(e)}},function(e,r,n){var o=e.existing,u=e.once,a=e.isEqual,c=o.findIndex(function(t){var e=i(t,2),o=e[0],u=e[1];return a(u,r,o,n)}),s=-1!==c;return s?(u[c]&&t&&(s=!1),u[c]=!0):o.push([n,r]),s})},t.prototype.readonly=function(){var e=this;return new t(function(t){e.each(function(e,r,n){1===t.act(e,r)&&n.stop()})},this).onReset(this.handleReset)},t.prototype.copy=function(){return t.entries(this.entries())},t.prototype.viewResolved=function(e){var r=this;return new t(function(t){var n=r.entries(),o=[],i=[],u=[],a=!1;if(e(n,function(e,r,n){var c=t.act(e,r);return 3!==c&&2!==c||(a=!0,u[n]=e,o[n]=c,i[n]=t.replaceWith),c}),a){var c=0;r.each(function(t,e,r){switch(o[c]){case 2:t===u[c]&&r.remove();break;case 3:t===u[c]&&r.replace(i[c])}c++})}},this).onReset(this.handleReset)},t.prototype.sorted=function(t){var e=this;return this.viewResolved(function(r,n){var u,a,c=e.getComparator(t),s=r.map(function(t,e){var r=i(t,2);return{key:r[0],value:r[1],index:e}});s.sort(function(t,e){return c(t.value,e.value)});try{for(var f=o(s),p=f.next();!p.done;p=f.next()){var h=p.value,l=h.key;if(1===n(h.value,l,h.index))return}}catch(t){u={error:t}}finally{try{p&&!p.done&&(a=f.return)&&a.call(f)}finally{if(u)throw u.error}}})},t.prototype.shuffle=function(t){void 0===t&&(t=1);var e=function(t,e,r){var n=t[e];t[e]=t[r],t[r]=n};return this.viewResolved(function(r,n){for(var o=[],u=r.length,a=0;a<u;a++)o.push(a);for(var c=0;c<t;c++)for(var s=0;s<u;s++){var f=Math.floor(Math.random()*u);e(r,f,s),e(o,f,s)}for(a=0;a<u;a++){var p=i(r[a],2),h=p[0];if(1===n(p[1],h,o[a]))return}})},t.prototype.reverse=function(){return this.viewResolved(function(t,e){for(var r=t.length-1;r>=0;r--){var n=i(t[r],2),o=n[0];if(1===e(n[1],o,r))return}})},t.prototype.transform=function(e,r){var n=this;return void 0===r&&(r=null),new t(function(t){n.each(function(n,o,i){var u=e(n,o,i);if(void 0!==u)switch(t.act(u,o)){case 1:i.stop();break;case 2:i.remove();break;case 3:r&&i.replace(r(t.replaceWith,u,n,o))}})}).onReset(this.handleReset)},t.prototype.each=function(t){return this.result=void 0,this.callback=t,this.action=0,this.source(this),this.callback=null,this},t.prototype.withResult=function(t){return this.result&&t(this.result),this},t.prototype[Symbol.iterator]=function(){return this.array().values()},t.entries=function(e){return void 0===e&&(e=[]),new t(function(t){for(var r=0;r<e.length;r++){var n=i(e[r],2),o=n[0],u=n[1];switch(t.act(u,o)){case 1:return;case 2:e.splice(r,1),r--;break;case 3:e.splice(r,1,[o,t.replaceWith])}}}).onReset(function(t){return e=t})},t.array=function(e){return void 0===e&&(e=[]),new t(function(t){for(var r=0;r<e.length;r++)switch(t.act(e[r],r)){case 1:return;case 2:e.splice(r,1),r--;break;case 3:e.splice(r,1,t.replaceWith)}}).onReset(function(t){return e=t})},t.zip=function(e,r){var o=Object(n.j)(e),u=Object(n.j)(r);return new t(function(t){var e=o.array(),r=[],n=0;if(u.each(function(o,i,u){if(n>=e.length)u.stop();else switch(t.act(o,e[n])){case 1:return;case 2:u.remove(),r.push(n);break;case 3:u.replace(t.replaceWith)}n++}),r.length>0){var i=0;o.each(function(t,e,n){i===r[0]?(n.remove(),r.shift()):0===r.length&&n.stop(),i++})}}).onReset(function(t){var e=i(t,2),r=e[0],a=e[1];o=Object(n.j)(r),u=Object(n.j)(a)})},t.hasEntries=function(e,r,n){return new t(function(t){for(var o=e.entries(),u=o.next();!u.done;u=o.next()){var a=i(u.value,2),c=a[0],s=a[1];switch(t.act(s,c)){case 1:return;case 2:r&&r(e,c,s);break;case 3:n&&n(e,c,s,t.replaceWith)}}}).onReset(function(t){return e=t})},t.map=function(e){return void 0===e&&(e=new Map),t.hasEntries(e,function(t,e){return t.delete(e)},function(t,e,r,n){return t.set(e,n)})},t.set=function(e){return void 0===e&&(e=new Set),t.hasEntries(e,function(t,e){return t.delete(e)},function(t,r,n,o){return e.delete(n)&&e.add(o)})},t.iterable=function(e){return new t(function(t){for(var r=e[Symbol.iterator](),n=0,o=r.next();!o.done&&1!==t.act(o.value,n);o=r.next(),n++);}).onReset(function(t){return e=t})},t.object=function(e,r){return void 0===r&&(r=!0),new t(function(t){for(var n in e)if(!r||e.hasOwnProperty(n))switch(t.act(e[n],n)){case 1:return;case 2:delete e[n];break;case 3:e[n]=t.replaceWith}}).onReset(function(t){return e=t})},t.linked=function(e,r,n,o,i){return i||(i=function(t){return e(t)}),function(u,a){return void 0===a&&(a=!0),new t(function(t){for(var c=u,s=r(u);s&&s!==u;){var f=r(s),p=!1;switch(t.act(e(s),i(s))){case 1:return;case 2:if(n)n(s,c),p=!0;else if(a)throw new Error("remove is required for linked list iteration");break;case 3:if(o)o(s,t.replaceWith);else if(a)throw new Error("replace is required for linked list iteration")}p||(c=s),s=f}}).onReset(function(t){return u=t})}},t.tree=function(e,r,n,o){o||(o=function(t){return e(t)});var i=t.empty(),u=function(e){var n=r(e);return n?Array.isArray(n)?t.array(n):n:i},a=function(t,r,i,u,a){switch(r.act(e(t),o(t))){case 1:return a&&a.stop(),!1;case 3:if(n)n(t,r.replaceWith);else if(i)throw new Error("replaceValue is required when replacing a value in a tree");break;case 2:if(a)a.remove();else if(i&&u)throw new Error("remove is not supported for breadth-first iteration")}return!0},c=function(t,e,r,n){return!!a(t,e,r,!1,n)&&!u(t).each(function(t,n,o){return c(t,e,r,o)}).isStopped()};return function(e,r,n){return void 0===r&&(r=!0),void 0===n&&(n=!0),new t(function(t){return r?c(e,t,n):function(t,e,r){var n=[];for(n.push(t);n.length>0;){var o=n.shift();if(!a(o,e,r,!0))break;u(o).array(n)}}(e,t,n)}).onReset(function(t){return e=t})}},t.join=function(){for(var e=[],r=0;r<arguments.length;r++)e[r]=arguments[r];return new t(function(t){var r,i,u=e.map(n.j);try{for(var a=o(u),c=a.next();!c.done;c=a.next()){var s=c.value;if(s.each(function(e,r,n){switch(t.act(e,r)){case 2:n.remove();break;case 1:n.stop();break;case 3:n.replace(t.replaceWith)}}),1===s.action)return}}catch(t){r={error:t}}finally{try{c&&!c.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}})},t.empty=function(){return new t(function(t){})},t.func=function(t){return function(e){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];var i,a=Object(n.j)(e);return t.apply(void 0,u([a,function(t){return i=t}],r)),i}},t}()},function(t,e){},function(t,e,r){"use strict";r.r(e);var n=r(0);r.d(e,"Generators",function(){return n.a}),r.d(e,"iterate",function(){return n.j}),r.d(e,"isFunction",function(){return n.i}),r.d(e,"compare",function(){return n.b}),r.d(e,"equals",function(){return n.d}),r.d(e,"defaultCompare",function(){return n.c}),r.d(e,"getNumberComparator",function(){return n.g}),r.d(e,"getStringComparator",function(){return n.h}),r.d(e,"getDateComparator",function(){return n.e}),r.d(e,"getDateEquality",function(){return n.f});var o=r(2);for(var i in o)["Generators","iterate","isFunction","compare","equals","defaultCompare","getNumberComparator","getStringComparator","getDateComparator","getDateEquality","default"].indexOf(i)<0&&function(t){r.d(e,t,function(){return o[t]})}(i);var u=r(1);r.d(e,"Iterate",function(){return u.a}),e.default=n.j}])}); | ||
//# sourceMappingURL=iteratez.js.map |
{ | ||
"name": "iteratez", | ||
"version": "1.1.0", | ||
"description": "A simple yet powerful iterator that allows iteration for even the most complex types.", | ||
"version": "1.2.0", | ||
"description": "A powerful functional iterator, transformer, and mutator - like Underscore.js, except for everything", | ||
"main": "dist/iteratez.js", | ||
@@ -6,0 +6,0 @@ "typings": "typings/index.d.ts", |
@@ -76,2 +76,3 @@ # iteratez | ||
- `copy`: Copies the values in the view and returns a new iterator. | ||
- `changes`: Notifies you when values are added, removed, or still present on an iterator since the last time called. | ||
@@ -88,2 +89,7 @@ ### Comparison Logic | ||
### Reset | ||
The following function(s) allow you to change the source for iteration. | ||
- `reset`: Sets a new source to iterate. | ||
### Other Functions | ||
@@ -177,2 +183,3 @@ The following static functions exist to help iterate simple sources: | ||
let copy = source.copy(): // Iterate<T> | ||
let that = source.changes(onAdd, onRemove, onPresent); // this | ||
@@ -241,2 +248,4 @@ // ============ Mutations ============ | ||
// ============ Reset ============ | ||
source.reset(['a', 'new', 'source', 'to', 'iterate']); | ||
@@ -243,0 +252,0 @@ // ============ Examples ============ |
import { IterateAction } from "./IterateAction"; | ||
import { GetKeyFor, GetValueFor, HasEntries, IterateCallback, IterateCompare, IterateEquals, IterateFilter, IterateFunction, IterateFunctionExecute, IterateResult, IterateSource, IterateSourceType, IterateSourceTypeKey } from "./types"; | ||
import { GetKeyFor, GetValueFor, HasEntries, IterateCallback, IterateCompare, IterateEquals, IterateFilter, IterateFunction, IterateFunctionExecute, IterateResult, IterateSource, IterateSourceType, IterateSourceTypeKey, IterateReset } from "./types"; | ||
/** | ||
@@ -126,2 +126,6 @@ * A class that allows an iteratable source to be iterated any number of times. | ||
/** | ||
* The function to invoke to passing a new source for iteration. | ||
*/ | ||
private handleReset; | ||
/** | ||
* Creates a new Iterate given a source. | ||
@@ -133,2 +137,21 @@ * | ||
/** | ||
* The function which receives a new source to reset iteration. | ||
* | ||
* @package handleReset The function which takes the new source. | ||
*/ | ||
onReset(handleReset: IterateReset<S>): this; | ||
/** | ||
* Returns whether the iterator at this point supports a reset. | ||
*/ | ||
canReset(): boolean; | ||
/** | ||
* Sets a new source for iteration if supported. If the iterator doesn't | ||
* support resetting the source then an error will be thrown when `strict` | ||
* is true. | ||
* | ||
* @param source The new source for iteration. | ||
* @param strict If an error should be thrown if the iterator can't be reset. | ||
*/ | ||
reset(source: S, strict?: boolean): this; | ||
/** | ||
* Returns a clone of this iterator with the same source. This is necessary | ||
@@ -384,2 +407,42 @@ * if you want to iterate all or a portion of the source while already | ||
/** | ||
* A map of key-value pairs stored from the last time `changes` was invoked. | ||
* | ||
* The keys are the value in the iterator or a dynamically created value | ||
* returned by the `getIdentifier` function. If that function is provided | ||
* once it must always be provided to ensure correct change detection. | ||
*/ | ||
protected history: Map<any, [K, T]>; | ||
/** | ||
* An operation which determines which changes have occurred in the source | ||
* since the last time the changes operation was called. The changes | ||
* operation needs to be called on the same exact iterator instance to | ||
* properly track changes. You should avoid sharing an iterator or using | ||
* reset for an iterator that you're using to track changes. | ||
* | ||
* Optionally you can provide a `getIdentifier` function which can convert | ||
* a value into a more optimal value for comparison. The value returned | ||
* will be compared by reference so a scalar value (number, string, etc) | ||
* is ideal but other identifiers can be returned as long as they are | ||
* the same reference and not dynamically generated. | ||
* | ||
* The first time this operation is performed all the values in the iterator | ||
* will be passed through the `onAdd` function. | ||
* | ||
* The `onRemove` function is only called at the very end of the changes | ||
* logic. | ||
* | ||
* @param onAdd The function to invoke for each value added since the | ||
* last `changes` operation, | ||
* @param onRemove The function to invoke for each value removed since the | ||
* last `changes` operation. This function is called zero or more times | ||
* at the end of the changes logic. | ||
* @param onPresent The function to invoke for each value that was in the | ||
* iterator before and is still in the iterator. | ||
* @param getIdentifier A function to use to create a simpler way to identify | ||
* a value. The simpler the value returned the better the performance | ||
* of the changes logic. If this function is passed once, it should be | ||
* passed everytime or the results of this function will not be accurate. | ||
*/ | ||
changes(onAdd: IterateCallback<T, K, S, any>, onRemove: IterateCallback<T, K, S, any>, onPresent: IterateCallback<T, K, S, any>, getIdentifier?: IterateCallback<T, K, S, any>): this; | ||
/** | ||
* A mutation which removes values in this iterator from the source. | ||
@@ -386,0 +449,0 @@ */ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
85099
1061
486