typetify 2.0.0 → 2.2.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.
Files changed (185) hide show
  1. package/CHANGELOG.md +70 -0
  2. package/README.md +108 -0
  3. package/dist/async/index.js +1 -49
  4. package/dist/async/index.mjs +1 -4
  5. package/dist/chunk-272Z3AXV.js +1 -0
  6. package/dist/chunk-4HQERWI6.mjs +1 -0
  7. package/dist/chunk-4JG7CFRK.js +1 -0
  8. package/dist/chunk-5FBZYPQM.mjs +1 -0
  9. package/dist/chunk-5LWNMYHB.js +1 -0
  10. package/dist/chunk-5XQRYI2Q.mjs +1 -0
  11. package/dist/chunk-6HA2SN23.js +1 -0
  12. package/dist/chunk-6NWIIOHH.js +1 -0
  13. package/dist/chunk-7LBL6CYT.js +1 -0
  14. package/dist/chunk-7V3EDYJD.mjs +1 -0
  15. package/dist/chunk-B3R73UK5.mjs +1 -0
  16. package/dist/chunk-EAHFED6V.mjs +1 -0
  17. package/dist/chunk-EKSHS4DL.mjs +1 -0
  18. package/dist/chunk-FYQNKDT3.mjs +1 -0
  19. package/dist/chunk-GKOA3XGQ.js +1 -0
  20. package/dist/chunk-I4YSQ4HB.js +1 -0
  21. package/dist/chunk-JZXLCA2E.mjs +1 -0
  22. package/dist/chunk-M5OMYDI7.mjs +1 -0
  23. package/dist/chunk-MPY3WRLG.mjs +1 -0
  24. package/dist/chunk-MSOFO6QN.js +1 -0
  25. package/dist/chunk-NENRAPOL.mjs +1 -0
  26. package/dist/chunk-NOW4Q26G.mjs +1 -0
  27. package/dist/chunk-P4UNM7SF.js +1 -0
  28. package/dist/chunk-P5E2JDCX.mjs +1 -0
  29. package/dist/chunk-Q7SUL7MD.js +1 -0
  30. package/dist/chunk-QKNZICUO.mjs +1 -0
  31. package/dist/chunk-RHMANSTA.mjs +1 -0
  32. package/dist/chunk-SF64HETW.js +1 -0
  33. package/dist/chunk-T66YO63J.js +1 -0
  34. package/dist/chunk-TNK6EVQK.mjs +1 -0
  35. package/dist/chunk-TSJFKV3R.js +1 -0
  36. package/dist/chunk-TVCWWECJ.mjs +1 -0
  37. package/dist/chunk-W5I352FJ.js +1 -0
  38. package/dist/chunk-WAT4QJB2.js +1 -0
  39. package/dist/chunk-WCG5ODRX.mjs +1 -0
  40. package/dist/chunk-WDFIRO2J.js +1 -0
  41. package/dist/chunk-WOT6VMZA.js +1 -0
  42. package/dist/chunk-WQPSXQT5.js +1 -0
  43. package/dist/chunk-WS743BFA.js +1 -0
  44. package/dist/chunk-XPY5CWKZ.mjs +1 -0
  45. package/dist/collection/index.js +1 -125
  46. package/dist/collection/index.mjs +1 -4
  47. package/dist/core/index.js +1 -41
  48. package/dist/core/index.mjs +1 -4
  49. package/dist/decorator/index.js +1 -57
  50. package/dist/decorator/index.mjs +1 -4
  51. package/dist/dx/index.js +1 -53
  52. package/dist/dx/index.mjs +1 -4
  53. package/dist/flow/index.js +1 -50
  54. package/dist/flow/index.mjs +1 -5
  55. package/dist/fn/index.js +1 -37
  56. package/dist/fn/index.mjs +1 -4
  57. package/dist/guards/index.js +1 -233
  58. package/dist/guards/index.mjs +1 -4
  59. package/dist/index.d.mts +143 -24
  60. package/dist/index.d.ts +143 -24
  61. package/dist/index.js +3 -2498
  62. package/dist/index.mjs +3 -1537
  63. package/dist/input/index.js +1 -74
  64. package/dist/input/index.mjs +1 -5
  65. package/dist/iterator/index.js +1 -522
  66. package/dist/iterator/index.mjs +1 -502
  67. package/dist/logic/index.js +1 -416
  68. package/dist/logic/index.mjs +1 -367
  69. package/dist/math/index.js +1 -45
  70. package/dist/math/index.mjs +1 -4
  71. package/dist/narrowing/index.js +1 -220
  72. package/dist/narrowing/index.mjs +1 -186
  73. package/dist/object/index.js +1 -113
  74. package/dist/object/index.mjs +1 -4
  75. package/dist/result/index.js +1 -86
  76. package/dist/result/index.mjs +1 -5
  77. package/dist/schema/index.js +1 -410
  78. package/dist/schema/index.mjs +1 -384
  79. package/dist/string/index.js +1 -49
  80. package/dist/string/index.mjs +1 -4
  81. package/dist/typed/index.js +1 -193
  82. package/dist/typed/index.mjs +1 -4
  83. package/package.json +8 -3
  84. package/dist/async/index.js.map +0 -1
  85. package/dist/async/index.mjs.map +0 -1
  86. package/dist/chunk-2LJ6NZ6K.js +0 -108
  87. package/dist/chunk-2LJ6NZ6K.js.map +0 -1
  88. package/dist/chunk-4NXETABV.mjs +0 -116
  89. package/dist/chunk-4NXETABV.mjs.map +0 -1
  90. package/dist/chunk-6ZBTL74K.js +0 -129
  91. package/dist/chunk-6ZBTL74K.js.map +0 -1
  92. package/dist/chunk-CN3GYRJN.mjs +0 -137
  93. package/dist/chunk-CN3GYRJN.mjs.map +0 -1
  94. package/dist/chunk-CNTE6ZVH.js +0 -359
  95. package/dist/chunk-CNTE6ZVH.js.map +0 -1
  96. package/dist/chunk-DBENOSTA.js +0 -156
  97. package/dist/chunk-DBENOSTA.js.map +0 -1
  98. package/dist/chunk-DWIG5GF2.js +0 -135
  99. package/dist/chunk-DWIG5GF2.js.map +0 -1
  100. package/dist/chunk-EAUTTWTQ.mjs +0 -231
  101. package/dist/chunk-EAUTTWTQ.mjs.map +0 -1
  102. package/dist/chunk-FXWYPHA3.mjs +0 -13
  103. package/dist/chunk-FXWYPHA3.mjs.map +0 -1
  104. package/dist/chunk-GS3PP67B.js +0 -200
  105. package/dist/chunk-GS3PP67B.js.map +0 -1
  106. package/dist/chunk-IGA3VEZM.mjs +0 -503
  107. package/dist/chunk-IGA3VEZM.mjs.map +0 -1
  108. package/dist/chunk-J5LGTIGS.mjs +0 -9
  109. package/dist/chunk-J5LGTIGS.mjs.map +0 -1
  110. package/dist/chunk-JAOGY4JO.mjs +0 -1007
  111. package/dist/chunk-JAOGY4JO.mjs.map +0 -1
  112. package/dist/chunk-JB6UXRKD.mjs +0 -97
  113. package/dist/chunk-JB6UXRKD.mjs.map +0 -1
  114. package/dist/chunk-JQAQV75V.js +0 -561
  115. package/dist/chunk-JQAQV75V.js.map +0 -1
  116. package/dist/chunk-JQHUBZ4M.js +0 -88
  117. package/dist/chunk-JQHUBZ4M.js.map +0 -1
  118. package/dist/chunk-LT7JK7RJ.js +0 -87
  119. package/dist/chunk-LT7JK7RJ.js.map +0 -1
  120. package/dist/chunk-OEJK37LO.mjs +0 -328
  121. package/dist/chunk-OEJK37LO.mjs.map +0 -1
  122. package/dist/chunk-OPVES6W2.js +0 -16
  123. package/dist/chunk-OPVES6W2.js.map +0 -1
  124. package/dist/chunk-OWNUKWXV.js +0 -291
  125. package/dist/chunk-OWNUKWXV.js.map +0 -1
  126. package/dist/chunk-PQTXSQ4P.js +0 -369
  127. package/dist/chunk-PQTXSQ4P.js.map +0 -1
  128. package/dist/chunk-PZ5AY32C.js +0 -11
  129. package/dist/chunk-PZ5AY32C.js.map +0 -1
  130. package/dist/chunk-QFR7DVAJ.mjs +0 -63
  131. package/dist/chunk-QFR7DVAJ.mjs.map +0 -1
  132. package/dist/chunk-SGQNLTRK.js +0 -73
  133. package/dist/chunk-SGQNLTRK.js.map +0 -1
  134. package/dist/chunk-SIA5BSVY.js +0 -1054
  135. package/dist/chunk-SIA5BSVY.js.map +0 -1
  136. package/dist/chunk-SRDWUHDY.mjs +0 -188
  137. package/dist/chunk-SRDWUHDY.mjs.map +0 -1
  138. package/dist/chunk-TXU7NTT4.js +0 -249
  139. package/dist/chunk-TXU7NTT4.js.map +0 -1
  140. package/dist/chunk-TZEWREAC.mjs +0 -277
  141. package/dist/chunk-TZEWREAC.mjs.map +0 -1
  142. package/dist/chunk-V6CWFDIJ.mjs +0 -123
  143. package/dist/chunk-V6CWFDIJ.mjs.map +0 -1
  144. package/dist/chunk-YBJC5WMX.mjs +0 -341
  145. package/dist/chunk-YBJC5WMX.mjs.map +0 -1
  146. package/dist/chunk-YOPAXITF.mjs +0 -75
  147. package/dist/chunk-YOPAXITF.mjs.map +0 -1
  148. package/dist/chunk-ZE4FDBRI.mjs +0 -79
  149. package/dist/chunk-ZE4FDBRI.mjs.map +0 -1
  150. package/dist/collection/index.js.map +0 -1
  151. package/dist/collection/index.mjs.map +0 -1
  152. package/dist/core/index.js.map +0 -1
  153. package/dist/core/index.mjs.map +0 -1
  154. package/dist/decorator/index.js.map +0 -1
  155. package/dist/decorator/index.mjs.map +0 -1
  156. package/dist/dx/index.js.map +0 -1
  157. package/dist/dx/index.mjs.map +0 -1
  158. package/dist/flow/index.js.map +0 -1
  159. package/dist/flow/index.mjs.map +0 -1
  160. package/dist/fn/index.js.map +0 -1
  161. package/dist/fn/index.mjs.map +0 -1
  162. package/dist/guards/index.js.map +0 -1
  163. package/dist/guards/index.mjs.map +0 -1
  164. package/dist/index.js.map +0 -1
  165. package/dist/index.mjs.map +0 -1
  166. package/dist/input/index.js.map +0 -1
  167. package/dist/input/index.mjs.map +0 -1
  168. package/dist/iterator/index.js.map +0 -1
  169. package/dist/iterator/index.mjs.map +0 -1
  170. package/dist/logic/index.js.map +0 -1
  171. package/dist/logic/index.mjs.map +0 -1
  172. package/dist/math/index.js.map +0 -1
  173. package/dist/math/index.mjs.map +0 -1
  174. package/dist/narrowing/index.js.map +0 -1
  175. package/dist/narrowing/index.mjs.map +0 -1
  176. package/dist/object/index.js.map +0 -1
  177. package/dist/object/index.mjs.map +0 -1
  178. package/dist/result/index.js.map +0 -1
  179. package/dist/result/index.mjs.map +0 -1
  180. package/dist/schema/index.js.map +0 -1
  181. package/dist/schema/index.mjs.map +0 -1
  182. package/dist/string/index.js.map +0 -1
  183. package/dist/string/index.mjs.map +0 -1
  184. package/dist/typed/index.js.map +0 -1
  185. package/dist/typed/index.mjs.map +0 -1
