gingersnap 0.26.4 → 0.26.6
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/data-structures/object/Time.cjs +23 -0
- package/data-structures/object/Time.d.ts +14 -0
- package/data-structures/object/Time.mjs +23 -0
- package/mocks.cjs +3 -0
- package/mocks.d.ts +3 -3
- package/mocks.mjs +1 -1
- package/package.json +1 -1
|
@@ -487,6 +487,29 @@ class Instant {
|
|
|
487
487
|
static now() {
|
|
488
488
|
return new Instant(new Date().getTime());
|
|
489
489
|
}
|
|
490
|
+
/**
|
|
491
|
+
* Creates an Instant from an ISO 8601 string or epoch milliseconds.
|
|
492
|
+
*
|
|
493
|
+
* @param value - An ISO 8601 date-time string or epoch milliseconds
|
|
494
|
+
* @returns An Instant representing the specified moment
|
|
495
|
+
* @throws {Error} If the input is not a valid ISO 8601 string
|
|
496
|
+
*
|
|
497
|
+
* @example
|
|
498
|
+
* ```ts
|
|
499
|
+
* const i1 = Instant.from('2024-01-01T12:00:00.000Z');
|
|
500
|
+
* const i2 = Instant.from(1704110400000); // Epoch milliseconds
|
|
501
|
+
* ```
|
|
502
|
+
*/
|
|
503
|
+
static from(value) {
|
|
504
|
+
if (typeof value === "number") {
|
|
505
|
+
return new Instant(value);
|
|
506
|
+
}
|
|
507
|
+
const timestamp = Date.parse(value);
|
|
508
|
+
if (isNaN(timestamp)) {
|
|
509
|
+
throw new Error(`Invalid ISO 8601 date-time format: ${value}`);
|
|
510
|
+
}
|
|
511
|
+
return new Instant(timestamp);
|
|
512
|
+
}
|
|
490
513
|
/**
|
|
491
514
|
* Checks if this instant is in the distant future.
|
|
492
515
|
*
|
|
@@ -392,6 +392,20 @@ export declare class Instant {
|
|
|
392
392
|
* ```
|
|
393
393
|
*/
|
|
394
394
|
static now(): Instant;
|
|
395
|
+
/**
|
|
396
|
+
* Creates an Instant from an ISO 8601 string or epoch milliseconds.
|
|
397
|
+
*
|
|
398
|
+
* @param value - An ISO 8601 date-time string or epoch milliseconds
|
|
399
|
+
* @returns An Instant representing the specified moment
|
|
400
|
+
* @throws {Error} If the input is not a valid ISO 8601 string
|
|
401
|
+
*
|
|
402
|
+
* @example
|
|
403
|
+
* ```ts
|
|
404
|
+
* const i1 = Instant.from('2024-01-01T12:00:00.000Z');
|
|
405
|
+
* const i2 = Instant.from(1704110400000); // Epoch milliseconds
|
|
406
|
+
* ```
|
|
407
|
+
*/
|
|
408
|
+
static from(value: string | number): Instant;
|
|
395
409
|
/**
|
|
396
410
|
* Checks if this instant is in the distant future.
|
|
397
411
|
*
|
|
@@ -485,6 +485,29 @@ class Instant {
|
|
|
485
485
|
static now() {
|
|
486
486
|
return new Instant(new Date().getTime());
|
|
487
487
|
}
|
|
488
|
+
/**
|
|
489
|
+
* Creates an Instant from an ISO 8601 string or epoch milliseconds.
|
|
490
|
+
*
|
|
491
|
+
* @param value - An ISO 8601 date-time string or epoch milliseconds
|
|
492
|
+
* @returns An Instant representing the specified moment
|
|
493
|
+
* @throws {Error} If the input is not a valid ISO 8601 string
|
|
494
|
+
*
|
|
495
|
+
* @example
|
|
496
|
+
* ```ts
|
|
497
|
+
* const i1 = Instant.from('2024-01-01T12:00:00.000Z');
|
|
498
|
+
* const i2 = Instant.from(1704110400000); // Epoch milliseconds
|
|
499
|
+
* ```
|
|
500
|
+
*/
|
|
501
|
+
static from(value) {
|
|
502
|
+
if (typeof value === "number") {
|
|
503
|
+
return new Instant(value);
|
|
504
|
+
}
|
|
505
|
+
const timestamp = Date.parse(value);
|
|
506
|
+
if (isNaN(timestamp)) {
|
|
507
|
+
throw new Error(`Invalid ISO 8601 date-time format: ${value}`);
|
|
508
|
+
}
|
|
509
|
+
return new Instant(timestamp);
|
|
510
|
+
}
|
|
488
511
|
/**
|
|
489
512
|
* Checks if this instant is in the distant future.
|
|
490
513
|
*
|
package/mocks.cjs
CHANGED
|
@@ -844,7 +844,10 @@ const request = () => new RequestDetails();
|
|
|
844
844
|
*/
|
|
845
845
|
const response = () => new ResponseBuilder();
|
|
846
846
|
|
|
847
|
+
exports.API = API;
|
|
847
848
|
exports.MockNetworkService = MockNetworkService;
|
|
849
|
+
exports.RequestDetails = RequestDetails;
|
|
850
|
+
exports.ResponseBuilder = ResponseBuilder;
|
|
848
851
|
exports.atLeast = atLeast;
|
|
849
852
|
exports.atMost = atMost;
|
|
850
853
|
exports.exact = exact;
|
package/mocks.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ type Validator = (matches: Response[]) => boolean;
|
|
|
20
20
|
* @see request
|
|
21
21
|
* @see API.when
|
|
22
22
|
*/
|
|
23
|
-
declare class RequestDetails {
|
|
23
|
+
export declare class RequestDetails {
|
|
24
24
|
private method?;
|
|
25
25
|
private path?;
|
|
26
26
|
private headers;
|
|
@@ -149,7 +149,7 @@ declare class RequestDetails {
|
|
|
149
149
|
* @see response
|
|
150
150
|
* @see API.when
|
|
151
151
|
*/
|
|
152
|
-
declare class ResponseBuilder {
|
|
152
|
+
export declare class ResponseBuilder {
|
|
153
153
|
private status;
|
|
154
154
|
private headers;
|
|
155
155
|
private body?;
|
|
@@ -341,7 +341,7 @@ declare class ResponseBuilder {
|
|
|
341
341
|
* @see atMost
|
|
342
342
|
* @see range
|
|
343
343
|
*/
|
|
344
|
-
declare class API {
|
|
344
|
+
export declare class API {
|
|
345
345
|
private readonly matchers;
|
|
346
346
|
private processedRequests;
|
|
347
347
|
constructor();
|
package/mocks.mjs
CHANGED
|
@@ -842,4 +842,4 @@ const request = () => new RequestDetails();
|
|
|
842
842
|
*/
|
|
843
843
|
const response = () => new ResponseBuilder();
|
|
844
844
|
|
|
845
|
-
export { MockNetworkService, atLeast, atMost, exact, range, request, response };
|
|
845
|
+
export { API, MockNetworkService, RequestDetails, ResponseBuilder, atLeast, atMost, exact, range, request, response };
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"gingersnap","version":"0.26.
|
|
1
|
+
{"name":"gingersnap","version":"0.26.6","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"}}}}
|