gingersnap 0.25.2 → 0.26.2

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.
@@ -245,6 +245,12 @@ class CacheManager {
245
245
  this.expiryPeriod = expiryPeriod;
246
246
  this.memStores = new Map();
247
247
  }
248
+ /**
249
+ * Checks if this cache manager can persist data
250
+ */
251
+ get canPersist() {
252
+ return !!this.persistStore;
253
+ }
248
254
  /**
249
255
  * Creates a new cache
250
256
  * @param name the name of the cache
@@ -272,6 +278,13 @@ class CacheManager {
272
278
  getCache(name) {
273
279
  return this.memStores.get(name);
274
280
  }
281
+ /**
282
+ * Checks if the manager contains a cache
283
+ * @param name
284
+ */
285
+ hasCache(name) {
286
+ return this.memStores.has(name);
287
+ }
275
288
  /**
276
289
  * Removes a cache by name
277
290
  * @param name the name of the cache
@@ -132,6 +132,10 @@ export declare class CacheManager {
132
132
  * @param expiryPeriod expiry period for cache entries
133
133
  */
134
134
  constructor(persistStore?: PersistenceStore, maxSize?: number, expiryPeriod?: Duration);
135
+ /**
136
+ * Checks if this cache manager can persist data
137
+ */
138
+ get canPersist(): boolean;
135
139
  /**
136
140
  * Creates a new cache
137
141
  * @param name the name of the cache
@@ -147,6 +151,11 @@ export declare class CacheManager {
147
151
  * @param name the name of the cache
148
152
  */
149
153
  getCache<T, K>(name: string): Cache<T, K>;
154
+ /**
155
+ * Checks if the manager contains a cache
156
+ * @param name
157
+ */
158
+ hasCache(name: string): boolean;
150
159
  /**
151
160
  * Removes a cache by name
152
161
  * @param name the name of the cache
@@ -243,6 +243,12 @@ class CacheManager {
243
243
  this.expiryPeriod = expiryPeriod;
244
244
  this.memStores = new Map();
245
245
  }
246
+ /**
247
+ * Checks if this cache manager can persist data
248
+ */
249
+ get canPersist() {
250
+ return !!this.persistStore;
251
+ }
246
252
  /**
247
253
  * Creates a new cache
248
254
  * @param name the name of the cache
@@ -270,6 +276,13 @@ class CacheManager {
270
276
  getCache(name) {
271
277
  return this.memStores.get(name);
272
278
  }
279
+ /**
280
+ * Checks if the manager contains a cache
281
+ * @param name
282
+ */
283
+ hasCache(name) {
284
+ return this.memStores.has(name);
285
+ }
273
286
  /**
274
287
  * Removes a cache by name
275
288
  * @param name the name of the cache
package/mocks.cjs CHANGED
@@ -311,6 +311,39 @@ class ResponseBuilder {
311
311
  this.delay = value;
312
312
  return this;
313
313
  }
314
+ /**
315
+ * Sets a custom handler function that receives the request and returns a complete Response.
316
+ * This provides full control over response generation, including status, headers, and body.
317
+ * When used, this overrides all other response builder methods (withStatus, withBody, etc.).
318
+ *
319
+ * @param functor - A function that receives the Request and returns a Response
320
+ * @returns This ResponseBuilder instance for chaining
321
+ *
322
+ * @example
323
+ * ```typescript
324
+ * // Dynamic response based on request details
325
+ * response().handle((req: Request) => {
326
+ * const url = new URL(req.url);
327
+ * const userId = url.pathname.split('/').pop();
328
+ *
329
+ * if (userId === '123') {
330
+ * return new Response(
331
+ * JSON.stringify({ id: 123, name: 'John' }),
332
+ * { status: HTTPStatus.OK, headers: { 'Content-Type': 'application/json' } }
333
+ * );
334
+ * }
335
+ *
336
+ * return new Response(
337
+ * JSON.stringify({ error: 'User not found' }),
338
+ * { status: HTTPStatus.NOT_FOUND, headers: { 'Content-Type': 'application/json' } }
339
+ * );
340
+ * })
341
+ * ```
342
+ */
343
+ handle(functor) {
344
+ this.handler = functor;
345
+ return this;
346
+ }
314
347
  /**
315
348
  * Builds and returns the Response object along with the delay.
316
349
  * This method is typically called internally by the API class.
@@ -319,15 +352,22 @@ class ResponseBuilder {
319
352
  *
320
353
  * @internal
321
354
  */