@@ -1,74 +1 @@
1
- 'use strict';
2
-
3
- var chunkTXU7NTT4_js = require('../chunk-TXU7NTT4.js');
4
- require('../chunk-OPVES6W2.js');
5
- require('../chunk-PZ5AY32C.js');
6
-
7
-
8
-
9
- Object.defineProperty(exports, "clamp", {
10
- enumerable: true,
11
- get: function () { return chunkTXU7NTT4_js.clamp; }
12
- });
13
- Object.defineProperty(exports, "coerceArray", {
14
- enumerable: true,
15
- get: function () { return chunkTXU7NTT4_js.coerceArray; }
16
- });
17
- Object.defineProperty(exports, "coerceString", {
18
- enumerable: true,
19
- get: function () { return chunkTXU7NTT4_js.coerceString; }
20
- });
21
- Object.defineProperty(exports, "defaults", {
22
- enumerable: true,
23
- get: function () { return chunkTXU7NTT4_js.defaults; }
24
- });
25
- Object.defineProperty(exports, "isEmail", {
26
- enumerable: true,
27
- get: function () { return chunkTXU7NTT4_js.isEmail; }
28
- });
29
- Object.defineProperty(exports, "isIpAddress", {
30
- enumerable: true,
31
- get: function () { return chunkTXU7NTT4_js.isIpAddress; }
32
- });
33
- Object.defineProperty(exports, "isUrl", {
34
- enumerable: true,
35
- get: function () { return chunkTXU7NTT4_js.isUrl; }
36
- });
37
- Object.defineProperty(exports, "isUuid", {
38
- enumerable: true,
39
- get: function () { return chunkTXU7NTT4_js.isUuid; }
40
- });
41
- Object.defineProperty(exports, "parseBoolean", {
42
- enumerable: true,
43
- get: function () { return chunkTXU7NTT4_js.parseBoolean; }
44
- });
45
- Object.defineProperty(exports, "parseDate", {
46
- enumerable: true,
47
- get: function () { return chunkTXU7NTT4_js.parseDate; }
48
- });
49
- Object.defineProperty(exports, "parseInteger", {
50
- enumerable: true,
51
- get: function () { return chunkTXU7NTT4_js.parseInteger; }
52
- });
53
- Object.defineProperty(exports, "parseNumber", {
54
- enumerable: true,
55
- get: function () { return chunkTXU7NTT4_js.parseNumber; }
56
- });
57
- Object.defineProperty(exports, "parseUrl", {
58
- enumerable: true,
59
- get: function () { return chunkTXU7NTT4_js.parseUrl; }
60
- });
61
- Object.defineProperty(exports, "safeJsonParse", {
62
- enumerable: true,
63
- get: function () { return chunkTXU7NTT4_js.safeJsonParse; }
64
- });
65
- Object.defineProperty(exports, "safeJsonStringify", {
66
- enumerable: true,
67
- get: function () { return chunkTXU7NTT4_js.safeJsonStringify; }
68
- });
69
- Object.defineProperty(exports, "trimAll", {
70
- enumerable: true,
71
- get: function () { return chunkTXU7NTT4_js.trimAll; }
72
- });
73
- //# sourceMappingURL=index.js.map
74
- //# sourceMappingURL=index.js.map
1
+ 'use strict';var chunkQ7SUL7MD_js=require('../chunk-Q7SUL7MD.js');require('../chunk-P4UNM7SF.js'),require('../chunk-WOT6VMZA.js');Object.defineProperty(exports,"clamp",{enumerable:true,get:function(){return chunkQ7SUL7MD_js.k}});Object.defineProperty(exports,"coerceArray",{enumerable:true,get:function(){return chunkQ7SUL7MD_js.h}});Object.defineProperty(exports,"coerceString",{enumerable:true,get:function(){return chunkQ7SUL7MD_js.g}});Object.defineProperty(exports,"defaults",{enumerable:true,get:function(){return chunkQ7SUL7MD_js.j}});Object.defineProperty(exports,"isEmail",{enumerable:true,get:function(){return chunkQ7SUL7MD_js.l}});Object.defineProperty(exports,"isIpAddress",{enumerable:true,get:function(){return chunkQ7SUL7MD_js.o}});Object.defineProperty(exports,"isUrl",{enumerable:true,get:function(){return chunkQ7SUL7MD_js.m}});Object.defineProperty(exports,"isUuid",{enumerable:true,get:function(){return chunkQ7SUL7MD_js.n}});Object.defineProperty(exports,"parseBoolean",{enumerable:true,get:function(){return chunkQ7SUL7MD_js.e}});Object.defineProperty(exports,"parseDate",{enumerable:true,get:function(){return chunkQ7SUL7MD_js.f}});Object.defineProperty(exports,"parseInteger",{enumerable:true,get:function(){return chunkQ7SUL7MD_js.d}});Object.defineProperty(exports,"parseNumber",{enumerable:true,get:function(){return chunkQ7SUL7MD_js.c}});Object.defineProperty(exports,"parseUrl",{enumerable:true,get:function(){return chunkQ7SUL7MD_js.p}});Object.defineProperty(exports,"safeJsonParse",{enumerable:true,get:function(){return chunkQ7SUL7MD_js.a}});Object.defineProperty(exports,"safeJsonStringify",{enumerable:true,get:function(){return chunkQ7SUL7MD_js.b}});Object.defineProperty(exports,"trimAll",{enumerable:true,get:function(){return chunkQ7SUL7MD_js.i}});
@@ -1,5 +1 @@
1
- export { clamp, coerceArray, coerceString, defaults, isEmail, isIpAddress, isUrl, isUuid, parseBoolean, parseDate, parseInteger, parseNumber, parseUrl, safeJsonParse, safeJsonStringify, trimAll } from '../chunk-EAUTTWTQ.mjs';
2
- import '../chunk-FXWYPHA3.mjs';
3
- import '../chunk-J5LGTIGS.mjs';
4
- //# sourceMappingURL=index.mjs.map
5
- //# sourceMappingURL=index.mjs.map
1
+ export{k as clamp,h as coerceArray,g as coerceString,j as defaults,l as isEmail,o as isIpAddress,m as isUrl,n as isUuid,e as parseBoolean,f as parseDate,d as parseInteger,c as parseNumber,p as parseUrl,a as safeJsonParse,b as safeJsonStringify,i as trimAll}from'../chunk-NOW4Q26G.mjs';import'../chunk-5FBZYPQM.mjs';import'../chunk-JZXLCA2E.mjs';
@@ -1,522 +1 @@
1
- 'use strict';
2
-
3
- require('../chunk-PZ5AY32C.js');
4
-
5
- // src/iterator/createIterator.ts
6
- function createIterator(source) {
7
- const getIterator = () => {
8
- if (typeof source === "function") {
9
- return source();
10
- }
11
- return source[Symbol.iterator]();
12
- };
13
- return {
14
- [Symbol.iterator]() {
15
- return getIterator();
16
- },
17
- map(fn) {
18
- const self = this;
19
- return createIterator(function* () {
20
- let index = 0;
21
- for (const value of self) {
22
- yield fn(value, index++);
23
- }
24
- });
25
- },
26
- filter(predicate) {
27
- const self = this;
28
- return createIterator(function* () {
29
- let index = 0;
30
- for (const value of self) {
31
- if (predicate(value, index++)) {
32
- yield value;
33
- }
34
- }
35
- });
36
- },
37
- take(n) {
38
- const self = this;
39
- return createIterator(function* () {
40
- let count = 0;
41
- for (const value of self) {
42
- if (count >= n) break;
43
- yield value;
44
- count++;
45
- }
46
- });
47
- },
48
- skip(n) {
49
- const self = this;
50
- return createIterator(function* () {
51
- let count = 0;
52
- for (const value of self) {
53
- if (count >= n) {
54
- yield value;
55
- }
56
- count++;
57
- }
58
- });
59
- },
60
- takeWhile(predicate) {
61
- const self = this;
62
- return createIterator(function* () {
63
- for (const value of self) {
64
- if (!predicate(value)) break;
65
- yield value;
66
- }
67
- });
68
- },
69
- skipWhile(predicate) {
70
- const self = this;
71
- return createIterator(function* () {
72
- let skipping = true;
73
- for (const value of self) {
74
- if (skipping && predicate(value)) continue;
75
- skipping = false;
76
- yield value;
77
- }
78
- });
79
- },
80
- flatMap(fn) {
81
- const self = this;
82
- return createIterator(function* () {
83
- for (const value of self) {
84
- yield* fn(value);
85
- }
86
- });
87
- },
88
- flatten() {
89
- const self = this;
90
- return createIterator(function* () {
91
- for (const value of self) {
92
- yield* value;
93
- }
94
- });
95
- },
96
- chunk(size) {
97
- const self = this;
98
- return createIterator(function* () {
99
- let chunk2 = [];
100
- for (const value of self) {
101
- chunk2.push(value);
102
- if (chunk2.length === size) {
103
- yield chunk2;
104
- chunk2 = [];
105
- }
106
- }
107
- if (chunk2.length > 0) {
108
- yield chunk2;
109
- }
110
- });
111
- },
112
- enumerate() {
113
- const self = this;
114
- return createIterator(function* () {
115
- let index = 0;
116
- for (const value of self) {
117
- yield [index++, value];
118
- }
119
- });
120
- },
121
- zip(other) {
122
- const self = this;
123
- return createIterator(function* () {
124
- const iter1 = self[Symbol.iterator]();
125
- const iter2 = other[Symbol.iterator]();
126
- while (true) {
127
- const r1 = iter1.next();
128
- const r2 = iter2.next();
129
- if (r1.done || r2.done) break;
130
- yield [r1.value, r2.value];
131
- }
132
- });
133
- },
134
- concat(...others) {
135
- const self = this;
136
- return createIterator(function* () {
137
- yield* self;
138
- for (const other of others) {
139
- yield* other;
140
- }
141
- });
142
- },
143
- unique(keyFn) {
144
- const self = this;
145
- return createIterator(function* () {
146
- const seen = /* @__PURE__ */ new Set();
147
- for (const value of self) {
148
- const key = keyFn ? keyFn(value) : value;
149
- if (!seen.has(key)) {
150
- seen.add(key);
151
- yield value;
152
- }
153
- }
154
- });
155
- },
156
- toArray() {
157
- return [...this];
158
- },
159
- reduce(fn, initial) {
160
- let acc = initial;
161
- for (const value of this) {
162
- acc = fn(acc, value);
163
- }
164
- return acc;
165
- },
166
- forEach(fn) {
167
- let index = 0;
168
- for (const value of this) {
169
- fn(value, index++);
170
- }
171
- },
172
- find(predicate) {
173
- for (const value of this) {
174
- if (predicate(value)) return value;
175
- }
176
- return void 0;
177
- },
178
- some(predicate) {
179
- for (const value of this) {
180
- if (predicate(value)) return true;
181
- }
182
- return false;
183
- },
184
- every(predicate) {
185
- for (const value of this) {
186
- if (!predicate(value)) return false;
187
- }
188
- return true;
189
- },
190
- first() {
191
- for (const value of this) {
192
- return value;
193
- }
194
- return void 0;
195
- },
196
- last() {
197
- let last;
198
- for (const value of this) {
199
- last = value;
200
- }
201
- return last;
202
- },
203
- count() {
204
- let count = 0;
205
- for (const _ of this) {
206
- count++;
207
- }
208
- return count;
209
- },
210
- collect(collector) {
211
- return collector(this);
212
- }
213
- };
214
- }
215
-
216
- // src/iterator/range.ts
217
- function range(start, end, step = 1) {
218
- return createIterator(function* () {
219
- if (step > 0) {
220
- for (let i = start; i < end; i += step) {
221
- yield i;
222
- }
223
- } else if (step < 0) {
224
- for (let i = start; i > end; i += step) {
225
- yield i;
226
- }
227
- }
228
- });
229
- }
230
-
231
- // src/iterator/map.ts
232
- function map(source, fn) {
233
- return createIterator(function* () {
234
- let index = 0;
235
- for (const value of source) {
236
- yield fn(value, index++);
237
- }
238
- });
239
- }
240
-
241
- // src/iterator/filter.ts
242
- function filter(source, predicate) {
243
- return createIterator(function* () {
244
- let index = 0;
245
- for (const value of source) {
246
- if (predicate(value, index++)) {
247
- yield value;
248
- }
249
- }
250
- });
251
- }
252
-
253
- // src/iterator/take.ts
254
- function take(source, n) {
255
- return createIterator(function* () {
256
- let count = 0;
257
- for (const value of source) {
258
- if (count >= n) break;
259
- yield value;
260
- count++;
261
- }
262
- });
263
- }
264
-
265
- // src/iterator/skip.ts
266
- function skip(source, n) {
267
- return createIterator(function* () {
268
- let count = 0;
269
- for (const value of source) {
270
- if (count >= n) {
271
- yield value;
272
- }
273
- count++;
274
- }
275
- });
276
- }
277
-
278
- // src/iterator/chunk.ts
279
- function chunk(source, size) {
280
- return createIterator(function* () {
281
- let chunk2 = [];
282
- for (const value of source) {
283
- chunk2.push(value);
284
- if (chunk2.length === size) {
285
- yield chunk2;
286
- chunk2 = [];
287
- }
288
- }
289
- if (chunk2.length > 0) {
290
- yield chunk2;
291
- }
292
- });
293
- }
294
-
295
- // src/iterator/flatten.ts
296
- function flatten(source) {
297
- return createIterator(function* () {
298
- for (const inner of source) {
299
- yield* inner;
300
- }
301
- });
302
- }
303
-
304
- // src/iterator/zip.ts
305
- function zip(source1, source2) {
306
- return createIterator(function* () {
307
- const iter1 = source1[Symbol.iterator]();
308
- const iter2 = source2[Symbol.iterator]();
309
- while (true) {
310
- const r1 = iter1.next();
311
- const r2 = iter2.next();
312
- if (r1.done || r2.done) break;
313
- yield [r1.value, r2.value];
314
- }
315
- });
316
- }
317
-
318
- // src/iterator/enumerate.ts
319
- function enumerate(source) {
320
- return createIterator(function* () {
321
- let index = 0;
322
- for (const value of source) {
323
- yield [index++, value];
324
- }
325
- });
326
- }
327
-
328
- // src/iterator/cycle.ts
329
- function cycle(source) {
330
- return createIterator(function* () {
331
- const cached = [];
332
- for (const value of source) {
333
- cached.push(value);
334
- yield value;
335
- }
336
- if (cached.length === 0) return;
337
- while (true) {
338
- for (const value of cached) {
339
- yield value;
340
- }
341
- }
342
- });
343
- }
344
-
345
- // src/iterator/repeat.ts
346
- function repeat(value, n) {
347
- return createIterator(function* () {
348
- if (n === void 0) {
349
- while (true) {
350
- yield value;
351
- }
352
- } else {
353
- for (let i = 0; i < n; i++) {
354
- yield value;
355
- }
356
- }
357
- });
358
- }
359
-
360
- // src/iterator/fromAsync.ts
361
- function fromAsync(source) {
362
- const getIterator = () => {
363
- if (typeof source === "function") {
364
- return source();
365
- }
366
- return source[Symbol.asyncIterator]();
367
- };
368
- return {
369
- [Symbol.asyncIterator]() {
370
- return getIterator();
371
- },
372
- map(fn) {
373
- const self = this;
374
- return fromAsync(async function* () {
375
- let index = 0;
376
- for await (const value of self) {
377
- yield await fn(value, index++);
378
- }
379
- });
380
- },
381
- filter(predicate) {
382
- const self = this;
383
- return fromAsync(async function* () {
384
- for await (const value of self) {
385
- if (await predicate(value)) {
386
- yield value;
387
- }
388
- }
389
- });
390
- },
391
- take(n) {
392
- const self = this;
393
- return fromAsync(async function* () {
394
- let count = 0;
395
- for await (const value of self) {
396
- if (count >= n) break;
397
- yield value;
398
- count++;
399
- }
400
- });
401
- },
402
- skip(n) {
403
- const self = this;
404
- return fromAsync(async function* () {
405
- let count = 0;
406
- for await (const value of self) {
407
- if (count >= n) {
408
- yield value;
409
- }
410
- count++;
411
- }
412
- });
413
- },
414
- async toArray() {
415
- const result = [];
416
- for await (const value of this) {
417
- result.push(value);
418
- }
419
- return result;
420
- },
421
- async reduce(fn, initial) {
422
- let acc = initial;
423
- for await (const value of this) {
424
- acc = await fn(acc, value);
425
- }
426
- return acc;
427
- },
428
- async forEach(fn) {
429
- let index = 0;
430
- for await (const value of this) {
431
- await fn(value, index++);
432
- }
433
- },
434
- async find(predicate) {
435
- for await (const value of this) {
436
- if (await predicate(value)) return value;
437
- }
438
- return void 0;
439
- },
440
- async first() {
441
- for await (const value of this) {
442
- return value;
443
- }
444
- return void 0;
445
- },
446
- async count() {
447
- let count = 0;
448
- for await (const _ of this) {
449
- count++;
450
- }
451
- return count;
452
- }
453
- };
454
- }
455
-
456
- // src/iterator/toArray.ts
457
- function toArray(source) {
458
- return [...source];
459
- }
460
-
461
- // src/iterator/reduce.ts
462
- function reduce(source, fn, initial) {
463
- let acc = initial;
464
- for (const value of source) {
465
- acc = fn(acc, value);
466
- }
467
- return acc;
468
- }
469
-
470
- // src/iterator/forEach.ts
471
- function forEach(source, fn) {
472
- let index = 0;
473
- for (const value of source) {
474
- fn(value, index++);
475
- }
476
- }
477
-
478
- // src/iterator/find.ts
479
- function find(source, predicate) {
480
- for (const value of source) {
481
- if (predicate(value)) return value;
482
- }
483
- return void 0;
484
- }
485
-
486
- // src/iterator/some.ts
487
- function some(source, predicate) {
488
- for (const value of source) {
489
- if (predicate(value)) return true;
490
- }
491
- return false;
492
- }
493
-
494
- // src/iterator/every.ts
495
- function every(source, predicate) {
496
- for (const value of source) {
497
- if (!predicate(value)) return false;
498
- }
499
- return true;
500
- }
501
-
502
- exports.createIterator = createIterator;
503
- exports.cycle = cycle;
504
- exports.enumerate = enumerate;
505
- exports.fromAsync = fromAsync;
506
- exports.iterEvery = every;
507
- exports.iterFind = find;
508
- exports.iterForEach = forEach;
509
- exports.iterReduce = reduce;
510
- exports.iterSome = some;
511
- exports.lazyChunk = chunk;
512
- exports.lazyFilter = filter;
513
- exports.lazyFlatten = flatten;
514
- exports.lazyMap = map;
515
- exports.lazyRange = range;
516
- exports.lazySkip = skip;
517
- exports.lazyTake = take;
518
- exports.lazyZip = zip;
519
- exports.repeat = repeat;
520
- exports.toArray = toArray;
521
- //# sourceMappingURL=index.js.map
522
- //# sourceMappingURL=index.js.map
1
+ 'use strict';var chunkWS743BFA_js=require('../chunk-WS743BFA.js');require('../chunk-WOT6VMZA.js');Object.defineProperty(exports,"createIterator",{enumerable:true,get:function(){return chunkWS743BFA_js.a}});Object.defineProperty(exports,"cycle",{enumerable:true,get:function(){return chunkWS743BFA_js.k}});Object.defineProperty(exports,"enumerate",{enumerable:true,get:function(){return chunkWS743BFA_js.j}});Object.defineProperty(exports,"fromAsync",{enumerable:true,get:function(){return chunkWS743BFA_js.m}});Object.defineProperty(exports,"iterEvery",{enumerable:true,get:function(){return chunkWS743BFA_js.s}});Object.defineProperty(exports,"iterFind",{enumerable:true,get:function(){return chunkWS743BFA_js.q}});Object.defineProperty(exports,"iterForEach",{enumerable:true,get:function(){return chunkWS743BFA_js.p}});Object.defineProperty(exports,"iterReduce",{enumerable:true,get:function(){return chunkWS743BFA_js.o}});Object.defineProperty(exports,"iterSome",{enumerable:true,get:function(){return chunkWS743BFA_js.r}});Object.defineProperty(exports,"lazyChunk",{enumerable:true,get:function(){return chunkWS743BFA_js.g}});Object.defineProperty(exports,"lazyFilter",{enumerable:true,get:function(){return chunkWS743BFA_js.d}});Object.defineProperty(exports,"lazyFlatten",{enumerable:true,get:function(){return chunkWS743BFA_js.h}});Object.defineProperty(exports,"lazyMap",{enumerable:true,get:function(){return chunkWS743BFA_js.c}});Object.defineProperty(exports,"lazyRange",{enumerable:true,get:function(){return chunkWS743BFA_js.b}});Object.defineProperty(exports,"lazySkip",{enumerable:true,get:function(){return chunkWS743BFA_js.f}});Object.defineProperty(exports,"lazyTake",{enumerable:true,get:function(){return chunkWS743BFA_js.e}});Object.defineProperty(exports,"lazyZip",{enumerable:true,get:function(){return chunkWS743BFA_js.i}});Object.defineProperty(exports,"repeat",{enumerable:true,get:function(){return chunkWS743BFA_js.l}});Object.defineProperty(exports,"toArray",{enumerable:true,get:function(){return chunkWS743BFA_js.n}});