semantic-typescript 0.7.1 → 0.8.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.
@@ -99,6 +99,7 @@ export class SynchronousSemantic {
99
99
  this.generator((element, index) => {
100
100
  if (count === -1n) {
101
101
  if (!predicate(element, index)) {
102
+ accept(element, count);
102
103
  count++;
103
104
  }
104
105
  }
@@ -269,9 +270,14 @@ export class SynchronousSemantic {
269
270
  if (isFunction(redirector)) {
270
271
  return new SynchronousSemantic((accept, interrupt) => {
271
272
  try {
273
+ let stop = false;
272
274
  this.generator((element, index) => {
273
- accept(element, redirector(element, index));
274
- }, interrupt);
275
+ let redirected = redirector(element, index);
276
+ stop = stop || interrupt(element, redirected);
277
+ accept(element, redirected);
278
+ }, () => {
279
+ return stop;
280
+ });
275
281
  }
276
282
  catch (error) {
277
283
  throw error;
@@ -283,9 +289,14 @@ export class SynchronousSemantic {
283
289
  reverse() {
284
290
  return new SynchronousSemantic((accept, interrupt) => {
285
291
  try {
292
+ let stop = false;
286
293
  this.generator((element, index) => {
287
- accept(element, -index);
288
- }, interrupt);
294
+ let redirected = -index;
295
+ stop = stop || interrupt(element, redirected);
296
+ accept(element, redirected);
297
+ }, () => {
298
+ return stop;
299
+ });
289
300
  }
290
301
  catch (error) {
291
302
  throw error;
@@ -296,9 +307,14 @@ export class SynchronousSemantic {
296
307
  if (isFunction(mapper)) {
297
308
  return new SynchronousSemantic((accept, interrupt) => {
298
309
  try {
310
+ let stop = false;
299
311
  this.generator((element, index) => {
300
- accept(element, mapper(element, index));
301
- }, interrupt);
312
+ let redirected = mapper(element, index);
313
+ stop = stop || interrupt(element, redirected);
314
+ accept(element, redirected);
315
+ }, () => {
316
+ return stop;
317
+ });
302
318
  }
303
319
  catch (error) {
304
320
  throw error;
@@ -389,7 +405,7 @@ export class SynchronousSemantic {
389
405
  try {
390
406
  let stop = false;
391
407
  this.generator((element, index) => {
392
- if (predicate(element, index) && !stop) {
408
+ if (predicate(element, index) && (!stop)) {
393
409
  accept(element, index);
394
410
  }
395
411
  else {
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "url": "https://github.com/eloyhere"
7
7
  },
8
8
  "description": "A modern type-safe stream processing library inspired by JavaScript Generator, Java Stream, and MySQL Index. Supports lazy evaluation, async streams, statistics, and IO-like operations.",
9
- "version": "0.7.1",
9
+ "version": "0.8.0",
10
10
  "type": "module",
11
11
  "readme": "readme.md",
12
12
  "main": "dist/index.js",
@@ -55,4 +55,4 @@
55
55
  "build": "tsc",
56
56
  "prepublishOnly": "npm run build"
57
57
  }
58
- }
58
+ }