322
- build() {
355
+ build(request) {
323
356
  var _a, _b;
324
357
  let data;
358
+ if (this.handler) {
359
+ return { response: this.handler(request), delay: this.delay };
360
+ }
325
361
  if (this.body && typeof this.body === "string") {
326
362
  data = new Blob([this.body]);
327
363
  }
328
364
  else if (this.body instanceof Blob) {
329
365
  data = this.body;
330
366
  }
367
+ else if (this.body instanceof Function) {
368
+ const result = this.body(request);
369
+ data = result instanceof Blob ? result : new Blob([result]);
370
+ }
331
371
  const status = (_a = this.status) !== null && _a !== void 0 ? _a : http.HTTPStatus.OK;
332
372
  const response = new Response(data, {
333
373
  status,
@@ -546,7 +586,7 @@ class API {
546
586
  const matcher = this.requestMatcher(mockRequest);
547
587
  return (request) => matcher(request).then((match) => _tslib.__awaiter(this, void 0, void 0, function* () {
548
588
  if (match) {
549
- const { response: resp, delay } = response.build();
589
+ const { response: resp, delay } = response.build(request);
550
590
  if (delay) {
551
591
  yield future.Future.sleep(delay);
552
592
  }
package/mocks.d.ts CHANGED
@@ -156,6 +156,7 @@ declare class ResponseBuilder {
156
156
  private uri?;
157
157
  private fragment?;
158
158
  private delay?;
159
+ private handler?;
159
160
  constructor();
160
161
  /**
161
162
  * Sets the HTTP status code for the response.
@@ -216,7 +217,7 @@ declare class ResponseBuilder {
216
217
  * response().withBody(blob)
217
218
  * ```
218
219
  */
219
- withBody(value: string | Blob): this;
220
+ withBody(value: string | Blob | ((r: Request) => string | Blob)): this;
220
221
  /**
221
222
  * Sets the URL for the response object.
222
223
  * This is useful for testing scenarios where you need to inspect the response URL.
@@ -262,6 +263,36 @@ declare class ResponseBuilder {
262
263
  * ```
263
264
  */
264
265
  withDelay(value: Duration): this;
266
+ /**
267
+ * Sets a custom handler function that receives the request and returns a complete Response.
268
+ * This provides full control over response generation, including status, headers, and body.
269
+ * When used, this overrides all other response builder methods (withStatus, withBody, etc.).
270
+ *
271
+ * @param functor - A function that receives the Request and returns a Response
272
+ * @returns This ResponseBuilder instance for chaining
273
+ *
274
+ * @example
275
+ * ```typescript
276
+ * // Dynamic response based on request details
277
+ * response().handle((req: Request) => {
278
+ * const url = new URL(req.url);
279
+ * const userId = url.pathname.split('/').pop();
280
+ *
281
+ * if (userId === '123') {
282
+ * return new Response(
283
+ * JSON.stringify({ id: 123, name: 'John' }),
284
+ * { status: HTTPStatus.OK, headers: { 'Content-Type': 'application/json' } }
285
+ * );
286
+ * }
287
+ *
288
+ * return new Response(
289
+ * JSON.stringify({ error: 'User not found' }),
290
+ * { status: HTTPStatus.NOT_FOUND, headers: { 'Content-Type': 'application/json' } }
291
+ * );
292
+ * })
293
+ * ```
294
+ */
295
+ handle(functor: (r: Request) => Response): this;
265
296
  /**
266
297
  * Builds and returns the Response object along with the delay.
267
298
  * This method is typically called internally by the API class.
@@ -270,7 +301,7 @@ declare class ResponseBuilder {
270
301
  *
271
302
  * @internal
272
303
  */
273
- build(): {
304
+ build(request?: Request): {
274
305
  response: Response;
275
306
  delay: Duration;
276
307
  };
package/mocks.mjs CHANGED
@@ -309,6 +309,39 @@ class ResponseBuilder {
309
309
  this.delay = value;
310
310
  return this;
311
311
  }
312
+ /**
313
+ * Sets a custom handler function that receives the request and returns a complete Response.
314
+ * This provides full control over response generation, including status, headers, and body.
315
+ * When used, this overrides all other response builder methods (withStatus, withBody, etc.).
316
+ *
317
+ * @param functor - A function that receives the Request and returns a Response
318
+ * @returns This ResponseBuilder instance for chaining
319
+ *
320
+ * @example
321
+ * ```typescript
322
+ * // Dynamic response based on request details
323
+ * response().handle((req: Request) => {
324
+ * const url = new URL(req.url);
325
+ * const userId = url.pathname.split('/').pop();
326
+ *
327
+ * if (userId === '123') {
328
+ * return new Response(
329
+ * JSON.stringify({ id: 123, name: 'John' }),
330
+ * { status: HTTPStatus.OK, headers: { 'Content-Type': 'application/json' } }
331
+ * );
332
+ * }
333
+ *
334
+ * return new Response(
335
+ * JSON.stringify({ error: 'User not found' }),
336
+ * { status: HTTPStatus.NOT_FOUND, headers: { 'Content-Type': 'application/json' } }
337
+ * );
338
+ * })
339
+ * ```
340
+ */
341
+ handle(functor) {
342
+ this.handler = functor;
343
+ return this;
344
+ }
312
345
  /**
313
346
  * Builds and returns the Response object along with the delay.
314
347
  * This method is typically called internally by the API class.
@@ -317,15 +350,22 @@ class ResponseBuilder {
317
350
  *
318
351
  * @internal
319
352
  */
320
- build() {
353
+ build(request) {
321
354
  var _a, _b;
322
355
  let data;
356
+ if (this.handler) {
357
+ return { response: this.handler(request), delay: this.delay };
358
+ }
323
359
  if (this.body && typeof this.body === "string") {
324
360
  data = new Blob([this.body]);
325
361
  }
326
362
  else if (this.body instanceof Blob) {
327
363
  data = this.body;
328
364
  }
365
+ else if (this.body instanceof Function) {
366
+ const result = this.body(request);
367
+ data = result instanceof Blob ? result : new Blob([result]);
368
+ }
329
369
  const status = (_a = this.status) !== null && _a !== void 0 ? _a : HTTPStatus.OK;
330
370
  const response = new Response(data, {
331
371
  status,
@@ -544,7 +584,7 @@ class API {
544
584
  const matcher = this.requestMatcher(mockRequest);
545
585
  return (request) => matcher(request).then((match) => __awaiter(this, void 0, void 0, function* () {
546
586
  if (match) {
547
- const { response: resp, delay } = response.build();
587
+ const { response: resp, delay } = response.build(request);
548
588
  if (delay) {
549
589
  yield Future.sleep(delay);
550
590
  }
@@ -19,6 +19,7 @@ var http = require('./http.cjs');
19
19
  var request = require('./request.cjs');
20
20
  var manager = require('../data/store/manager.cjs');
21
21
  var stream_collector = require('../stream/collector.cjs');
22
+ var IllegalOperationError = require('../errors/IllegalOperationError.cjs');
22
23
 
23
24
  function _interopNamespaceDefault(e) {
24
25
  var n = Object.create(null);
@@ -43,12 +44,25 @@ var R__namespace = /*#__PURE__*/_interopNamespaceDefault(R);
43
44
  * A Snap Service for managing network requests
44
45
  */
45
46
  class NetworkService {
46
- constructor({ baseUrl, retryLimit, cacheManager } = {}) {
47
+ constructor({ baseUrl, retryLimit, cacheManager, persistor } = {}) {
47
48
  var _a, _b, _c;
48
49
  this.retryLimit = retryLimit;
49
50
  this.__internal__ = (_a = this.__internal__) !== null && _a !== void 0 ? _a : { classConfig: {}, methodConfig: {} };
50
51
  this.baseUrl = (_c = (_b = this.__internal__.classConfig.baseUrl) !== null && _b !== void 0 ? _b : baseUrl) !== null && _c !== void 0 ? _c : "";
51
- this.cacheManager = cacheManager !== null && cacheManager !== void 0 ? cacheManager : new manager.CacheManager();
52
+ this.cacheManager = cacheManager !== null && cacheManager !== void 0 ? cacheManager : new manager.CacheManager(persistor);
53
+ }
54
+ /**
55
+ * Manually set the credentials of the service, provided it has an authenticator (meaning this class should
56
+ * have declared an authenticator)
57
+ * @param credentials
58
+ */
59
+ __set_credentials__(credentials) {
60
+ var _a;
61
+ const cache = (_a = this.cacheManager.getCache(this.constructor.name)) !== null && _a !== void 0 ? _a : this.cacheManager.getCache(NetworkService.name);
62
+ if (cache === undefined) {
63
+ throw new IllegalOperationError.IllegalOperationError();
64
+ }
65
+ cache.set("auth", credentials);
52
66
  }
53
67
  /**
54
68
  * Converts the given value to a JSON object
@@ -330,10 +344,16 @@ class NetworkService {
330
344
  else {
331
345
  credentials = result;
332
346
  }
333
- if (auth.global)
347
+ if (auth.global) {
334
348
  NetworkService.credentials = credentials;
335
- else
349
+ const cache = this.cacheManager.getCache(NetworkService.name);
350
+ cache.set("auth", credentials);
351
+ }
352
+ else {
336
353
  classRef.credentials = credentials;
354
+ const cache = this.cacheManager.getCache(classRef.name);
355
+ cache.set("auth", credentials);
356
+ }
337
357
  return credentials;
338
358
  });
339
359
  }
@@ -357,6 +377,15 @@ class NetworkService {
357
377
  }
358
378
  const parentRef = config.authenticator.global ? NetworkService : classRef;
359
379
  const oldMethod = this[methodName];
380
+ const cache = this.cacheManager.hasCache(parentRef.name)
381
+ ? this.cacheManager.getCache(parentRef.name)
382
+ : this.cacheManager.createCache(parentRef.name, this.cacheManager.canPersist, (v) => v.json(), config.authenticator.type.fromJSON);
383
+ cache
384
+ .get("auth")
385
+ .thenApply(({ value }) => {
386
+ parentRef.credentials = value;
387
+ })
388
+ .schedule();
360
389
  this[methodName] = (...args) => {
361
390
  const result = oldMethod(...args);
362
391
  if (result instanceof Promise) {
@@ -364,11 +393,13 @@ class NetworkService {
364
393
  if (v instanceof credentials.Credentials) {
365
394
  parentRef.credentials = v;
366
395
  }
396
+ cache.set("auth", v);
367
397
  return v;
368
398
  });
369
399
  }
370
400
  else if (result instanceof credentials.Credentials) {
371
401
  parentRef.credentials = result;
402
+ cache.set("auth", result);
372
403
  }
373
404
  return result;
374
405
  };
@@ -1,3 +1,4 @@
1
+ import { Credentials } from "../data/model";
1
2
  import { GingerSnapProps } from "./index";
2
3
  import { TimeableObject } from "../data-structures/object";
3
4
  import { CacheManager } from "../data/store/manager";
@@ -59,7 +60,13 @@ export declare class NetworkService {
59
60
  * @protected
60
61
  */
61
62
  protected lookupCache: TimeableObject<string, any>;
62
- constructor({ baseUrl, retryLimit, cacheManager }?: GingerSnapProps);
63
+ constructor({ baseUrl, retryLimit, cacheManager, persistor }?: GingerSnapProps);
64
+ /**
65
+ * Manually set the credentials of the service, provided it has an authenticator (meaning this class should
66
+ * have declared an authenticator)
67
+ * @param credentials
68
+ */
69
+ __set_credentials__(credentials: Credentials): void;
63
70
  /**
64
71
  * Converts the given value to a JSON object
65
72
  * @param value Any data
@@ -17,17 +17,31 @@ import { HTTPStatus } from './http.mjs';
17
17
  import { request } from './request.mjs';
18
18
  import { CacheManager } from '../data/store/manager.mjs';
19
19
  import { Collectors } from '../stream/collector.mjs';
20
+ import { IllegalOperationError } from '../errors/IllegalOperationError.mjs';
20
21
 
21
22
  /**
22
23
  * A Snap Service for managing network requests
23
24
  */
24
25
  class NetworkService {
25
- constructor({ baseUrl, retryLimit, cacheManager } = {}) {
26
+ constructor({ baseUrl, retryLimit, cacheManager, persistor } = {}) {
26
27
  var _a, _b, _c;
27
28
  this.retryLimit = retryLimit;
28
29
  this.__internal__ = (_a = this.__internal__) !== null && _a !== void 0 ? _a : { classConfig: {}, methodConfig: {} };
29
30
  this.baseUrl = (_c = (_b = this.__internal__.classConfig.baseUrl) !== null && _b !== void 0 ? _b : baseUrl) !== null && _c !== void 0 ? _c : "";
30
- this.cacheManager = cacheManager !== null && cacheManager !== void 0 ? cacheManager : new CacheManager();
31
+ this.cacheManager = cacheManager !== null && cacheManager !== void 0 ? cacheManager : new CacheManager(persistor);
32
+ }
33
+ /**
34
+ * Manually set the credentials of the service, provided it has an authenticator (meaning this class should
35
+ * have declared an authenticator)
36
+ * @param credentials
37
+ */
38
+ __set_credentials__(credentials) {
39
+ var _a;
40
+ const cache = (_a = this.cacheManager.getCache(this.constructor.name)) !== null && _a !== void 0 ? _a : this.cacheManager.getCache(NetworkService.name);
41
+ if (cache === undefined) {
42
+ throw new IllegalOperationError();
43
+ }
44
+ cache.set("auth", credentials);
31
45
  }
32
46
  /**
33
47
  * Converts the given value to a JSON object
@@ -309,10 +323,16 @@ class NetworkService {
309
323
  else {
310
324
  credentials = result;
311
325
  }
312
- if (auth.global)
326
+ if (auth.global) {
313
327
  NetworkService.credentials = credentials;
314
- else
328
+ const cache = this.cacheManager.getCache(NetworkService.name);
329
+ cache.set("auth", credentials);
330
+ }
331
+ else {
315
332
  classRef.credentials = credentials;
333
+ const cache = this.cacheManager.getCache(classRef.name);
334
+ cache.set("auth", credentials);
335
+ }
316
336
  return credentials;
317
337
  });
318
338
  }
@@ -336,6 +356,15 @@ class NetworkService {
336
356
  }
337
357
  const parentRef = config.authenticator.global ? NetworkService : classRef;
338
358
  const oldMethod = this[methodName];
359
+ const cache = this.cacheManager.hasCache(parentRef.name)
360
+ ? this.cacheManager.getCache(parentRef.name)
361
+ : this.cacheManager.createCache(parentRef.name, this.cacheManager.canPersist, (v) => v.json(), config.authenticator.type.fromJSON);
362
+ cache
363
+ .get("auth")
364
+ .thenApply(({ value }) => {
365
+ parentRef.credentials = value;
366
+ })
367
+ .schedule();
339
368
  this[methodName] = (...args) => {
340
369
  const result = oldMethod(...args);
341
370
  if (result instanceof Promise) {
@@ -343,11 +372,13 @@ class NetworkService {
343
372
  if (v instanceof Credentials) {
344
373
  parentRef.credentials = v;
345
374
  }
375
+ cache.set("auth", v);
346
376
  return v;
347
377
  });
348
378
  }
349
379
  else if (result instanceof Credentials) {
350
380
  parentRef.credentials = result;
381
+ cache.set("auth", result);
351
382
  }
352
383
  return result;
353
384
  };
@@ -1,20 +1,26 @@
1
1
  import { Decoder } from "../data/decoders";
2
2
  import { NetworkService } from "./NetworkService";
3
- import { CacheManager } from "../data/store/manager";
3
+ import { CacheManager, PersistenceStore } from "../data/store/manager";
4
4
  export { NetworkService } from "./NetworkService";
5
5
  export { WebSocketService } from "./SocketService";
6
6
  export { EventSourceService } from "./EventSourceService";
7
7
  export { request } from "./request";
8
8
  export { GET, PUT, POST, DELETE, PATCH, OPTIONS, HEAD, DataDecoder, Take, Skip, IgnoreCache, ReplyableStream, WriteStream, MatcherValue, MatcherKey, ReadStream, NoAuth, HeaderMap, Header, Query, Path, QueryMap, StringBody, XMLBody, JSONBody, OptionalField, Field, Part, AuthRefresher, Authenticator, ThrottleBy, Throttle, Headers, FormUrlEncoded, Multipart, NoResponse, BinaryResponse, StringResponse, XMLResponse, JSONResponse, BaseUrl, Cached, RequestReply, } from "./decorators";
9
- export { ReplyStreamDirection, MapOfHeaders, ParamHeaders, MapOfQueries, MapOfPath, NONE, PASS } from "./types";
9
+ export { ReplyStreamDirection, MapOfHeaders, ParamHeaders, MapOfQueries, MapOfPath, NONE, PASS, RequestType, ResponseType, BodyType, } from "./types";
10
10
  export * from "./http";
11
11
  export interface GingerSnapProps {
12
12
  baseUrl?: string;
13
13
  retryLimit?: number;
14
14
  decoder?: Decoder<any>;
15
15
  cacheManager?: CacheManager;
16
+ persistor?: PersistenceStore;
16
17
  [string: string]: any;
17
18
  }
19
+ /**
20
+ * Properties that can be passed to GingerSnap constructor
21
+ * Excludes cacheManager and persistor which are only supported on individual services
22
+ */
23
+ export type GingerSnapConstructorProps = Omit<GingerSnapProps, "cacheManager" | "persistor" | "decoder">;
18
24
  /**
19
25
  * Core Service for creating Snap Services - services that manage network requests
20
26
  */
@@ -29,7 +35,7 @@ export declare class GingerSnap {
29
35
  * @private
30
36
  */
31
37
  private readonly retryLimit;
32
- constructor({ baseUrl, retryLimit }?: GingerSnapProps);
38
+ constructor({ baseUrl, retryLimit }?: GingerSnapConstructorProps);
33
39
  /**
34
40
  * Creates a new instance of the provided SnapService
35
41
  * @param Class A SnapService class
package/networking.cjs CHANGED
@@ -83,9 +83,21 @@ exports.RequestReply = socket.RequestReply;
83
83
  exports.Skip = socket.Skip;
84
84
  exports.Take = socket.Take;
85
85
  exports.WriteStream = socket.WriteStream;
86
+ Object.defineProperty(exports, 'BodyType', {
87
+ enumerable: true,
88
+ get: function () { return types.BodyType; }
89
+ });
86
90
  exports.PASS = types.PASS;
87
91
  Object.defineProperty(exports, 'ReplyStreamDirection', {
88
92
  enumerable: true,
89
93
  get: function () { return types.ReplyStreamDirection; }
90
94
  });
95
+ Object.defineProperty(exports, 'RequestType', {
96
+ enumerable: true,
97
+ get: function () { return types.RequestType; }
98
+ });
99
+ Object.defineProperty(exports, 'ResponseType', {
100
+ enumerable: true,
101
+ get: function () { return types.ResponseType; }
102
+ });
91
103
  exports.GingerSnap = GingerSnap;
package/networking.mjs CHANGED
@@ -6,7 +6,7 @@ export { AuthRefresher, Authenticator, BaseUrl, BinaryResponse, Field, FormUrlEn
6
6
  export { Cached, DELETE, GET, HEAD, OPTIONS, PATCH, POST, PUT } from './networking/decorators/requests.mjs';
7
7
  export { HTTPStatus } from './networking/http.mjs';
8
8
  export { DataDecoder, IgnoreCache, MatcherKey, MatcherValue, ReadStream, ReplyableStream, RequestReply, Skip, Take, WriteStream } from './networking/decorators/socket.mjs';
9
- export { PASS, ReplyStreamDirection } from './networking/types.mjs';
9
+ export { BodyType, PASS, ReplyStreamDirection, RequestType, ResponseType } from './networking/types.mjs';
10
10
 
11
11
  const DEFAULT_RETRY_LIMIT = 3;
12
12
  /**
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"gingersnap","version":"0.25.2","description":"A general purpose library built with the aim of filling the gaps of javascript shortcomings","dependencies":{"@msgpack/msgpack":"^3.0.0-beta2","browser-or-node":"^3.0.0-pre.0","modern-isomorphic-ws":"^1.0.5","object-hash":"^3.0.0","papaparse":"^5.4.1","protobufjs":"^7.2.6","ramda":"^0.30.1","reflect-metadata":"^0.2.2","tslib":"^2.6.3","uuid":"^9.0.1","ws":"^8.16.0","x2js":"^3.4.4"},"author":"CookieNerds LLC","exports":{"./synchronize":{"import":{"types":"./synchronize.d.ts","default":"./synchronize.mjs"},"require":{"types":"./synchronize.d.ts","default":"./synchronize.cjs"}},"./mocks":{"import":{"types":"./mocks.d.ts","default":"./mocks.mjs"},"require":{"types":"./mocks.d.ts","default":"./mocks.cjs"}},"./socket":{"import":{"types":"./socket.d.ts","default":"./socket.mjs"},"require":{"types":"./socket.d.ts","default":"./socket.cjs"}},"./typing/types":{"import":{"types":"./typing/types.d.ts","default":"./typing/types.mjs"},"require":{"types":"./typing/types.d.ts","default":"./typing/types.cjs"}},"./stream":{"import":{"types":"./stream/index.d.ts","default":"./stream.mjs"},"require":{"types":"./stream/index.d.ts","default":"./stream.cjs"}},"./reflection/injector":{"import":{"types":"./reflection/injector.d.ts","default":"./reflection/injector.mjs"},"require":{"types":"./reflection/injector.d.ts","default":"./reflection/injector.cjs"}},"./stream/call":{"import":{"types":"./stream/call.d.ts","default":"./stream/call.mjs"},"require":{"types":"./stream/call.d.ts","default":"./stream/call.cjs"}},"./stream/state":{"import":{"types":"./stream/state.d.ts","default":"./stream/state.mjs"},"require":{"types":"./stream/state.d.ts","default":"./stream/state.cjs"}},"./stream/collector":{"import":{"types":"./stream/collector.d.ts","default":"./stream/collector.mjs"},"require":{"types":"./stream/collector.d.ts","default":"./stream/collector.cjs"}},"./stream/observable":{"import":{"types":"./stream/observable.d.ts","default":"./stream/observable.mjs"},"require":{"types":"./stream/observable.d.ts","default":"./stream/observable.cjs"}},"./networking":{"import":{"types":"./networking/index.d.ts","default":"./networking.mjs"},"require":{"types":"./networking/index.d.ts","default":"./networking.cjs"}},"./managers":{"import":{"types":"./managers/index.d.ts","default":"./managers.mjs"},"require":{"types":"./managers/index.d.ts","default":"./managers.cjs"}},"./future":{"import":{"types":"./future/index.d.ts","default":"./future.mjs"},"require":{"types":"./future/index.d.ts","default":"./future.cjs"}},"./errors":{"import":{"types":"./errors/index.d.ts","default":"./errors.mjs"},"require":{"types":"./errors/index.d.ts","default":"./errors.cjs"}},"./data-structures/array":{"import":{"types":"./data-structures/array/index.d.ts","default":"./data-structures/array.mjs"},"require":{"types":"./data-structures/array/index.d.ts","default":"./data-structures/array.cjs"}},"./data-structures/object":{"import":{"types":"./data-structures/object/index.d.ts","default":"./data-structures/object.mjs"},"require":{"types":"./data-structures/object/index.d.ts","default":"./data-structures/object.cjs"}},"./data/decoders":{"import":{"types":"./data/decoders/index.d.ts","default":"./data/decoders.mjs"},"require":{"types":"./data/decoders/index.d.ts","default":"./data/decoders.cjs"}},"./data/model":{"import":{"types":"./data/model/index.d.ts","default":"./data/model.mjs"},"require":{"types":"./data/model/index.d.ts","default":"./data/model.cjs"}},"./data/bus":{"import":{"types":"./data/bus.d.ts","default":"./data/bus.mjs"},"require":{"types":"./data/bus.d.ts","default":"./data/bus.cjs"}},"./data/AtomicValue":{"import":{"types":"./data/AtomicValue.d.ts","default":"./data/AtomicValue.mjs"},"require":{"types":"./data/AtomicValue.d.ts","default":"./data/AtomicValue.cjs"}},"./data/store":{"import":{"types":"./data/store/index.d.ts","default":"./data/store.mjs"},"require":{"types":"./data/store/index.d.ts","default":"./data/store.cjs"}},"./functools":{"import":{"types":"./functools/index.d.ts","default":"./functools.mjs"},"require":{"types":"./functools/index.d.ts","default":"./functools.cjs"}},"./files":{"import":{"types":"./files.d.ts","default":"./files.mjs"},"require":{"types":"./files.d.ts","default":"./files.cjs"}}}}
1
+ {"name":"gingersnap","version":"0.26.2","description":"A general purpose library built with the aim of filling the gaps of javascript shortcomings","dependencies":{"@msgpack/msgpack":"^3.0.0-beta2","browser-or-node":"^3.0.0-pre.0","modern-isomorphic-ws":"^1.0.5","object-hash":"^3.0.0","papaparse":"^5.4.1","protobufjs":"^7.2.6","ramda":"^0.30.1","reflect-metadata":"^0.2.2","tslib":"^2.6.3","uuid":"^9.0.1","ws":"^8.16.0","x2js":"^3.4.4"},"author":"CookieNerds LLC","exports":{"./synchronize":{"import":{"types":"./synchronize.d.ts","default":"./synchronize.mjs"},"require":{"types":"./synchronize.d.ts","default":"./synchronize.cjs"}},"./mocks":{"import":{"types":"./mocks.d.ts","default":"./mocks.mjs"},"require":{"types":"./mocks.d.ts","default":"./mocks.cjs"}},"./socket":{"import":{"types":"./socket.d.ts","default":"./socket.mjs"},"require":{"types":"./socket.d.ts","default":"./socket.cjs"}},"./typing/types":{"import":{"types":"./typing/types.d.ts","default":"./typing/types.mjs"},"require":{"types":"./typing/types.d.ts","default":"./typing/types.cjs"}},"./stream":{"import":{"types":"./stream/index.d.ts","default":"./stream.mjs"},"require":{"types":"./stream/index.d.ts","default":"./stream.cjs"}},"./reflection/injector":{"import":{"types":"./reflection/injector.d.ts","default":"./reflection/injector.mjs"},"require":{"types":"./reflection/injector.d.ts","default":"./reflection/injector.cjs"}},"./stream/call":{"import":{"types":"./stream/call.d.ts","default":"./stream/call.mjs"},"require":{"types":"./stream/call.d.ts","default":"./stream/call.cjs"}},"./stream/state":{"import":{"types":"./stream/state.d.ts","default":"./stream/state.mjs"},"require":{"types":"./stream/state.d.ts","default":"./stream/state.cjs"}},"./stream/collector":{"import":{"types":"./stream/collector.d.ts","default":"./stream/collector.mjs"},"require":{"types":"./stream/collector.d.ts","default":"./stream/collector.cjs"}},"./stream/observable":{"import":{"types":"./stream/observable.d.ts","default":"./stream/observable.mjs"},"require":{"types":"./stream/observable.d.ts","default":"./stream/observable.cjs"}},"./networking":{"import":{"types":"./networking/index.d.ts","default":"./networking.mjs"},"require":{"types":"./networking/index.d.ts","default":"./networking.cjs"}},"./managers":{"import":{"types":"./managers/index.d.ts","default":"./managers.mjs"},"require":{"types":"./managers/index.d.ts","default":"./managers.cjs"}},"./future":{"import":{"types":"./future/index.d.ts","default":"./future.mjs"},"require":{"types":"./future/index.d.ts","default":"./future.cjs"}},"./errors":{"import":{"types":"./errors/index.d.ts","default":"./errors.mjs"},"require":{"types":"./errors/index.d.ts","default":"./errors.cjs"}},"./data-structures/array":{"import":{"types":"./data-structures/array/index.d.ts","default":"./data-structures/array.mjs"},"require":{"types":"./data-structures/array/index.d.ts","default":"./data-structures/array.cjs"}},"./data-structures/object":{"import":{"types":"./data-structures/object/index.d.ts","default":"./data-structures/object.mjs"},"require":{"types":"./data-structures/object/index.d.ts","default":"./data-structures/object.cjs"}},"./data/decoders":{"import":{"types":"./data/decoders/index.d.ts","default":"./data/decoders.mjs"},"require":{"types":"./data/decoders/index.d.ts","default":"./data/decoders.cjs"}},"./data/model":{"import":{"types":"./data/model/index.d.ts","default":"./data/model.mjs"},"require":{"types":"./data/model/index.d.ts","default":"./data/model.cjs"}},"./data/bus":{"import":{"types":"./data/bus.d.ts","default":"./data/bus.mjs"},"require":{"types":"./data/bus.d.ts","default":"./data/bus.cjs"}},"./data/AtomicValue":{"import":{"types":"./data/AtomicValue.d.ts","default":"./data/AtomicValue.mjs"},"require":{"types":"./data/AtomicValue.d.ts","default":"./data/AtomicValue.cjs"}},"./data/store":{"import":{"types":"./data/store/index.d.ts","default":"./data/store.mjs"},"require":{"types":"./data/store/index.d.ts","default":"./data/store.cjs"}},"./functools":{"import":{"types":"./functools/index.d.ts","default":"./functools.mjs"},"require":{"types":"./functools/index.d.ts","default":"./functools.cjs"}},"./files":{"import":{"types":"./files.d.ts","default":"./files.mjs"},"require":{"types":"./files.d.ts","default":"./files.cjs"}}}}
package/stream.cjs CHANGED
@@ -913,8 +913,9 @@ class Stream {
913
913
  _h = false;
914
914
  const _ = _c;
915
915
  this.finalActionHooks.forEach((hook) => hook());
916
- if (++index >= limit)
916
+ if (++index >= limit) {
917
917
  break;
918
+ }
918
919
  }
919
920
  }
920
921
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
@@ -1060,7 +1061,8 @@ class Stream {
1060
1061
  if (this.concurrencyLimit || this.sourceStream) {
1061
1062
  throw new IllegalOperationError.IllegalOperationError("Iterator cannot be called on a parallel stream.Please join first");
1062
1063
  }
1063
- return { done: true, value: yield this.execute().run() };
1064
+ this.executed = true;
1065
+ return { done: true, value };
1064
1066
  });
1065
1067
  }
1066
1068
  throw(e) {
package/stream.mjs CHANGED
@@ -892,8 +892,9 @@ class Stream {
892
892
  _h = false;
893
893
  const _ = _c;
894
894
  this.finalActionHooks.forEach((hook) => hook());
895
- if (++index >= limit)
895
+ if (++index >= limit) {
896
896
  break;
897
+ }
897
898
  }
898
899
  }
899
900
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
@@ -1039,7 +1040,8 @@ class Stream {
1039
1040
  if (this.concurrencyLimit || this.sourceStream) {
1040
1041
  throw new IllegalOperationError("Iterator cannot be called on a parallel stream.Please join first");
1041
1042
  }
1042
- return { done: true, value: yield this.execute().run() };
1043
+ this.executed = true;
1044
+ return { done: true, value };
1043
1045
  });
1044
1046
  }
1045
1047
  throw(e) {