Socket
Socket
Sign inDemoInstall

iteratez

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iteratez - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

2

dist/iteratez.js

@@ -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 e(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,e),o.l=!0,o.exports}return e.m=t,e.c=r,e.d=function(t,r,n){e.o(t,r)||Object.defineProperty(t,r,{enumerable:!0,get:n})},e.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},e.t=function(t,r){if(1&r&&(t=e(t)),8&r)return t;if(4&r&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(e.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&r&&"string"!=typeof t)for(var o in t)e.d(n,o,function(r){return t[r]}.bind(null,o));return n},e.n=function(t){var r=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(r,"a",r),r},e.o=function(t,r){return Object.prototype.hasOwnProperty.call(t,r)},e.p="",e(e.s=3)}([function(t,r,e){"use strict";e.d(r,"a",function(){return i}),e.d(r,"h",function(){return u}),e.d(r,"b",function(){return a}),e.d(r,"c",function(){return c}),e.d(r,"f",function(){return f}),e.d(r,"g",function(){return s}),e.d(r,"d",function(){return p}),e.d(r,"e",function(){return l});var n=e(1),o=function(t){var r="function"==typeof Symbol&&t[Symbol.iterator],e=0;return r?r.call(t):{next:function(){return t&&e>=t.length&&(t=void 0),{value:t&&t[e++],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 r,e;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){r={error:t}}finally{try{u&&!u.done&&(e=n.return)&&e.call(n)}finally{if(r)throw r.error}}}function a(t,r,e,n,o,i){var u=!o(e),a=!o(n);return u!==a?(r?u:a)?-1:1:u?0:t?i(e,n):i(n,e)}function c(t,r,e,n){var o=!e(t);return o===!e(r)&&(!!o||n(t,r))}function f(t,r){void 0===t&&(t=!0),void 0===r&&(r=!1);var e=function(t){return"number"==typeof t&&isFinite(t)},n=function(t,r){return t-r};return function(o,i){return a(t,r,o,i,e,n)}}function s(t,r,e){void 0===t&&(t=!0),void 0===r&&(r=!0),void 0===e&&(e=!1);var n=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,e,t,i,n,o)}}function p(t,r){void 0===t&&(t=!0),void 0===r&&(r=!1);var e=function(t){return t instanceof Date},n=function(t,r){return t.getTime()-r.getTime()};return function(o,i){return a(t,r,o,i,e,n)}}function l(t,r){void 0===t&&(t=1),void 0===r&&(r=!0);var e=function(t){return t instanceof Date},n=r?function(t){return t.getTime()}:function(t){return t.getTime()+6e4*t.getTimezoneOffset()},o=function(r,e){return n(r)%t==n(e)%t};return function(t,r){return c(t,r,e,o)}}},function(t,r,e){"use strict";e.d(r,"a",function(){return a});var n=e(0),o=function(t,r){var e="function"==typeof Symbol&&t[Symbol.iterator];if(!e)return t;var n,o,i=e.call(t),u=[];try{for(;(void 0===r||r-- >0)&&!(n=i.next()).done;)u.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(e=i.return)&&e.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],e=0;return r?r.call(t):{next:function(){return t&&e>=t.length&&(t=void 0),{value:t&&t[e++],done:!t}}}},a=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,e){return 0===t(r,e)}),this},t.prototype.withLogic=function(t,r){return this.comparator=t,this.equality=r||function(r,e,n,o){return 0===t(r,e,n,o)},this},t.prototype.numbers=function(t,r){return void 0===t&&(t=!0),void 0===r&&(r=!1),this.withLogic(Object(n.f)(t,r))},t.prototype.strings=function(t,r,e){return void 0===t&&(t=!0),void 0===r&&(r=!0),void 0===e&&(e=!1),this.withLogic(Object(n.g)(t,r,e))},t.prototype.dates=function(t,r,e,o){return void 0===t&&(t=1),void 0===r&&(r=!0),void 0===e&&(e=!0),void 0===o&&(o=!1),this.withLogic(Object(n.d)(e,o),Object(n.e)(t,r))},t.prototype.desc=function(t){var r=t||this.comparator;return this.comparator=function(t,e,n,o){return r(e,t,o,n)},this},t.prototype.getEquality=function(r){return r||this.equality||t.EQUALS_STRICT},t.prototype.getComparator=function(t){var r=t||this.comparator;if(!r)throw new Error("A comparator is required for the requested action");return r},t.prototype.empty=function(){return!this.iterate(function(t,r,e){return e.stop()}).isStopped()},t.prototype.has=function(){return this.iterate(function(t,r,e){return e.stop()}).isStopped()},t.prototype.contains=function(t,r){var e=this;return this.where(function(n,o){return e.getEquality(r)(t,n,void 0,o)}).has()},t.prototype.count=function(){var t=0;return this.iterate(function(){return t++}),t},t.prototype.first=function(){return this.iterate(function(t,r,e){return e.stop(t)}).result},t.prototype.last=function(){var t=null;return this.iterate(function(r){return t=r}),t},t.prototype.array=function(t){return void 0===t&&(t=[]),this.iterate(function(r){return t.push(r)}),t},t.prototype.entries=function(t){return void 0===t&&(t=[]),this.iterate(function(r,e){return t.push([e,r])}),t},t.prototype.object=function(t,r){return void 0===r&&(r=Object.create(null)),this.iterate(function(e){return r[t(e)]=e}),r},t.prototype.set=function(t){return void 0===t&&(t=new Set),this.iterate(function(r){return t.add(r)}),t},t.prototype.map=function(t){return void 0===t&&(t=new Map),this.iterate(function(r,e){return t.set(e,r)}),t},t.prototype.group=function(t,r){return void 0===r&&(r=Object.create(null)),this.iterate(function(e){var n=t(e);n in r?r[n].push(e):r[n]=[e]}),r},t.prototype.reduce=function(t,r){var e=t;return this.iterate(function(t){return e=r(t,e)}),e},t.prototype.min=function(t){var r=this.getComparator(t);return this.reduce(null,function(t,e){return null===e||r(t,e)<0?t:e})},t.prototype.max=function(t){var r=this.getComparator(t);return this.reduce(null,function(t,e){return null===e||r(t,e)>0?t:e})},t.prototype.delete=function(){return this.iterate(function(t,r,e){return e.remove()})},t.prototype.extract=function(){var r=[];return this.iterate(function(t,e,n){return r.push([e,t])&&n.remove()}),t.entries(r)},t.prototype.overwrite=function(t){return this.iterate(function(r,e,n){return n.replace(t)})},t.prototype.fork=function(t){return t(this),this},t.prototype.split=function(t,r){var e=this.where(t),n=this.not(t);return r?(r(e,n),this):{pass:e,fail:n}},t.prototype.unzip=function(t){var r=this.keys(),e=this.values();return t?(t(r,e),this):{keys:r,values:e}},t.prototype.keys=function(){var r=this;return new t(function(t){var e=0;r.iterate(function(r,n,o){switch(t.act(n,e++)){case 1:o.stop();break;case 2:o.remove()}})})},t.prototype.values=function(){var r=this;return new t(function(t){r.iterate(function(r,e,n){var o=0;switch(t.act(r,o++)){case 1:n.stop();break;case 2:n.remove();break;case 3:n.replace(t.replaceWith)}})},this)},t.prototype.view=function(r,e,n,o){var i=this;return new t(function(t){var u=r();i.iterate(function(r,i,a){if(e(u,r,i)){switch(t.act(r,i)){case 1:a.stop();break;case 2:a.remove();break;case 3:a.replace(t.replaceWith)}n&&n(u,r,i,a)}else o&&o(u,r,i,a)})},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,e,n){return n.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=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return t.join.apply(t,i([this],r))},t.prototype.prepend=function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return t.join.apply(t,i(r,[this]))},t.prototype.where=function(t){return this.view(function(){return null},function(r,e,n){return t(e,n)})},t.prototype.not=function(t){return this.view(function(){return null},function(r,e,n){return!t(e,n)})},t.prototype.gt=function(t,r){var e=this;return this.view(function(){return e.getComparator(r)},function(r,e,n){return r(e,t,n)>0})},t.prototype.gte=function(t,r){var e=this;return this.view(function(){return e.getComparator(r)},function(r,e,n){return r(e,t,n)>=0})},t.prototype.lt=function(t,r){var e=this;return this.view(function(){return e.getComparator(r)},function(r,e,n){return r(e,t,n)<0})},t.prototype.lte=function(t,r){var e=this;return this.view(function(){return e.getComparator(r)},function(r,e,n){return r(e,t,n)<=0})},t.prototype.exclude=function(t,r){var e=this;return this.view(function(){return[e.getEquality(r),Object(n.h)(t)]},function(t,r){var e=o(t,2),n=e[0];return!e[1].contains(r,n)})},t.prototype.intersect=function(t,r){var e=this;return this.view(function(){return[e.getEquality(r),Object(n.h)(t)]},function(t,r){var e=o(t,2),n=e[0];return e[1].contains(r,n)})},t.prototype.unique=function(t){var r=this;return this.view(function(){return{existing:[],isEqual:r.getEquality(t)}},function(t,r,e){var n=t.existing,i=t.isEqual;return-1===n.findIndex(function(t){var n=o(t,2),u=n[0],a=n[1];return i(a,r,u,e)})},function(t,r,e){return t.existing.push([e,r])})},t.prototype.duplicates=function(t,r){var e=this;return void 0===t&&(t=!1),this.view(function(){return{existing:[],once:[],isEqual:e.getEquality(r)}},function(r,e,n){var i=r.existing,u=r.once,a=r.isEqual,c=i.findIndex(function(t){var r=o(t,2),i=r[0],u=r[1];return a(u,e,i,n)}),f=-1!==c;return f?(u[c]&&t&&(f=!1),u[c]=!0):i.push([n,e]),f})},t.prototype.readonly=function(){var r=this;return new t(function(t){r.iterate(function(r,e,n){1===t.act(r,e)&&n.stop()})},this)},t.prototype.copy=function(){return t.entries(this.entries())},t.prototype.viewResolved=function(r){var e=this;return new t(function(t){var n=e.entries(),o=[],i=[],u=[],a=!1;if(r(n,function(r,e,n){var c=t.act(r,e);return 3!==c&&2!==c||(a=!0,u[n]=r,o[n]=c,i[n]=t.replaceWith),c}),a){var c=0;e.iterate(function(t,r,e){switch(o[c]){case 2:t===u[c]&&e.remove();break;case 3:t===u[c]&&e.replace(i[c])}c++})}},this)},t.prototype.sorted=function(t){var r=this;return this.viewResolved(function(e,n){var i,a,c=r.getComparator(t),f=e.map(function(t,r){var e=o(t,2);return{key:e[0],value:e[1],index:r}});f.sort(function(t,r){return c(t.value,r.value)});try{for(var s=u(f),p=s.next();!p.done;p=s.next()){var l=p.value,h=l.key;if(1===n(l.value,h,l.index))return}}catch(t){i={error:t}}finally{try{p&&!p.done&&(a=s.return)&&a.call(s)}finally{if(i)throw i.error}}})},t.prototype.shuffle=function(t){void 0===t&&(t=1);var r=function(t,r,e){var n=t[r];t[r]=t[e],t[e]=n};return this.viewResolved(function(e,n){for(var i=[],u=e.length,a=0;a<u;a++)i.push(a);for(var c=0;c<t;c++)for(var f=0;f<u;f++){var s=Math.floor(Math.random()*u);r(e,s,f),r(i,s,f)}for(a=0;a<u;a++){var p=o(e[a],2),l=p[0];if(1===n(p[1],l,i[a]))return}})},t.prototype.reverse=function(){return this.viewResolved(function(t,r){for(var e=t.length-1;e>=0;e--){var n=o(t[e],2),i=n[0];if(1===r(n[1],i,e))return}})},t.prototype.transform=function(r,e){var n=this;return void 0===e&&(e=null),new t(function(t){n.iterate(function(n,o,i){var u=r(n,o,i);if(void 0!==u)switch(t.act(u,o)){case 1:i.stop();break;case 2:i.remove();break;case 3:e&&i.replace(e(t.replaceWith,u,n,o))}})})},t.prototype.iterate=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 new t(function(t){for(var e=0;e<r.length;e++){var n=o(r[e],2),i=n[0],u=n[1];switch(t.act(u,i)){case 1:return;case 2:r.splice(e,1),e--;break;case 3:r.splice(e,1,[i,t.replaceWith])}}})},t.array=function(r){return new t(function(t){for(var e=0;e<r.length;e++)switch(t.act(r[e],e)){case 1:return;case 2:r.splice(e,1),e--;break;case 3:r.splice(e,1,t.replaceWith)}})},t.zip=function(r,e){var o=Object(n.h)(r),i=Object(n.h)(e);return new t(function(t){var r=o.array(),e=[],n=0;if(i.iterate(function(o,i,u){if(n>=r.length)u.stop();else switch(t.act(o,r[n])){case 1:return;case 2:u.remove(),e.push(n);break;case 3:u.replace(t.replaceWith)}n++}),e.length>0){var u=0;o.iterate(function(t,r,n){u===e[0]?(n.remove(),e.shift()):0===e.length&&n.stop(),u++})}})},t.hasEntries=function(r,e,n){return new t(function(t){for(var i=r.entries(),u=i.next();!u.done;u=i.next()){var a=o(u.value,2),c=a[0],f=a[1];switch(t.act(f,c)){case 1:return;case 2:e&&e(r,c,f);break;case 3:n&&n(r,c,f,t.replaceWith)}}})},t.map=function(r){return t.hasEntries(r,function(t,r){return t.delete(r)},function(t,r,e,n){return t.set(r,n)})},t.set=function(r){return t.hasEntries(r,function(t,r){return t.delete(r)},function(t,e,n,o){return r.delete(n)&&r.add(o)})},t.iterable=function(r){return new t(function(t){for(var e=r[Symbol.iterator](),n=0,o=e.next();!o.done&&1!==t.act(o.value,n);o=e.next(),n++);})},t.object=function(r,e){return void 0===e&&(e=!0),new t(function(t){for(var n in r)if(!e||r.hasOwnProperty(n))switch(t.act(r[n],n)){case 1:return;case 2:delete r[n];break;case 3:r[n]=t.replaceWith}})},t.linked=function(r,e,n,o,i){return i||(i=function(t){return r(t)}),function(u,a){return void 0===a&&(a=!0),new t(function(t){for(var c=u,f=e(u);f&&f!==u;){var s=e(f),p=!1;switch(t.act(r(f),i(f))){case 1:return;case 2:if(n)n(f,c),p=!0;else if(a)throw new Error("remove is required for linked list iteration");break;case 3:if(o)o(f,t.replaceWith);else if(a)throw new Error("replace is required for linked list iteration")}p||(c=f),f=s}})}},t.tree=function(r,e,n,o){o||(o=function(t){return r(t)});var i=t.empty(),u=function(r){var n=e(r);return n?Array.isArray(n)?t.array(n):n:i},a=function(t,e,i,u,a){switch(e.act(r(t),o(t))){case 1:return a&&a.stop(),!1;case 3:if(n)n(t,e.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,r,e,n){return!!a(t,r,e,!1,n)&&!u(t).iterate(function(t,n,o){return c(t,r,e,o)}).isStopped()};return function(r,e,n){return void 0===e&&(e=!0),void 0===n&&(n=!0),new t(function(t){return e?c(r,t,n):function(t,r,e){var n=[];for(n.push(t);n.length>0;){var o=n.shift();if(!a(o,r,e,!0))break;u(o).array(n)}}(r,t,n)})}},t.join=function(){for(var r=[],e=0;e<arguments.length;e++)r[e]=arguments[e];return new t(function(t){var e,o,i=r.map(n.h);try{for(var a=u(i),c=a.next();!c.done;c=a.next()){var f=c.value;if(f.iterate(function(r,e,n){switch(t.act(r,e)){case 2:n.remove();break;case 1:n.stop();break;case 3:n.replace(t.replaceWith)}}),1===f.action)return}}catch(t){e={error:t}}finally{try{c&&!c.done&&(o=a.return)&&o.call(a)}finally{if(e)throw e.error}}})},t.empty=function(){return new t(function(t){})},t.EQUALS_STRICT=function(t,r){return t===r},t.EQUALS_LOOSE=function(t,r){return t==r},t}()},function(t,r){},function(t,r,e){"use strict";e.r(r);var n=e(0);e.d(r,"Generators",function(){return n.a}),e.d(r,"iterate",function(){return n.h}),e.d(r,"compare",function(){return n.b}),e.d(r,"equals",function(){return n.c}),e.d(r,"getNumberComparator",function(){return n.f}),e.d(r,"getStringComparator",function(){return n.g}),e.d(r,"getDateComparator",function(){return n.d}),e.d(r,"getDateEquality",function(){return n.e});var o=e(2);for(var i in o)["Generators","iterate","compare","equals","getNumberComparator","getStringComparator","getDateComparator","getDateEquality","default"].indexOf(i)<0&&function(t){e.d(r,t,function(){return o[t]})}(i);var u=e(1);e.d(r,"Iterate",function(){return u.a}),r.default=n.h}])});
!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}])});
//# sourceMappingURL=iteratez.js.map
{
"name": "iteratez",
"version": "1.0.0",
"version": "1.1.0",
"description": "A simple yet powerful iterator that allows iteration for even the most complex types.",

@@ -5,0 +5,0 @@ "main": "dist/iteratez.js",

@@ -13,21 +13,22 @@ # iteratez

- Iteration is lazy, so iteration is only done when it absolutely needs to be.
- Some [operations](operations) can exit early and cease iteration saving time and resources.
- Some [operations](#operations) can exit early and cease iteration saving time and resources.
- When iterating, you can stop at any time.
- If the underlying source supports it, [remove](mutations) an item.
- If the underlying source supports it, [replace](mutations) an item.
- You can chain [views](views) which don't cause iteration until an [operation](operations) or [mutation](mutations) are called.
- You can call [mutations](mutations) to affect the underlying source.
- You can call [operations](operations) to iterate and produce a result.
- Create your own iterator.
- If the underlying source supports it, [remove](#mutations) a value.
- If the underlying source supports it, [replace](#mutations) a value.
- You can chain [views](#views) which don't cause iteration until an [operation](#operations) or [mutation](#mutations) are called.
- You can call [mutations](#mutations) to affect the underlying source.
- You can call [operations](#operations) to iterate and produce a result.
- You can create a [reusable function](#reusable-function) to perform operations repeatedly.
- [Create your own iterator.](#custom-iterators)
You can see all of these features in the examples below.
You can see all of these features in the [examples](#examples) below.
### Views
Returns an iterator...
- `where`: for a subset of the items.
- `not`: for a subset of the items that don't pass test (opposite of where).
- `transform`: that transforms the items to another type.
- `reverse`: that iterates over the items in reverse order.
- `exclude`: that excludes items found in another iterator.
- `intersect`: that has common items in another iterator.
- `where`: for a subset of the values.
- `not`: for a subset of the values that don't pass test (opposite of where).
- `transform`: that transforms the values to another type.
- `reverse`: that iterates over the values in reverse order.
- `exclude`: that excludes values found in another iterator.
- `intersect`: that has common values in another iterator.
- `sorted`: that is sorted based on some comparison.

@@ -38,43 +39,43 @@ - `shuffle`: that is randomly ordered.

- `readonly`: that ignores mutations.
- `keys`: only for the keys of the items (replace not supported).
- `values`: only for the values of the items (new key is index based).
- `take`: that only iterates over the first X items.
- `skip`: that skips the first X items.
- `drop`: that drops off the last X items.
- `keys`: only for the keys of the values (replace not supported).
- `values`: only for the values (new key is index based).
- `take`: that only iterates over the first X values.
- `skip`: that skips the first X values.
- `drop`: that drops off the last X values.
- `append`: that is the original iterator + one or more iterators specified.
- `prepend`: that is one or more iterators specified + the original iterator.
- `gt`: that only has items greater than a value.
- `gte`: that only has items greater than or equal to a value.
- `lt`: that only has items less than a value.
- `lte`: that only has items less than or equal to a value.
- `gt`: that only has values greater than a value.
- `gte`: that only has values greater than or equal to a value.
- `lt`: that only has values less than a value.
- `lte`: that only has values less than or equal to a value.
- `fork`: that is this, but allows a function to perform fork operations
- `split`: Splits the items into two iterators (pass/fail) based on a condition.
- `split`: Splits the values into two iterators (pass/fail) based on a condition.
- `unzip`: Splits the view into two iterates (keys/values).
### Mutations
- `delete`: Removes items in the view from the source.
- `overwrite`: Replaces items in the view from the source.
- `extract`: Removes items in the view from the source and returns a new iterator with the removed items.
- `delete`: Removes values in the view from the source.
- `overwrite`: Replaces values in the view from the source.
- `extract`: Removes values in the view from the source and returns a new iterator with the removed values.
### Operations
- `empty`: Determines if view contains zero items.
- `has`: Determines if the view contains any items.
- `contains`: Determines if the view contains a specific item.
- `first`: Gets the first item in the view.
- `last`: Gets the last item in the view.
- `count`: Counts the number of items in the view.
- `array`: Builds an array of the items in the view.
- `set`: Builds a Set of the items in the view.
- `object`: Builds an object of the items in the view.
- `empty`: Determines if view contains zero values.
- `has`: Determines if the view contains any values.
- `contains`: Determines if the view contains a specific value.
- `first`: Gets the first value in the view.
- `last`: Gets the last value in the view.
- `count`: Counts the number of values in the view.
- `array`: Builds an array of the values in the view.
- `set`: Builds a Set of the values in the view.
- `object`: Builds an object of the values in the view.
- `entries`: Builds an array of `[key, value]` in the view.
- `map`: Builds a Map of the items and keys in the view.
- `group`: Builds an object of item arrays grouped by a value derived from each item.
- `reduce`: Reduces the items in the view down to a single value.
- `min`: Returns the minimum item in the view.
- `max`: Returns the maximum item in the view.
- `iterate`: Invokes a function for each item in the view.
- `copy`: Copies the items in the view and returns a new iterator.
- `map`: Builds a Map of the values and keys in the view.
- `group`: Builds an object of value arrays grouped by a value derived from each value.
- `reduce`: Reduces the values in the view down to a single value.
- `min`: Returns the minimum value in the view.
- `max`: Returns the maximum value in the view.
- `iterate`: Invokes a function for each value in the view.
- `copy`: Copies the values in the view and returns a new iterator.
### Comparison Logic
The following chainable functions define how items should be compared.
The following chainable functions define how values should be compared.

@@ -129,4 +130,4 @@ - `numbers`: Set number comparison logic to the iterator.

// Stop
source.iterate((item, itemKey, iter) => {
if (someCondition(item)) {
source.each((value, key, iter) => {
if (someCondition(value)) {
iter.stop(42)

@@ -143,4 +144,4 @@ }

// - otherwise, up to the custom source
source.iterate((item, itemKey, iter) => {
if (someCondition(item)) {
source.each((value, key, iter) => {
if (someCondition(value)) {
iter.remove();

@@ -151,4 +152,4 @@ }

// Replace
source.iterate((item, itemKey, iter) => {
if (someCondition(item)) {
source.each((value, key, iter) => {
if (someCondition(value)) {
iter.replace(replacement);

@@ -170,7 +171,7 @@ }

let set = source.set(); // Set<T>
let object = source.object(item => item.id); // { [item.id]: item }
let object = source.object(item => item.id, dest);
let object = source.object(value => value.id); // { [value.id]: value }
let object = source.object(value => value.id, dest);
let entries = source.entries(): // Array<[K, T]>
let map = source.map(); // Map<T, K>
let group = source.group(item => item.age); // { [age]: T[] }
let group = source.group(value => value.age); // { [age]: T[] }
let reduced = source.reduce(R, (T, R) => R); // R

@@ -183,11 +184,11 @@ let min = source.min(); // T

// These are at the end of a chain of views and they
// take the items in the current iterator and affects the
// take the values in the current iterator and affects the
// underlying source.
source.delete(); // removes all items in iterator
source.where(x => x.id).delete(); // remove items without an ID
source.delete(); // removes all values in iterator
source.where(x => x.id).delete(); // remove values without an ID
source.extract(); // does a delete and returns a new iterator with the removed items
source.extract(); // does a delete and returns a new iterator with the removed values
source.overwrite(42); // replaces all items in iterator
source.overwrite(42); // replaces all values in iterator
source.where(x => x > 34).overwrite(12); // replace all numbers over 34 with 12

@@ -197,28 +198,28 @@

// These are chainable, at the end if you call an operation it performs
// it only on the items in the iterator at that point. If you call
// it only on the values in the iterator at that point. If you call
// a mutation then it changes the underlying source but only on the
// items in the view.
// values in the view.
source.where(x => x.age > 0); // items that past test
source.not(x => x.age > 0); // items that don't pass test
source.transform(x => x.name); // items transformed to a new type
source.reverse(); // items in reverse
source.exclude(anotherSource); // not shared items
source.intersect(anotherSource); // shared items
source.where(x => x.age > 0); // values that past test
source.not(x => x.age > 0); // values that don't pass test
source.transform(x => x.name); // values transformed to a new type
source.reverse(); // values in reverse
source.exclude(anotherSource); // not shared values
source.intersect(anotherSource); // shared values
source.sorted(comparator?); // sorted by a comparator
source.shuffle(times?); // randomly orders
source.unique(equality?); // unique items only
source.duplicates(onlyOnce?); // duplicate items only
source.unique(equality?); // unique values only
source.duplicates(onlyOnce?); // duplicate values only
source.readonly(); // all subsequent mutations are ignored
source.keys(); // just the keys (index based), delete mutation works
source.values(); // just the values (index based)
source.take(10); // first 10 items
source.skip(5); // after first 5 items
source.take(10); // first 10 values
source.skip(5); // after first 5 values
source.drop(3); // ignore last 3
source.append(anotherSource); // union of two
source.prepend(anotherSource); // union in reverse order
source.gt(value, comparator?); // all items greater than value
source.gte(value, comparator?); // all items greater/equal to value
source.lt(value, comparator?); // all items less than value
source.lte(value, comparator?); // all items less/equal to value
source.gt(value, comparator?); // all values greater than value
source.gte(value, comparator?); // all values greater/equal to value
source.lt(value, comparator?); // all values less than value
source.lte(value, comparator?); // all values less/equal to value
source.fork(f => f.where(x => !!x.male).delete()); // fork operation

@@ -256,9 +257,9 @@ source.split(x => x.male); // { pass, fail }

source.transform<string>(
// transforms items to new type
item => item.name,
// if replace is called un a subsequent iteration, how do we take the transformed value and apply it back to the original item?
(replaceWith, current, item) => {
item.name = replaceWith;
// transforms values to new type
value => value.name,
// if replace is called un a subsequent iteration, how do we take the transformed value and apply it back to the original value?
(replaceWith, current, value) => {
value.name = replaceWith;
}
).iterate((name, key, iter) => {
).each((name, key, iter) => {
// Make all names uppercase in the most obtuse way possible

@@ -269,3 +270,3 @@ iter.replace(name.toUpperCase());

// Iterate with a callback
source.iterate((item, key, iter) => {
source.each((value, key, iter) => {
// iter.remove();

@@ -334,2 +335,55 @@ // iter.stop(withResult);

## Reusable Function
You can define a function which takes an iterator and performs any
number of operations. You can optionally have it return a result.
```typescript
// Iterate.func<T, R, A, K, S>
// - T = value type
// - R = function return type
// - A = array of parameter types
// - K = desired key type (restricts the source that can be passed to the function)
// - S = desired source (type passed to function must match this type)
// A function without a result. If a word contains an a, uppercase the word
const fn = Iterate.func<string>(
source => source
.where(x => x.indexOf('a') !== -1)
.update(x => x.toUpperCase())
);
// Any iterable source that has strings as values can be passed to function
const a = ['apple', 'bit', 'cat'];
fn(a);
// a = [APPLE, bit, CAT]
// A function with a result. If a word contains an a, uppercase it. Return the
// number of changed words. The counting has to happen before the update
// since the update would make no values pass the where condition.
const fn = Iterate.func<string, number>(
(source, setResult) => source
.where(x => x.indexOf('a') !== -1)
.count(setResult)
.update(x => x.toUpperCase())
);
const a = ['apple', 'bit', 'cat'];
const b = fn(a); // 2
// a = [APPLE, bit, CAT]
// A function can have special paramters passed to it.
// Given an array of people, I want a subset of that array given
// a limit and offset.
const getPage = Iterate.func<Person, Person[], [number, number]>(
(source, setResult, offset, limit) => source
.skip(offset)
.take(limit)
.array(setResult)
);
const persons: Person[] = ...;
const page = getPage(persons, 5, 10);
// page = at most 10 people starting at index 5
```
## Custom Iterators

@@ -355,3 +409,3 @@ You can add your own iterators to pick up your own types. If you are not using

// This function is called when an operation or mutation is called on iter
// You should iterate over your items and respond to the action requested
// You should iterate over your values and respond to the action requested
// In this example, if iterateNode returns false, stop all iteration

@@ -368,7 +422,7 @@ const curr = new Date(start.getTime());

// stop all iteration
case IterateAction.Stop:
case IterateAction.STOP:
return;
// remove this value, and subsequentally all children from tree
case IterateAction.Remove:
case IterateAction.REMOVE:
// doesn't apply here, this is a dynamic set

@@ -378,3 +432,3 @@ break;

// replace the value
case IterateAction.Replace:
case IterateAction.REPLACE:
// doesn't apply here, this is a dynamic set

@@ -381,0 +435,0 @@ break;

@@ -34,4 +34,8 @@ import { Iterate } from './Iterate';

export declare function iterate<T>(empty?: null): Iterate<any, any, any>;
export declare function iterate<T>(item: T): Iterate<T, number, [T]>;
export declare function iterate<T>(value: T): Iterate<T, number, [T]>;
/**
* Determines whether the given variable is a function.
*/
export declare function isFunction(x: any): x is (...args: any[]) => any;
/**
* A helper comparison function for two unknown variables. If they both

@@ -64,4 +68,15 @@ * aren't the correct type the are considered equal. If one doesn't have the

/**
* The default comparison function. If the types are not comparable, an
* error is thrown notifying the user that they need to set their own
* comparator.
*
* @param a The first value to compare.
* @param b The second value.
*/
export declare function defaultCompare(a: any, b: any, forEquals?: boolean): number;
/**
* Creates a number comparator.
*
* @param ascending If the numbers should be in ascending order.
* @param nullsFirst If non-numbers values should be ordered first.
*/

@@ -68,0 +83,0 @@ export declare function getNumberComparator<K>(ascending?: boolean, nullsFirst?: boolean): IterateCompare<number, K>;

import { IterateAction } from "./IterateAction";
import { GetKeyFor, GetValueFor, HasEntries, IterateCallback, IterateCompare, IterateEquals, IterateFilter, IterateSource, IterateSourceType, IterateSourceTypeKey } from "./types";
import { GetKeyFor, GetValueFor, HasEntries, IterateCallback, IterateCompare, IterateEquals, IterateFilter, IterateFunction, IterateFunctionExecute, IterateResult, IterateSource, IterateSourceType, IterateSourceTypeKey } from "./types";
/**

@@ -7,3 +7,3 @@ * A class that allows an iteratable source to be iterated any number of times.

* There are 3 types of functions in an Iterate:
* - **Operation**: produces a result from the items in the iterator.
* - **Operation**: produces a result from the values in the iterator.
* - **View**: produces a new iterator, the original iterator is not affected.

@@ -17,33 +17,33 @@ * - **Mutation**: modifies the source based on the values in the current iterator.

* **Operations**
* - `empty`: Determines whether the view contains no items.
* - `has`: Determines whether the view contains any items.
* - `contains`: Determines if the view contains a specific item.
* - `first`: Gets the first item in the view.
* - `last`: Gets the last item in the view.
* - `count`: Counds the number of items in the view.
* - `array`: Builds an array of the items in the view.
* - `set`: Builds a Set of the items in the view.
* - `object`: Builds an object of the items in the view.
* - `empty`: Determines whether the view contains no values.
* - `has`: Determines whether the view contains any values.
* - `contains`: Determines if the view contains a specific value.
* - `first`: Gets the first value in the view.
* - `last`: Gets the last value in the view.
* - `count`: Counds the number of values in the view.
* - `array`: Builds an array of the values in the view.
* - `set`: Builds a Set of the values in the view.
* - `object`: Builds an object of the values in the view.
* - `entries`: Builds an array of `[key, value]` in the view.
* - `map`: Builds a Map of the items and keys in the view.
* - `group`: Builds an object of item arrays grouped by a value derived from each item.
* - `reduce`: Reduces the items in the view down to a single value.
* - `min`: Returns the minimum item in the view.
* - `max`: Returns the maximum item in the view.
* - `iterate`: Invokes a function for each item in the view.
* - `copy`: Copies the items in the view and returns a new iterator.
* - `map`: Builds a Map of the values and keys in the view.
* - `group`: Builds an object of value arrays grouped by a value derived from each value.
* - `reduce`: Reduces the values in the view down to a single value.
* - `min`: Returns the minimum value in the view.
* - `max`: Returns the maximum value in the view.
* - `each`: Invokes a function for each value in the view.
* - `copy`: Copies the values in the view and returns a new iterator.
*
* **Mutations**
* - `delete`: Removes items in the view from the source.
* - `overwrite`: Replaces items in the view from the source.
* - `extract`: Removes items in the view from the source and returns a new iterator with the removed items.
* - `delete`: Removes values in the view from the source.
* - `overwrite`: Replaces values in the view from the source.
* - `extract`: Removes values in the view from the source and returns a new iterator with the removed values.
*
* **Views**
* Returns an iterator...
* - `where`: for a subset of the items.
* - `not`: for a subset of the items (opposite of where).
* - `transform`: that transforms the items to another type.
* - `reverse`: that iterates over the items in reverse order.
* - `exclude`: that excludes items found in another iterator.
* - `intersect`: that has common items in another iterator.
* - `where`: for a subset of the values.
* - `not`: for a subset of the values (opposite of where).
* - `transform`: that transforms the values to another type.
* - `reverse`: that iterates over the values in reverse order.
* - `exclude`: that excludes values found in another iterator.
* - `intersect`: that has common values in another iterator.
* - `sorted`: that is sorted based on some comparison.

@@ -54,15 +54,15 @@ * - `shuffle`: that is randomly ordered.

* - `readonly`: that ignores mutations.
* - `keys`: only for the keys of the items (replace not supported).
* - `values`: only for the values of the items (new key is index based).
* - `take`: that only iterates over the first X items.
* - `skip`: that skips the first X items.
* - `drop`: that drops off the last X items.
* - `keys`: only for the keys of the values (replace not supported).
* - `values`: only for the values of the values (new key is index based).
* - `take`: that only iterates over the first X values.
* - `skip`: that skips the first X values.
* - `drop`: that drops off the last X values.
* - `append`: that is the original iterator + one or more iterators specified.
* - `prepend`: that is one or more iterators specified + the original iterator.
* - `gt`: that only has items greater than a value.
* - `gte`: that only has items greater than or equal to a value.
* - `lt`: that only has items less than a value.
* - `lte`: that only has items less than or equal to a value.
* - `gt`: that only has values greater than a value.
* - `gte`: that only has values greater than or equal to a value.
* - `lt`: that only has values less than a value.
* - `lte`: that only has values less than or equal to a value.
* - `fork`: that is this, but allows a function to perform fork operations
* - `split`: Splits the items into two iterators (pass/fail) based on a condition.
* - `split`: Splits the values into two iterators (pass/fail) based on a condition.
* - `unzip`: Splits the view into two iterates (keys/values).

@@ -94,13 +94,6 @@ *

*
* @typeparam T The type of item being iterated.
* @typeparam T The type of value being iterated.
*/
export declare class Iterate<T, K, S> {
/**
* An equality check by reference.
*/
static EQUALS_STRICT: IterateEquals<any, any>;
/**
* An equality check by value.
*/ static EQUALS_LOOSE: IterateEquals<any, any>;
/**
* A result of the iteration passed to [[Iterate.stop]].

@@ -114,3 +107,3 @@ */

/**
* The value to replace with the current item.
* The value to replace with the current value.
*/

@@ -123,4 +116,4 @@ replaceWith: T;

/**
* The source of iterable items. This allows the iteration over any type of
* structure. The source must call the callback for each item and its
* The source of iterable values. This allows the iteration over any type of
* structure. The source must call the callback for each value and its
* recommended that the source checks the [[Iterate.iterating]] flag after

@@ -141,3 +134,3 @@ * each callback invokation.

*
* @param source The source of items to iterator.
* @param source The source of values to iterator.
*/

@@ -152,8 +145,8 @@ constructor(source: IterateSource<T, K, S>, parent?: Iterate<T, any, any>);

/**
* Passes the given item to the iterator callback and returns the action
* Passes the given value to the iterator callback and returns the action
* requested at this point in iteration.
*
* @param item The current item being iterated.
* @param value The current value being iterated.
*/
act(item: T, key: K): IterateAction;
act(value: T, key: K): IterateAction;
/**

@@ -176,3 +169,3 @@ * Stops iteration and optionally sets the result of the iteration.

/**
* Signals to the iterator source that the current item wants to be removed.
* Signals to the iterator source that the current value wants to be removed.
*/

@@ -258,11 +251,13 @@ remove(): this;

*
* @returns `true` if no valid items exist in the iterator.
* @param setResult A function to pass the result to.
*/
empty(): boolean;
empty(setResult: IterateResult<boolean>): this;
/**
* An operation that determines whether this iterator has an item.
* An operation that determines whether this iterator has a value.
*
* @returns `true` if no valid items exist in the iterator.
* @param setResult A function to pass the result to.
*/
has(): boolean;
has(setResult: IterateResult<boolean>): this;
/**

@@ -272,76 +267,100 @@ * An operation that determines whether this iterator has the given value.

* @param value The value to search for.
* @param equality An override for any existing equality logic.
* @param setResult A function to pass the result to.
*/
contains(value: T, equality?: IterateEquals<T, K>): boolean;
contains(value: T): boolean;
contains(value: T, setResult: IterateResult<boolean>): this;
/**
* An operation that counts the number of items in the iterator.
* An operation that counts the number of values in the iterator.
*
* @returns The number of items in the iterator.
* @param setResult A function to pass the count to.
*/
count(): number;
count(setResult: IterateResult<number>): this;
/**
* An operation that returns the first item in the iterator.
* An operation that returns the first value in the iterator.
*
* @returns The first item found.
* @param setResult A function to pass the first value to.
*/
first(): T;
first(setResult: IterateResult<T>): this;
/**
* An operation that returns the last item in the iterator.
* An operation that returns the last value in the iterator.
*
* @returns The last item found.
* @param setResult A function to pass the last value to.
*/
last(): T;
last(setResult: IterateResult<T>): this;
/**
* An operation that builds an array of items from the source.
* An operation that builds an array of values from the source.
*
* @param out The array to place the items in.
* @returns The reference to `out` which has had items added to it.
* @param out The array to place the values in.
* @param setResult A function to pass the array to.
*/
array(out?: T[]): T[];
array(out: T[], setResult: IterateResult<T[]>): this;
array(setResult: IterateResult<T[]>): this;
/**
* An operation that builds an array of [key, item] entries from this view.
* An operation that builds an array of [key, value] entries from this view.
*
* @param out The array to place the entries in.
* @returns The reference to `out` which has had entries added to it.
* @param setResult A function to pass the entries to.
*/
entries(out?: Array<[K, T]>): Array<[K, T]>;
entries(out: Array<[K, T]>, setResult: IterateResult<Array<[K, T]>>): this;
entries(setResult: IterateResult<Array<[K, T]>>): this;
/**
* An operation that builds an object of items from the iterator keyed by a
* An operation that builds an object of values from the iterator keyed by a
* result returned by a `getKey` function.
*
* @param getKey The function which returns the key of the object.
* @param out The object to place the items in.
* @returns The reference to `out` which has had items set to it.
* @param out The object to place the values in.
* @param setResult A function to pass the object to.
*/
object<O = {
[key: string]: T;
}>(getKey: (item: T) => keyof O, out?: O): O;
}>(getKey: (value: T) => keyof O, out?: O): O;
object<O = {
[key: string]: T;
}>(getKey: (value: T) => keyof O, out: O, setResult: IterateResult<O>): this;
object<O = {
[key: string]: T;
}>(getKey: (value: T) => keyof O, setResult: IterateResult<O>): this;
/**
* An operation that builds a Set of items from the source.
* An operation that builds a Set of values from the source.
*
* @param out The Set to place the items in.
* @returns The reference to `out` which has had items added to it.
* @param out The Set to place the values in.
* @param setResult A function to pass the set to.
*/
set(out?: Set<T>): Set<T>;
set(out: Set<T>, setResult: IterateResult<Set<T>>): this;
set(setResult: IterateResult<Set<T>>): this;
/**
* An operation that builds a Map of key-value pairs from the source.
*
* @param out The Map to place the items in.
* @returns The reference to `out` which has had items added to it.
* @param out The Map to place the values in.
* @param setResult A function to pass the map to.
*/
map(out?: Map<K, T>): Map<K, T>;
map(out: Map<K, T>, setResult: IterateResult<Map<K, T>>): this;
map(setResult: IterateResult<Map<K, T>>): this;
/**
* An operation that returns an object with arrays of items where the
* An operation that returns an object with arrays of values where the
* property of the object is a key returned by a function.
*
* @param by A function to get the key from an item.
* @param by A function to get the key from a value.
* @param out The object to add groups to.
* @returns The reference to `out` which has had items added to it.
* @param setResult A function to pass the groups to.
*/
group<G extends {
[by: string]: T[];
}>(by: (item: T) => any, out?: G): G;
}>(by: (value: T) => any, out?: G): G;
group<G extends {
[by: string]: T[];
}>(by: (value: T) => any, out: G, setResult: IterateResult<G>): this;
group<G extends {
[by: string]: T[];
}>(by: (value: T) => any, setResult: IterateResult<G>): this;
/**
* An operation that reduces all the items in the source to a single value
* given the initial value and a function to convert an item and the current
* An operation that reduces all the values in the source to a single value
* given the initial value and a function to convert a value and the current
* reduced value

@@ -351,49 +370,59 @@ *

* first time.
* @param reducer A function which takes an item in the iterator and the
* @param reducer A function which takes a value in the iterator and the
* current reduced value and returns a new reduced value.
* @param setResult A function to pass the reduced value to.
*/
reduce<R>(initial: R, reducer: (item: T, reduced: R) => R): R;
reduce<R>(initial: R, reducer: (value: T, reduced: R) => R): R;
reduce<R>(initial: R, reducer: (value: T, reduced: R) => R, setResult: IterateResult<R>): this;
/**
* An operation that returns the minimum item in this iterator. If this
* An operation that returns the minimum value in this iterator. If this
* iterator is empty null is returned.
*
* @param comparator An override for any existing comparison logic.
* @param setResult A function to pass the minimum value to.
*/
min(comparator?: IterateCompare<T, K>): T;
min(): T;
min(setResult: IterateResult<T>): this;
/**
* An operation that returns the maximum item in this iterator. If this
* An operation that returns the maximum value in this iterator. If this
* iterator is empty null is returned.
*
* @param comparator An override for any existing comparison logic.
* @param setResult A function to pass the maximum value to.
*/
max(comparator?: IterateCompare<T, K>): T;
max(): T;
max(setResult: IterateResult<T>): this;
/**
* A mutation which removes items in this iterator from the source.
* A mutation which removes values in this iterator from the source.
*/
delete(): this;
/**
* A mutation which removes items in this iterator from the source and
* returns a new iterator with the removed items.
* A mutation which removes values in this iterator from the source and
* returns a new iterator with the removed values.
*/
extract(): Iterate<T, K, Array<[K, T]>>;
extract(setResult: IterateResult<Iterate<T, K, Array<[K, T]>>>): this;
/**
* A mutation which replaces items in this iterator from the source.
* A mutation which replaces values in this view with a single given value.
*
* @param replacement The item to replace for all the items in this iterator.
* @param replacement The value to replace for all the values in this iterator.
*/
overwrite(replacement: T): this;
/**
* A mutation which replaces values in this view with a dynamically created one.
*
* @param updater A function which given a value and key returns a replacement value.
*/
update(updater: (value: T, key: K) => T): this;
/**
* Forks this view into another and returns a reference to this view.
* This allows chaining of multiple views which each perform a different
* operation or mutation. Forks are executed sequentially, so if one fork
* performs mutations the subsequent forks will see the mutated items.
* performs mutations the subsequent forks will see the mutated values.
*
* @param forker A function which takes the iterator at this point and
* performs any mutations and operations.
* @returns The reference to this iterator.
*/
fork(forker: (fork: this) => any): this;
/**
* Provides split views of the items in this iterator, one iterator gets
* passed items and the other iterator gets the failed items.
* Provides split views of the values in this iterator, one iterator gets
* passed values and the other iterator gets the failed values.
*

@@ -439,30 +468,30 @@ * You can pass a function as a second argument which recieves two iterators

* @param getData Get any necessary data needed for the view.
* @param shouldAct Based on the data and the item, should we act on it?
* @param afterAct What to do if the item was acted on.
* @param afterSkip What to do if the item was NOT acted on.
* @param shouldAct Based on the data and the value, should we act on it?
* @param afterAct What to do if the value was acted on.
* @param afterSkip What to do if the value was NOT acted on.
*/
view<D>(getData: () => D, shouldAct: (data: D, item: T, key: K) => any, afterAct?: (data: D, item: T, key: K, iter: Iterate<T, K, S>) => void, afterSkip?: (data: D, item: T, key: K, iter: Iterate<T, K, S>) => void): Iterate<T, K, S>;
view<D>(getData: () => D, shouldAct: (data: D, value: T, key: K) => any, afterAct?: (data: D, value: T, key: K, iter: Iterate<T, K, S>) => void, afterSkip?: (data: D, value: T, key: K, iter: Iterate<T, K, S>) => void): Iterate<T, K, S>;
/**
* Returns a view that only returns a maximum number of items.
* Returns a view that only returns a maximum number of values.
*
* @param amount The maximum number of items to return.
* @param amount The maximum number of values to return.
*/
take(amount: number): Iterate<T, K, S>;
/**
* Returns a view that skips the given number of items from the items
* Returns a view that skips the given number of values from the values
* in this iterator.
*
* @param amount The number of items to skip.
* @param amount The number of values to skip.
*/
skip(amount: number): Iterate<T, K, S>;
/**
* Returns a view that drops the given number of items from the end of the
* items in this iterator.
* Returns a view that drops the given number of values from the end of the
* values in this iterator.
*
* @param amount The number of items to drop from the end.
* @param amount The number of values to drop from the end.
*/
drop(amount: number): Iterate<T, K, S>;
/**
* Returns a view thats items are the items in this iterator followed
* by the items in the given iterators.
* Returns a view thats values are the values in this iterator followed
* by the values in the given iterators.
*

@@ -476,4 +505,4 @@ * @param iterators The iterators to append after this one.

/**
* Returns a view thats items are the items in the given iterators
* followed by the items in this iterator.
* Returns a view thats values are the values in the given iterators
* followed by the values in this iterator.
*

@@ -487,50 +516,50 @@ * @param iterators The iterators to prepend before this one.

/**
* Returns a view of items in this iterator which pass a `where` function.
* Returns a view of values in this iterator which pass a `where` function.
*
* @param where The function which determines if an item should be iterated.
* @param where The function which determines if a value should be iterated.
*/
where(where: IterateFilter<T, K>): Iterate<T, K, S>;
/**
* Returns a view of items in this iterator which do NOT pass a `not` function.
* Returns a view of values in this iterator which do NOT pass a `not` function.
*
* @param not The function which determines if an item should be iterated.
* @param not The function which determines if a value should be iterated.
*/
not(not: IterateFilter<T, K>): Iterate<T, K, S>;
/**
* Returns a view where all items are greater than the given value.
* Returns a view where all values are greater than the given value.
* If a comparator is not on this iterator or provided an error is thrown.
*
* @param value The value to compare against.
* @param threshold The value to compare against.
* @param comparator An override for any existing comparison logic.
*/
gt(value: T, comparator?: IterateCompare<T, K>): Iterate<T, K, S>;
gt(threshold: T, comparator?: IterateCompare<T, K>): Iterate<T, K, S>;
/**
* Returns a view where all items are greater than or equal to the given value.
* Returns a view where all values are greater than or equal to the given value.
* If a comparator is not on this iterator or provided an error is thrown.
*
* @param value The value to compare against.
* @param threshold The value to compare against.
* @param comparator An override for any existing comparison logic.
*/
gte(value: T, comparator?: IterateCompare<T, K>): Iterate<T, K, S>;
gte(threshold: T, comparator?: IterateCompare<T, K>): Iterate<T, K, S>;
/**
* Returns a view where all items are less than the given value.
* Returns a view where all values are less than the given value.
* If a comparator is not on this iterator or provided an error is thrown.
*
* @param value The value to compare against.
* @param threshold The value to compare against.
* @param comparator An override for any existing comparison logic.
*/
lt(value: T, comparator?: IterateCompare<T, K>): Iterate<T, K, S>;
lt(threshold: T, comparator?: IterateCompare<T, K>): Iterate<T, K, S>;
/**
* Returns a view where all items are less than or equal to the given value.
* Returns a view where all values are less than or equal to the given value.
* If a comparator is not on this iterator or provided an error is thrown.
*
* @param value The value to compare against.
* @param threshold The value to compare against.
* @param comparator An override for any existing comparison logic.
*/
lte(value: T, comparator?: IterateCompare<T, K>): Iterate<T, K, S>;
lte(threshold: T, comparator?: IterateCompare<T, K>): Iterate<T, K, S>;
/**
* Returns a view of this iterator which does not include the items in the
* Returns a view of this iterator which does not include the values in the
* given iterator.
*
* @param values The iterator with items to exclude.
* @param source The source of values to exclude.
* @param equality An override for any existing equality logic.

@@ -540,6 +569,6 @@ */

/**
* Returns a view which has items which are in this iterator and the given
* Returns a view which has values which are in this iterator and the given
* iterator.
*
* @param values The iterator with items to intersect with.
* @param source The source of values to intersect with.
* @param equality An override for any existing equality logic.

@@ -549,3 +578,3 @@ */

/**
* Returns a view which only contains unique items.
* Returns a view which only contains unique values.
*

@@ -556,4 +585,4 @@ * @param equality An override for any existing equality logic.

/**
* Returns a view which only contains items that have duplicates in this
* iterator. For any items that occur more than twice you can exclude them
* Returns a view which only contains values that have duplicates in this
* iterator. For any values that occur more than twice you can exclude them
* from the resulting view by passing `true` to `onlyOnce`.

@@ -570,8 +599,8 @@ *

/**
* Returns a copy of the items in this view as a new iterator.
* Returns a copy of the values in this view as a new iterator.
*/
copy(): Iterate<T, K, Array<[K, T]>>;
/**
* Returns a view which requires a fully resolved array of items. The view
* must keep track of the original item index in order to ensure removals
* Returns a view which requires a fully resolved array of values. The view
* must keep track of the original value index in order to ensure removals
* and replaces can be performed on the source.

@@ -581,5 +610,5 @@ *

*/
viewResolved(onResolve: (items: Array<[K, T]>, handleAct: (item: T, itemKey: K, index: number) => IterateAction) => void): Iterate<T, K, S>;
viewResolved(onResolve: (values: Array<[K, T]>, handleAct: (value: T, key: K, index: number) => IterateAction) => void): Iterate<T, K, S>;
/**
* Returns a view which has the items sorted.
* Returns a view which has the values sorted.
*

@@ -590,7 +619,7 @@ * @param comparator An override for any existing comparison logic.

/**
* Returns an view of items in this iterator and presents them in a random order.
* Returns an view of values in this iterator and presents them in a random order.
*/
shuffle(passes?: number): Iterate<T, K, S>;
/**
* Returns an view of items in this iterator and presents them in reverse.
* Returns an view of values in this iterator and presents them in reverse.
*/

@@ -600,17 +629,17 @@ reverse(): Iterate<T, K, S>;

* Returns an iterator where this iterator is the source and the returned
* iterator is built from transformed items pulled from items in the source
* iterator is built from transformed values pulled from values in the source
* of this iterator.
*
* @param transformer The function which transforms an item to another.
* @param transformer The function which transforms a value to another type.
* @param untransformer The function which untransforms a value when replace is called.
*/
transform<W>(transformer: IterateCallback<T, K, S, W>, untransformer?: (replaceWith: W, current: W, item: T, key: K) => T): Iterate<W, K, S>;
transform<W>(transformer: IterateCallback<T, K, S, W>, untransformer?: (replaceWith: W, current: W, value: T, key: K) => T): Iterate<W, K, S>;
/**
* Invokes the callback for each item in the source of this iterator. The
* Invokes the callback for each value in the source of this iterator. The
* second argument in the callback is the reference to this iterator and
* [[Iterate.stop]] can be called at anytime to cease iteration.
*
* @param callback The function to invoke for each item in this iterator.
* @param callback The function to invoke for each value in this iterator.
*/
iterate(callback: IterateCallback<T, K, S, any>): this;
each(callback: IterateCallback<T, K, S, any>): this;
/**

@@ -630,16 +659,16 @@ * Passes the result of the iteration to the given function if a truthy

*
* @param items The array of items to iterate.
* @param values The array of values to iterate.
* @returns A new iterator for the given array.
*/
static entries<T, K>(items: Array<[K, T]>): Iterate<T, K, Array<[K, T]>>;
static entries<T, K>(values?: Array<[K, T]>): Iterate<T, K, Array<[K, T]>>;
/**
* Returns an iterator for the given array.
*
* @param items The array of items to iterate.
* @param values The array of values to iterate.
* @returns A new iterator for the given array.
*/
static array<T>(items: T[]): Iterate<T, number, T[]>;
static array<T>(values?: T[]): Iterate<T, number, T[]>;
/**
* Returns an iterator for the keys and values specified. If the key and
* value iterators don't have the same number of items, the returned iterator
* value iterators don't have the same number of values, the returned iterator
* will have the maximum pairs possible (which is the lesser of the number

@@ -655,5 +684,3 @@ * of keys and values).

*/
static zip<T, K, S extends IterateSourceTypeKey<T, K, S>>(keys: S, values: S): Iterate<T, K, S>;
static zip<T, K>(keys: IterateSourceTypeKey<K, number>, values: IterateSourceTypeKey<T, number>): Iterate<T, K, any>;
static zip<T, K>(keys: IterateSourceType<K>, values: IterateSourceType<T>): Iterate<T, K, any>;
static zip<J, K extends GetValueFor<J>, S, T extends GetValueFor<S>>(keySource: J, valueSource: S): Iterate<T, K, [J, S]>;
/**

@@ -666,24 +693,24 @@ * Returns an iterator for any object which has an entries() iterable.

*/
static hasEntries<T, K, E extends HasEntries<T, K>>(hasEntries: E, onRemove?: (entries: E, key: K, value: T) => any, onReplace?: (entries: E, key: K, value: T, newValue: T) => any): Iterate<T, K, E>;
static hasEntries<T, K, E extends HasEntries<T, K>>(hasEntries?: E, onRemove?: (entries: E, key: K, value: T) => any, onReplace?: (entries: E, key: K, value: T, newValue: T) => any): Iterate<T, K, E>;
/**
* Returns an iterator for the given Map.
*
* @param items The Map of key-value pairs to iterate.
* @param values The Map of key-value pairs to iterate.
* @returns A new iterator for the given Map.
*/
static map<T, K>(items: Map<K, T>): Iterate<T, K, Map<K, T>>;
static map<T, K>(values?: Map<K, T>): Iterate<T, K, Map<K, T>>;
/**
* Returns an iterator for the given Set.
*
* @param items The Set of items to iterate.
* @param values The Set of values to iterate.
* @returns A new iterator for the given Set.
*/
static set<T>(items: Set<T>): Iterate<T, T, Set<T>>;
static set<T>(values?: Set<T>): Iterate<T, T, Set<T>>;
/**
* Returns an iterator for any iterable. Because iterables don't support
*
* @param items The iterable collection.
* @param values The iterable collection.
* @returns A new iterator for the given set.
*/
static iterable<T, I extends Iterable<T>>(items: I): Iterate<T, number, I>;
static iterable<T>(values: Iterable<T>): Iterate<T, number, Iterable<T>>;
/**

@@ -693,7 +720,7 @@ * Returns an iterator for the given object optionally checking the

*
* @param items The object to iterate.
* @param values The object to iterate.
* @param hasOwnProperty If `hasOwnProperty` should be checked.
* @returns A new iterator for the given object.
*/
static object<T>(items: {
static object<T>(values: {
[key: string]: T;

@@ -718,3 +745,3 @@ }, hasOwnProperty?: boolean): Iterate<T, string, {

*/
static linked<N, T = any, K = T>(getValue: (node: N) => T, getNext: (node: N) => N | undefined | null, remove?: (node: N, prev: N) => any, replaceValue?: (node: N, value: T) => any, getKey?: (node: N) => K): (previousNode: N, strict?: boolean) => Iterate<T, K, N>;
static linked<N, T = any, K = T>(getValue: (node: N) => T, getNext: (node: N) => N | undefined | null, remove?: (node: N, prev: N) => any, replaceValue?: (node: N, value: T) => any, getKey?: (node: N) => K): (previousNode?: N, strict?: boolean) => Iterate<T, K, N>;
/**

@@ -730,6 +757,6 @@ * Returns a function for iterating over a tree. You pass a node to the

*/
static tree<N, T = any, K = T>(getValue: (node: N) => T, getChildren: (node: N) => N[] | Iterate<N, any, any> | undefined | null, replaceValue?: (node: N, value: T) => any, getKey?: (node: N) => K): (startingNode: N, depthFirst?: boolean, strict?: boolean) => Iterate<T, K, N>;
static tree<N, T = any, K = T>(getValue: (node: N) => T, getChildren: (node: N) => N[] | Iterate<N, any, any> | undefined | null, replaceValue?: (node: N, value: T) => any, getKey?: (node: N) => K): (startingNode?: N, depthFirst?: boolean, strict?: boolean) => Iterate<T, K, N>;
/**
* Joins all the given sources into a single iterator where the items
* returned are in the same order as passed to this function. If any items
* Joins all the given sources into a single iterator where the values
* returned are in the same order as passed to this function. If any values
* are removed from the returned iterator they will be removed from the given

@@ -747,7 +774,14 @@ * iterator if it supports removal.

/**
* Returns a new iterator with no items.
* Returns a new iterator with no values.
*
* @returns A new iterator with no items.
* @returns A new iterator with no values.
*/
static empty<T, K, S>(): Iterate<T, K, S>;
/**
* Generates a reusable function which takes a source and performs a
* pre-defined set of views, operations, and mutations.
*
* @param execute The function which performs the function.
*/
static func<T = any, R = void, A extends any[] = [], K = any, S = any>(execute: IterateFunctionExecute<T, R, A, K, S>): IterateFunction<T, R, A, K, S>;
}
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