iterable-linq-utility 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -5
- package/dist/index.d.cts +373 -1
- package/dist/index.d.ts +373 -1
- package/dist/iterable-linq-utility.js +270 -119
- package/dist/iterable-linq-utility.umd.cjs +1 -1
- package/package.json +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.IterableLinq={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.defineProperty,n=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r};function r(e){return typeof e==`function`}function i(e,t){return e<t?-1:e===t?0:1}function a(e){if(e==null)return i;if(r(e))return e;let t=Array.isArray(e)?e:[e];return(e,n)=>{for(let r of t){let t=i(e[r],n[r]);if(t!==0)return t}return 0}}function o(e,t,n){let r,i=!1;for(let a of e)!i||r==null&&a!=null?(r=a,i=!0):a!=null&&n*t(r,a)<0&&(r=a);return r}function s(e){return{done:!1,value:e}}function c(e){return{done:!0,value:e}}function l(e){if(e==null)throw Error(`The "sourceIterable" must be provided`);if(!r(e[Symbol.iterator]))throw Error(`The provided "sourceIterable" does not conform to the iterator protocol https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol. It must implement the "[Symbol.iterator]" function.`)}function u(e,t){if(!r(e))throw Error(`The "${t}" function must be provided`)}function d(e,t){if(!Number.isInteger(e)||e<0)throw Error(`The "${t}" parameter must be a non-negative integer`)}function f(e,t){if(!Number.isFinite(e)||e===0)throw Error(`The "${t}" parameter must be a finite number other than 0`)}function ee(e,t){if(typeof e!=`object`||!e)throw Error(`The "${t}" parameter must be an object`)}function te(e,t){if(typeof e!=`string`||e.length===0)throw Error(`The "${t}" parameter must be a non-empty string`)}function p(e){if(l(e),Array.isArray(e)||e instanceof Set)return Array.from(e);let t=[];for(let n of e)t.push(n);return t}var m=class{done=!1;next(){if(this.done)return c();let e=this.advance();return e.done===!0&&(this.done=!0),e}return(e){return this.done||(this.done=!0,this.onReturn(e)),c(e)}[Symbol.iterator](){return this}onReturn(e){}closeAfterCallbackError(){if(!this.done){this.done=!0;try{this.onReturn()}catch{}}}},h=class{createIterator;constructor(e){this.createIterator=e}[Symbol.iterator](){return this.createIterator()}},g=class extends m{source;index=0;constructor(e){super(),this.source=e[Symbol.iterator]()}onReturn(e){this.source.return?.(e)}};function _(e,t){return new h(()=>new ne(e,t))}var ne=class extends m{state;step;constructor(e,t){super(),this.state=e,this.step=t}advance(){let e=this.step(this.state);return e===void 0?c():(this.state=e[1],s(e[0]))}};function v(){return _(void 0,()=>void 0)}function y(e,t){return l(e),u(t,`predicate`),new h(()=>new re(e,t))}var re=class extends g{predicate;constructor(e,t){super(e),this.predicate=t}advance(){for(let e=this.source.next();;e=this.source.next()){if(e.done===!0)return e;let t;try{t=this.predicate(e.value,this.index++)}catch(e){throw this.closeAfterCallbackError(),e}if(t)return e}}};function b(e,t){return l(e),u(t,`mapper`),new h(()=>new ie(e,t))}var ie=class e extends g{mapper;static steps={outer:t=>{let n=t.source.next();if(n.done===!0)return n;let r=e.mapNext(t,n.value);if(r===void 0){t.state=`inner`;return}if(r.length!==0)return t.array=r,t.position=1,t.state=`array`,s(r[0])},inner:t=>{let n=e.nextInner(t);if(n.done!==!0)return n;t.inner=void 0,t.state=`outer`},array:e=>{if(e.position<e.array.length)return s(e.array[e.position++]);e.array=void 0,e.state=`outer`}};state=`outer`;inner;array;position=0;constructor(e,t){super(e),this.mapper=t}advance(){for(;;){let t=e.steps[this.state](this);if(t!==void 0)return t}}onReturn(e){this.array=void 0;try{this.inner?.return?.(e)}finally{super.onReturn(e)}}static mapNext(e,t){try{let n=e.mapper(t,e.index++);if(Array.isArray(n))return n;e.inner=n[Symbol.iterator]();return}catch(t){throw e.closeAfterCallbackError(),t}}static nextInner(e){try{return e.inner.next()}catch(t){throw e.inner=void 0,e.closeAfterCallbackError(),t}}},x=class e{static instance=e.createFrozen();constructor(){}static createFrozen(){let t=new e;return Object.freeze(t),t}};function S(){return x.instance}function C(e,t){l(e),u(t,`action`);let n=0;for(let r of e)t(r,n++);return S()}async function w(e,t){l(e),u(t,`action`);let n=0;for(let r of e)await t(r,n++);return S()}function T(e,t){return l(e),u(t,`mapper`),new h(()=>new ae(e,t))}var ae=class extends g{mapper;constructor(e,t){super(e),this.mapper=t}advance(){let e=this.source.next();if(e.done===!0)return e;let t;try{t=this.mapper(e.value,this.index++)}catch(e){throw this.closeAfterCallbackError(),e}return s(t)}};function oe(e){l(e);let t=new se;for(let n of e)t.addLast(n);return t}var se=class{internalSize=0;head=null;tail=null;[Symbol.iterator](){return new ce(this.head)}addFirst(e){let t={data:e,nextNode:this.head};return this.tail===null&&(this.tail=t),this.head=t,this.internalSize++,this}addLast(e){let t={data:e,nextNode:null};return this.tail===null?this.head=t:this.tail.nextNode=t,this.tail=t,this.internalSize++,this}size(){return this.internalSize}},ce=class extends m{current;constructor(e){super(),this.current=e}advance(){let e=this.current;return e===null?c():(this.current=e.nextNode,s(e.data))}};function E(e){return l(e),e instanceof D?e:new D(e)}var D=class{source;constructor(e){this.source=oe(e)}[Symbol.iterator](){return this.source[Symbol.iterator]()}};function O(e,t){return l(e),o(e,a(t),1)}function k(){return{allowPartialMemoization:!0}}function A(e,t){l(e);let n={...k(),...t}.allowPartialMemoization;return e instanceof N?n?e.changePartialMemoizationBehaviour():e:e instanceof P?n?e:e.changePartialMemoizationBehaviour():n?new P(e):new N(e)}function j(){return{values:[],finished:!1}}function M(e,t){if(t.error)throw t.error.value;if(t.finished)return!1;t.source??=e[Symbol.iterator]();let n;try{n=t.source.next()}catch(e){throw t.error={value:e},t.source=void 0,e}return n.done===!0?(t.finished=!0,t.source=void 0,!1):(t.values.push(n.value),!0)}var N=class{source;cache=j();constructor(e){this.source=e}[Symbol.iterator](){return new F(this.source,this.cache,!0)}changePartialMemoizationBehaviour(){return new P(this.source)}},P=class{source;cache=j();constructor(e){this.source=e}[Symbol.iterator](){return new F(this.source,this.cache,!1)}changePartialMemoizationBehaviour(){return new N(this.source)}},F=class extends m{source;cache;drainFirst;index=0;constructor(e,t,n){super(),this.source=e,this.cache=t,this.drainFirst=n}advance(){if(this.drainFirst)for(;M(this.source,this.cache););return this.index<this.cache.values.length||M(this.source,this.cache)?s(this.cache.values[this.index++]):c()}};function I(e,t){return l(e),o(e,a(t),-1)}function L(e,t,n){let r=typeof t==`number`,i=r?e:0,a=r?t:e;if(!r&&n!==void 0)throw Error(`The "options" parameter must be the second argument when "start" is omitted`);let o=r?n:t;o!==void 0&&ee(o,`options`);let{step:s=1,reverse:c=!1}=o??{};f(s,`step`);let l=le(i,a,Math.abs(s),c);return l.length>0?new h(()=>new ue(l.first,l.step,l.length)):v()}function le(e,t,n,r){let i=t<e?-n:n,a=Math.ceil(Math.abs(t-e)/n);return r?{first:e+(a-1)*i,step:-i,length:a}:{first:e,step:i,length:a}}var ue=class extends m{first;step;length;index=0;constructor(e,t,n){super(),this.first=e,this.step=t,this.length=n}advance(){return this.index>=this.length?c():s(this.first+this.index++*this.step)}};function R(e,...t){if(l(e),t.length===1)return de(e,t[0]);let[n,r]=t;u(r,`reducer`);let i=n,a=0;for(let t of e)i=r(i,t,a++);return i}function de(e,t){u(t,`reducer`);let n,r=0;for(let i of e)n=r===0?i:t(n,i,r),r++;if(r===0)throw Error(`The "sourceIterable" must not be empty when "reduce" has no seed`);return n}function z(e,t){return d(t,`count`),_(t,t=>t>0?[e,t-1]:void 0)}function B(e,t){return l(e),d(t,`count`),new h(()=>new V(e,t))}var V=class extends g{count;constructor(e,t){super(e),this.count=t}advance(){for(;this.index<this.count;){let e=this.source.next();if(e.done===!0)return e;this.index++}return this.source.next()}};function H(e,t){if(l(e),t===void 0){for(let t of e)return!0;return!1}u(t,`predicate`);let n=0;for(let r of e)if(t(r,n++))return!0;return!1}function U(e,t){return l(e),d(t,`count`),new h(()=>new fe(e,t))}var fe=class extends g{count;constructor(e,t){super(e),this.count=t}advance(){if(this.index>=this.count)return this.source.return?.(),c();let e=this.source.next();return e.done===!0?e:(this.index++,s(e.value))}};function W(e,t){return l(e),u(t,`tapper`),new h(()=>new pe(e,t))}var pe=class extends g{tapper;constructor(e,t){super(e),this.tapper=t}advance(){let e=this.source.next();if(e.done===!0)return e;try{this.tapper(e.value,this.index++)}catch(e){throw this.closeAfterCallbackError(),e}return e}};function G(e,t){return l(e),u(t,`tapper`),new h(()=>(t(e,0),e[Symbol.iterator]()))}var me=n({collectToArray:()=>p,empty:()=>v,filter:()=>y,flatMap:()=>b,forEach:()=>C,forEachAsync:()=>w,getMemoizeDefaultOptions:()=>k,map:()=>T,materialize:()=>E,max:()=>O,memoize:()=>A,min:()=>I,range:()=>L,reduce:()=>R,repeat:()=>z,skip:()=>B,some:()=>H,take:()=>U,tap:()=>W,tapChain:()=>G}),K=Symbol.for(`iterable-linq-utility.IIterableLinq`);function q(e){return new J(e)}var J=class{iterable;constructor(e){this.iterable=e}[Symbol.iterator](){return this.iterable[Symbol.iterator]()}collectToArray(){return p(this.iterable)}filter(e){return q(y(this.iterable,e))}flatMap(e){return q(b(this.iterable,e))}forEach(e){return C(this.iterable,e)}forEachAsync(e){return w(this.iterable,e)}map(e){return q(T(this.iterable,e))}materialize(){return q(E(this.iterable))}max(e){return O(this.iterable,e)}memoize(e){return q(A(this.iterable,e))}min(e){return I(this.iterable,e)}reduce(...e){return e.length===1?R(this.iterable,e[0]):R(this.iterable,e[0],e[1])}skip(e){return q(B(this.iterable,e))}some(e){return H(this.iterable,e)}take(e){return q(U(this.iterable,e))}tap(e){return q(W(this.iterable,e))}tapChain(e){return q(G(this.iterable,e))}tapChainCreation(e){u(e,`chainCreationTapper`);let t=this;return e(t),t}};Object.defineProperty(J.prototype,K,{value:!0,enumerable:!1,writable:!1,configurable:!1});function Y(){return J.prototype}function he(e){return typeof e==`object`&&!!e&&e[K]===!0}function X(e,t){let n=Object.getOwnPropertyDescriptor(Y(),e);Object.defineProperty(Y(),e,{value:t,enumerable:!1,writable:n?.writable??!1,configurable:!0})}function Z(e,t){te(e,`name`),u(t,`implementation`)}function Q(e,t){if(Z(e,t),e in q([]))throw Error(`"${e}" already exists on IIterableLinq: use override() to replace it`);X(e,t)}function ge(e,t){Z(e,t);let n=e;if(!(n!==`constructor`&&Object.prototype.hasOwnProperty.call(Y(),n)))throw Error(`"${n}" is not a method of IIterableLinq: use extend() to add it`);X(n,t)}function _e(){return $(v())}function $(e){return l(e),q(e)}function ve(e,t,n){if(typeof t==`number`)return $(L(e,t,n));if(n!==void 0)throw Error(`The "options" parameter must be the second argument when "start" is omitted`);return $(L(e,t))}function ye(e,t){return $(z(e,t))}Object.defineProperty(e,"Functions",{enumerable:!0,get:function(){return me}}),e.Unit=x,e.empty=_e,e.extend=Q,e.from=$,e.fromRange=ve,e.isIterableLinq=he,e.override=ge,e.repeat=ye,e.unit=S});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.IterableLinq={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Object.defineProperty,n=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r};function r(e){return typeof e==`function`}function i(e,t){return e<t?-1:e===t?0:1}function a(e){if(e==null)return i;if(r(e))return e;let t=Array.isArray(e)?e:[e];return(e,n)=>{for(let r of t){let t=i(e[r],n[r]);if(t!==0)return t}return 0}}function o(e,t,n){let r,i=!1;for(let a of e)!i||r==null&&a!=null?(r=a,i=!0):a!=null&&n*t(r,a)<0&&(r=a);return r}function s(e){return{done:!1,value:e}}function c(e){return{done:!0,value:e}}function l(e){if(e==null)throw Error(`The "sourceIterable" must be provided`);if(!r(e[Symbol.iterator]))throw Error(`The provided "sourceIterable" does not conform to the iterator protocol https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterable_protocol. It must implement the "[Symbol.iterator]" function.`)}function u(e,t){if(!r(e))throw Error(`The "${t}" function must be provided`)}function d(e,t){if(!Number.isInteger(e)||e<0)throw Error(`The "${t}" parameter must be a non-negative integer`)}function ee(e,t){if(!Number.isFinite(e)||e===0)throw Error(`The "${t}" parameter must be a finite number other than 0`)}function te(e,t){if(typeof e!=`object`||!e)throw Error(`The "${t}" parameter must be an object`)}function ne(e,t){if(typeof e!=`string`||e.length===0)throw Error(`The "${t}" parameter must be a non-empty string`)}function re(e){if(l(e),Array.isArray(e)||e instanceof Set)return Array.from(e);let t=[];for(let n of e)t.push(n);return t}function f(e,t){l(e);let n=0;if(t===void 0){for(let t of e)n++;return n}u(t,`predicate`);let r=0;for(let i of e)t(i,r++)&&n++;return n}var p=class{done=!1;next(){if(this.done)return c();let e=this.advance();return e.done===!0&&(this.done=!0),e}return(e){return this.done||(this.done=!0,this.onReturn(e)),c(e)}[Symbol.iterator](){return this}onReturn(e){}closeAfterCallbackError(){if(!this.done){this.done=!0;try{this.onReturn()}catch{}}}},m=class{createIterator;constructor(e){this.createIterator=e}[Symbol.iterator](){return this.createIterator()}},h=class extends p{source;index=0;constructor(e){super(),this.source=e[Symbol.iterator]()}onReturn(e){this.source.return?.(e)}};function g(e,t){return new m(()=>new ie(e,t))}var ie=class extends p{state;step;constructor(e,t){super(),this.state=e,this.step=t}advance(){let e=this.step(this.state);return e===void 0?c():(this.state=e[1],s(e[0]))}};function ae(e,t){return l(e),t!==void 0&&u(t,`keySelector`),new m(()=>new oe(e,t))}var oe=class extends h{keySelector;seen=new Set;constructor(e,t){super(e),this.keySelector=t}advance(){for(let e=this.source.next();;e=this.source.next()){if(e.done===!0)return e;let t=e.value;if(this.keySelector!==void 0)try{t=this.keySelector(e.value,this.index++)}catch(e){throw this.closeAfterCallbackError(),e}if(!this.seen.has(t))return this.seen.add(t),e}}};function _(){return g(void 0,()=>void 0)}function v(e,t){l(e),u(t,`predicate`);let n=0;for(let r of e)if(!t(r,n++))return!1;return!0}function se(e,t){return l(e),u(t,`predicate`),new m(()=>new ce(e,t))}var ce=class extends h{predicate;constructor(e,t){super(e),this.predicate=t}advance(){for(let e=this.source.next();;e=this.source.next()){if(e.done===!0)return e;let t;try{t=this.predicate(e.value,this.index++)}catch(e){throw this.closeAfterCallbackError(),e}if(t)return e}}};function y(e,t){l(e),u(t,`predicate`);let n=0;for(let r of e)if(t(r,n++))return r}function b(e,t){l(e),u(t,`predicate`);let n=0;for(let r of e){if(t(r,n))return n;n++}return-1}function x(e,t){return l(e),u(t,`mapper`),new m(()=>new le(e,t))}var le=class e extends h{mapper;static steps={outer:t=>{let n=t.source.next();if(n.done===!0)return n;let r=e.mapNext(t,n.value);if(r===void 0){t.state=`inner`;return}if(r.length!==0)return t.array=r,t.position=1,t.state=`array`,s(r[0])},inner:t=>{let n=e.nextInner(t);if(n.done!==!0)return n;t.inner=void 0,t.state=`outer`},array:e=>{if(e.position<e.array.length)return s(e.array[e.position++]);e.array=void 0,e.state=`outer`}};state=`outer`;inner;array;position=0;constructor(e,t){super(e),this.mapper=t}advance(){for(;;){let t=e.steps[this.state](this);if(t!==void 0)return t}}onReturn(e){this.array=void 0;try{this.inner?.return?.(e)}finally{super.onReturn(e)}}static mapNext(e,t){try{let n=e.mapper(t,e.index++);if(Array.isArray(n))return n;e.inner=n[Symbol.iterator]();return}catch(t){throw e.closeAfterCallbackError(),t}}static nextInner(e){try{return e.inner.next()}catch(t){throw e.inner=void 0,e.closeAfterCallbackError(),t}}},S=class e{static instance=e.createFrozen();constructor(){}static createFrozen(){let t=new e;return Object.freeze(t),t}};function C(){return S.instance}function w(e,t){l(e),u(t,`action`);let n=0;for(let r of e)t(r,n++);return C()}async function T(e,t){l(e),u(t,`action`);let n=0;for(let r of e)await t(r,n++);return C()}function E(e,t){l(e);let n=t!==t;for(let r of e)if(r===t||n&&r!==r)return!0;return!1}function D(e,t){return l(e),u(t,`mapper`),new m(()=>new ue(e,t))}var ue=class extends h{mapper;constructor(e,t){super(e),this.mapper=t}advance(){let e=this.source.next();if(e.done===!0)return e;let t;try{t=this.mapper(e.value,this.index++)}catch(e){throw this.closeAfterCallbackError(),e}return s(t)}};function de(e){l(e);let t=new fe;for(let n of e)t.addLast(n);return t}var fe=class{internalSize=0;head=null;tail=null;[Symbol.iterator](){return new pe(this.head)}addFirst(e){let t={data:e,nextNode:this.head};return this.tail===null&&(this.tail=t),this.head=t,this.internalSize++,this}addLast(e){let t={data:e,nextNode:null};return this.tail===null?this.head=t:this.tail.nextNode=t,this.tail=t,this.internalSize++,this}size(){return this.internalSize}},pe=class extends p{current;constructor(e){super(),this.current=e}advance(){let e=this.current;return e===null?c():(this.current=e.nextNode,s(e.data))}};function O(e){return l(e),e instanceof k?e:new k(e)}var k=class{source;constructor(e){this.source=de(e)}[Symbol.iterator](){return this.source[Symbol.iterator]()}};function A(e,t){return l(e),o(e,a(t),1)}function j(){return{allowPartialMemoization:!0}}function M(e,t){l(e);let n={...j(),...t}.allowPartialMemoization;return e instanceof P?n?e.changePartialMemoizationBehaviour():e:e instanceof F?n?e:e.changePartialMemoizationBehaviour():n?new F(e):new P(e)}function N(){return{values:[],finished:!1}}function me(e,t){if(t.error)throw t.error.value;if(t.finished)return!1;t.source??=e[Symbol.iterator]();let n;try{n=t.source.next()}catch(e){throw t.error={value:e},t.source=void 0,e}return n.done===!0?(t.finished=!0,t.source=void 0,!1):(t.values.push(n.value),!0)}var P=class{source;cache=N();constructor(e){this.source=e}[Symbol.iterator](){return new I(this.source,this.cache,!0)}changePartialMemoizationBehaviour(){return new F(this.source)}},F=class{source;cache=N();constructor(e){this.source=e}[Symbol.iterator](){return new I(this.source,this.cache,!1)}changePartialMemoizationBehaviour(){return new P(this.source)}},I=class extends p{source;cache;drainFirst;index=0;constructor(e,t,n){super(),this.source=e,this.cache=t,this.drainFirst=n}advance(){if(this.drainFirst)for(;me(this.source,this.cache););return this.index<this.cache.values.length||me(this.source,this.cache)?s(this.cache.values[this.index++]):c()}};function L(e,t){return l(e),o(e,a(t),-1)}function R(e,t,n){let r=typeof t==`number`,i=r?e:0,a=r?t:e;if(!r&&n!==void 0)throw Error(`The "options" parameter must be the second argument when "start" is omitted`);let o=r?n:t;o!==void 0&&te(o,`options`);let{step:s=1,reverse:c=!1}=o??{};ee(s,`step`);let l=he(i,a,Math.abs(s),c);return l.length>0?new m(()=>new ge(l.first,l.step,l.length)):_()}function he(e,t,n,r){let i=t<e?-n:n,a=Math.ceil(Math.abs(t-e)/n);return r?{first:e+(a-1)*i,step:-i,length:a}:{first:e,step:i,length:a}}var ge=class extends p{first;step;length;index=0;constructor(e,t,n){super(),this.first=e,this.step=t,this.length=n}advance(){return this.index>=this.length?c():s(this.first+this.index++*this.step)}};function z(e,...t){if(l(e),t.length===1)return _e(e,t[0]);let[n,r]=t;u(r,`reducer`);let i=n,a=0;for(let t of e)i=r(i,t,a++);return i}function _e(e,t){u(t,`reducer`);let n,r=0;for(let i of e)n=r===0?i:t(n,i,r),r++;if(r===0)throw Error(`The "sourceIterable" must not be empty when "reduce" has no seed`);return n}function B(e,t){return d(t,`count`),g(t,t=>t>0?[e,t-1]:void 0)}function V(e,t){return l(e),d(t,`count`),new m(()=>new ve(e,t))}var ve=class extends h{count;constructor(e,t){super(e),this.count=t}advance(){for(;this.index<this.count;){let e=this.source.next();if(e.done===!0)return e;this.index++}return this.source.next()}};function H(e,t){return l(e),u(t,`predicate`),new m(()=>new ye(e,t))}var ye=class extends h{predicate;skipping=!0;constructor(e,t){super(e),this.predicate=t}advance(){if(!this.skipping)return this.source.next();for(let e=this.source.next();;e=this.source.next()){if(e.done===!0)return e;let t;try{t=this.predicate(e.value,this.index++)}catch(e){throw this.closeAfterCallbackError(),e}if(!t)return this.skipping=!1,e}}};function U(e,t){if(l(e),t===void 0){for(let t of e)return!0;return!1}u(t,`predicate`);let n=0;for(let r of e)if(t(r,n++))return!0;return!1}function W(e,t){return l(e),d(t,`count`),new m(()=>new be(e,t))}var be=class extends h{count;constructor(e,t){super(e),this.count=t}advance(){if(this.index>=this.count)return this.source.return?.(),c();let e=this.source.next();return e.done===!0?e:(this.index++,s(e.value))}};function G(e,t){return l(e),u(t,`predicate`),new m(()=>new xe(e,t))}var xe=class extends h{predicate;constructor(e,t){super(e),this.predicate=t}advance(){let e=this.source.next();if(e.done===!0)return e;let t;try{t=this.predicate(e.value,this.index++)}catch(e){throw this.closeAfterCallbackError(),e}return t?e:(this.source.return?.(),c())}};function K(e,t){return l(e),u(t,`tapper`),new m(()=>new Se(e,t))}var Se=class extends h{tapper;constructor(e,t){super(e),this.tapper=t}advance(){let e=this.source.next();if(e.done===!0)return e;try{this.tapper(e.value,this.index++)}catch(e){throw this.closeAfterCallbackError(),e}return e}};function q(e,t){return l(e),u(t,`tapper`),new m(()=>(t(e,0),e[Symbol.iterator]()))}var Ce=n({collectToArray:()=>re,count:()=>f,distinct:()=>ae,empty:()=>_,every:()=>v,filter:()=>se,find:()=>y,findIndex:()=>b,flatMap:()=>x,forEach:()=>w,forEachAsync:()=>T,getMemoizeDefaultOptions:()=>j,includes:()=>E,map:()=>D,materialize:()=>O,max:()=>A,memoize:()=>M,min:()=>L,range:()=>R,reduce:()=>z,repeat:()=>B,skip:()=>V,skipWhile:()=>H,some:()=>U,take:()=>W,takeWhile:()=>G,tap:()=>K,tapChain:()=>q}),J=Symbol.for(`iterable-linq-utility.IIterableLinq`);function Y(e){return new X(e)}var X=class{iterable;constructor(e){this.iterable=e}[Symbol.iterator](){return this.iterable[Symbol.iterator]()}collectToArray(){return re(this.iterable)}count(e){return f(this.iterable,e)}distinct(e){return Y(ae(this.iterable,e))}every(e){return v(this.iterable,e)}filter(e){return Y(se(this.iterable,e))}find(e){return y(this.iterable,e)}findIndex(e){return b(this.iterable,e)}flatMap(e){return Y(x(this.iterable,e))}forEach(e){return w(this.iterable,e)}forEachAsync(e){return T(this.iterable,e)}includes(e){return E(this.iterable,e)}map(e){return Y(D(this.iterable,e))}materialize(){return Y(O(this.iterable))}max(e){return A(this.iterable,e)}memoize(e){return Y(M(this.iterable,e))}min(e){return L(this.iterable,e)}reduce(...e){return e.length===1?z(this.iterable,e[0]):z(this.iterable,e[0],e[1])}skip(e){return Y(V(this.iterable,e))}skipWhile(e){return Y(H(this.iterable,e))}some(e){return U(this.iterable,e)}take(e){return Y(W(this.iterable,e))}takeWhile(e){return Y(G(this.iterable,e))}tap(e){return Y(K(this.iterable,e))}tapChain(e){return Y(q(this.iterable,e))}tapChainCreation(e){u(e,`chainCreationTapper`);let t=this;return e(t),t}};Object.defineProperty(X.prototype,J,{value:!0,enumerable:!1,writable:!1,configurable:!1});function Z(){return X.prototype}function we(e){return typeof e==`object`&&!!e&&e[J]===!0}function Q(e,t){let n=Object.getOwnPropertyDescriptor(Z(),e);Object.defineProperty(Z(),e,{value:t,enumerable:!1,writable:n?.writable??!1,configurable:!0})}function Te(e,t){ne(e,`name`),u(t,`implementation`)}function Ee(e,t){if(Te(e,t),e in Y([]))throw Error(`"${e}" already exists on IIterableLinq: use override() to replace it`);Q(e,t)}function De(e,t){Te(e,t);let n=e;if(!(n!==`constructor`&&Object.prototype.hasOwnProperty.call(Z(),n)))throw Error(`"${n}" is not a method of IIterableLinq: use extend() to add it`);Q(n,t)}function Oe(){return $(_())}function $(e){return l(e),Y(e)}function ke(e,t,n){if(typeof t==`number`)return $(R(e,t,n));if(n!==void 0)throw Error(`The "options" parameter must be the second argument when "start" is omitted`);return $(R(e,t))}function Ae(e,t){return $(B(e,t))}Object.defineProperty(e,"Functions",{enumerable:!0,get:function(){return Ce}}),e.Unit=S,e.empty=Oe,e.extend=Ee,e.from=$,e.fromRange=ke,e.isIterableLinq=we,e.override=De,e.repeat=Ae,e.unit=C});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iterable-linq-utility",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "An Iterable mutation utility inspired by .net Linq and Javascript Array interface",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/iterable-linq-utility.umd.cjs",
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"build": "tsc -p tsconfig.build.json && vite build && cp dist/index.d.ts dist/index.d.cts",
|
|
26
26
|
"check:package": "attw --pack .",
|
|
27
27
|
"check:changeset": "changeset status --since=origin/main",
|
|
28
|
+
"check:commits": "node scripts/check-commits.ts",
|
|
28
29
|
"check:since": "node scripts/check-since.ts",
|
|
29
30
|
"check:instructions": "node scripts/check-instructions.ts",
|
|
30
31
|
"check:structure": "node scripts/check-structure.ts",
|
|
@@ -65,6 +66,7 @@
|
|
|
65
66
|
"@vitest/coverage-istanbul": "^5.0.2",
|
|
66
67
|
"@vitest/ui": "^5.0.2",
|
|
67
68
|
"eslint": "^10.11.0",
|
|
69
|
+
"eslint-plugin-perfectionist": "^5.12.1",
|
|
68
70
|
"eslint-plugin-tsdoc": "^0.5.3",
|
|
69
71
|
"globals": "^17.12.0",
|
|
70
72
|
"typescript": "^6.0.3",
|