@ddd-ts/shape 0.0.36 → 0.0.38
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/LICENSE +21 -0
- package/dist/_.d.ts +6 -6
- package/dist/_.d.ts.map +1 -1
- package/dist/_.js +34 -51
- package/dist/_.mjs +36 -0
- package/dist/addons/microsecond-timestamp.js +62 -75
- package/dist/addons/microsecond-timestamp.mjs +61 -0
- package/dist/choice.d.ts +1 -1
- package/dist/choice.d.ts.map +1 -1
- package/dist/choice.js +43 -48
- package/dist/choice.mjs +44 -0
- package/dist/class.d.ts +1 -1
- package/dist/class.d.ts.map +1 -1
- package/dist/class.js +29 -30
- package/dist/class.mjs +30 -0
- package/dist/dict.d.ts +1 -1
- package/dist/dict.d.ts.map +1 -1
- package/dist/dict.js +40 -46
- package/dist/dict.mjs +41 -0
- package/dist/discriminated-union.d.ts +2 -2
- package/dist/discriminated-union.d.ts.map +1 -1
- package/dist/discriminated-union.js +59 -90
- package/dist/discriminated-union.mjs +64 -0
- package/dist/either.d.ts +2 -2
- package/dist/either.d.ts.map +1 -1
- package/dist/either.js +50 -61
- package/dist/either.mjs +51 -0
- package/dist/index.js +32 -30
- package/dist/index.mjs +15 -0
- package/dist/literal.d.ts +1 -1
- package/dist/literal.d.ts.map +1 -1
- package/dist/literal.js +26 -26
- package/dist/literal.mjs +27 -0
- package/dist/mapping.d.ts +1 -1
- package/dist/mapping.d.ts.map +1 -1
- package/dist/mapping.js +44 -49
- package/dist/mapping.mjs +45 -0
- package/dist/multiple.d.ts +1 -1
- package/dist/multiple.d.ts.map +1 -1
- package/dist/multiple.js +118 -119
- package/dist/multiple.mjs +119 -0
- package/dist/nothing.d.ts +1 -1
- package/dist/nothing.d.ts.map +1 -1
- package/dist/nothing.js +18 -18
- package/dist/nothing.mjs +19 -0
- package/dist/optional.d.ts +1 -1
- package/dist/optional.d.ts.map +1 -1
- package/dist/optional.js +33 -40
- package/dist/optional.mjs +34 -0
- package/dist/primitive.d.ts +1 -1
- package/dist/primitive.d.ts.map +1 -1
- package/dist/primitive.js +29 -32
- package/dist/primitive.mjs +30 -0
- package/dist/test.d.ts +1 -1
- package/dist/test.d.ts.map +1 -1
- package/package.json +21 -10
- package/dist/_.js.map +0 -1
- package/dist/addons/microsecond-timestamp.js.map +0 -1
- package/dist/choice.js.map +0 -1
- package/dist/choice.spec.js +0 -147
- package/dist/choice.spec.js.map +0 -1
- package/dist/class.js.map +0 -1
- package/dist/class.spec.js +0 -39
- package/dist/class.spec.js.map +0 -1
- package/dist/dict.js.map +0 -1
- package/dist/dict.spec.js +0 -180
- package/dist/dict.spec.js.map +0 -1
- package/dist/discriminated-union.js.map +0 -1
- package/dist/discriminated-union.spec.js +0 -262
- package/dist/discriminated-union.spec.js.map +0 -1
- package/dist/either.js.map +0 -1
- package/dist/either.spec.js +0 -232
- package/dist/either.spec.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/literal.js.map +0 -1
- package/dist/literal.spec.js +0 -162
- package/dist/literal.spec.js.map +0 -1
- package/dist/mapping.js.map +0 -1
- package/dist/mapping.spec.js +0 -207
- package/dist/mapping.spec.js.map +0 -1
- package/dist/multiple.js.map +0 -1
- package/dist/multiple.spec.js +0 -207
- package/dist/multiple.spec.js.map +0 -1
- package/dist/nothing.js.map +0 -1
- package/dist/nothing.spec.js +0 -172
- package/dist/nothing.spec.js.map +0 -1
- package/dist/optional.js.map +0 -1
- package/dist/optional.spec.js +0 -172
- package/dist/optional.spec.js.map +0 -1
- package/dist/primitive.js.map +0 -1
- package/dist/primitive.spec.js +0 -162
- package/dist/primitive.spec.js.map +0 -1
- package/dist/test.js +0 -45
- package/dist/test.js.map +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Aetherall
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/_.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { IClass, ClassShorthand } from "./class";
|
|
2
|
-
import { IDict, DictShorthand } from "./dict";
|
|
3
|
-
import { Primitive, PrimitiveShorthand } from "./primitive";
|
|
4
|
-
import { IMultiple, MultipleShorthand } from "./multiple";
|
|
5
|
-
import { Nothing, NothingShorthand } from "./nothing";
|
|
6
|
-
import { ILiteral, LiteralShorthand } from "./literal";
|
|
1
|
+
import { type IClass, type ClassShorthand } from "./class";
|
|
2
|
+
import { type IDict, type DictShorthand } from "./dict";
|
|
3
|
+
import { Primitive, type PrimitiveShorthand } from "./primitive";
|
|
4
|
+
import { type IMultiple, type MultipleShorthand } from "./multiple";
|
|
5
|
+
import { Nothing, type NothingShorthand } from "./nothing";
|
|
6
|
+
import { type ILiteral, type LiteralShorthand } from "./literal";
|
|
7
7
|
export declare abstract class Empty {
|
|
8
8
|
}
|
|
9
9
|
export interface Constructor<T = any, P extends any[] = any[]> {
|
package/dist/_.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_.d.ts","sourceRoot":"","sources":["../src/_.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"_.d.ts","sourceRoot":"","sources":["../src/_.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,MAAM,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAQ,KAAK,KAAK,EAAE,KAAK,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAY,KAAK,SAAS,EAAE,KAAK,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAW,KAAK,QAAQ,EAAE,KAAK,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE1E,8BAAsB,KAAK;CAAG;AAE9B,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,GAAG,EAAE,GAAG,GAAG,EAAE;IAC3D,KAAK,GAAG,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC;CACrB;AACD,MAAM,MAAM,mBAAmB,CAC7B,CAAC,GAAG,GAAG,EACP,CAAC,SAAS,GAAG,EAAE,GAAG,GAAG,EAAE,IACrB,QAAQ,MAAM,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC;AAEnC,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,GAAG,CAAC;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AAM,YAAY,CACtB,CAAC,SAAS,mBAAmB,EAC7B,OAAO,SAAS,mBAAmB,IACjC,QAAQ,MACV,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,CAAC,KACpC,YAAY,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC"}
|
package/dist/_.js
CHANGED
|
@@ -1,55 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const nothing_1 = require("./nothing");
|
|
11
|
-
const literal_1 = require("./literal");
|
|
12
|
-
class Empty {
|
|
13
|
-
}
|
|
14
|
-
exports.Empty = Empty;
|
|
1
|
+
const require_class = require('./class.js');
|
|
2
|
+
const require_dict = require('./dict.js');
|
|
3
|
+
const require_primitive = require('./primitive.js');
|
|
4
|
+
const require_multiple = require('./multiple.js');
|
|
5
|
+
const require_nothing = require('./nothing.js');
|
|
6
|
+
const require_literal = require('./literal.js');
|
|
7
|
+
|
|
8
|
+
//#region src/_.ts
|
|
9
|
+
var Empty = class {};
|
|
15
10
|
function Shape(shorthand, base = Empty) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return (0, primitive_1.Primitive)(shorthand, base);
|
|
33
|
-
}
|
|
34
|
-
if (shorthand && "prototype" in shorthand) {
|
|
35
|
-
return (0, class_1.Class)(shorthand, base);
|
|
36
|
-
}
|
|
37
|
-
if (Array.isArray(shorthand)) {
|
|
38
|
-
return multiple_1.Multiple(shorthand[0], base);
|
|
39
|
-
}
|
|
40
|
-
if (typeof shorthand === "object") {
|
|
41
|
-
return (0, dict_1.Dict)(shorthand, base);
|
|
42
|
-
}
|
|
43
|
-
throw new Error(`Could not determine longhand from shorthand ${JSON.stringify(shorthand)}`);
|
|
11
|
+
if (typeof shorthand === "string" || typeof shorthand === "number") return require_literal.Literal(shorthand, base);
|
|
12
|
+
if (shorthand && "$shape" in shorthand && "name" in shorthand && typeof shorthand.name === "string") {
|
|
13
|
+
if (shorthand.name.startsWith("$")) return shorthand;
|
|
14
|
+
return require_class.Class(shorthand, base);
|
|
15
|
+
}
|
|
16
|
+
if (shorthand === void 0) return require_nothing.Nothing(void 0, base);
|
|
17
|
+
if ([
|
|
18
|
+
String,
|
|
19
|
+
Number,
|
|
20
|
+
Date,
|
|
21
|
+
Boolean
|
|
22
|
+
].includes(shorthand)) return require_primitive.Primitive(shorthand, base);
|
|
23
|
+
if (shorthand && "prototype" in shorthand) return require_class.Class(shorthand, base);
|
|
24
|
+
if (Array.isArray(shorthand)) return require_multiple.Multiple(shorthand[0], base);
|
|
25
|
+
if (typeof shorthand === "object") return require_dict.Dict(shorthand, base);
|
|
26
|
+
throw new Error(`Could not determine longhand from shorthand ${JSON.stringify(shorthand)}`);
|
|
44
27
|
}
|
|
45
28
|
function forward(base, forward) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
},
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
return base;
|
|
29
|
+
for (const key of forward) Object.defineProperty(base.prototype, key, { get() {
|
|
30
|
+
return this.value[key].bind(this.value);
|
|
31
|
+
} });
|
|
32
|
+
return base;
|
|
54
33
|
}
|
|
55
|
-
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
exports.Empty = Empty;
|
|
37
|
+
exports.Shape = Shape;
|
|
38
|
+
exports.forward = forward;
|
package/dist/_.mjs
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Class } from "./class.mjs";
|
|
2
|
+
import { Dict } from "./dict.mjs";
|
|
3
|
+
import { Primitive } from "./primitive.mjs";
|
|
4
|
+
import { Multiple } from "./multiple.mjs";
|
|
5
|
+
import { Nothing } from "./nothing.mjs";
|
|
6
|
+
import { Literal } from "./literal.mjs";
|
|
7
|
+
|
|
8
|
+
//#region src/_.ts
|
|
9
|
+
var Empty = class {};
|
|
10
|
+
function Shape(shorthand, base = Empty) {
|
|
11
|
+
if (typeof shorthand === "string" || typeof shorthand === "number") return Literal(shorthand, base);
|
|
12
|
+
if (shorthand && "$shape" in shorthand && "name" in shorthand && typeof shorthand.name === "string") {
|
|
13
|
+
if (shorthand.name.startsWith("$")) return shorthand;
|
|
14
|
+
return Class(shorthand, base);
|
|
15
|
+
}
|
|
16
|
+
if (shorthand === void 0) return Nothing(void 0, base);
|
|
17
|
+
if ([
|
|
18
|
+
String,
|
|
19
|
+
Number,
|
|
20
|
+
Date,
|
|
21
|
+
Boolean
|
|
22
|
+
].includes(shorthand)) return Primitive(shorthand, base);
|
|
23
|
+
if (shorthand && "prototype" in shorthand) return Class(shorthand, base);
|
|
24
|
+
if (Array.isArray(shorthand)) return Multiple(shorthand[0], base);
|
|
25
|
+
if (typeof shorthand === "object") return Dict(shorthand, base);
|
|
26
|
+
throw new Error(`Could not determine longhand from shorthand ${JSON.stringify(shorthand)}`);
|
|
27
|
+
}
|
|
28
|
+
function forward(base, forward) {
|
|
29
|
+
for (const key of forward) Object.defineProperty(base.prototype, key, { get() {
|
|
30
|
+
return this.value[key].bind(this.value);
|
|
31
|
+
} });
|
|
32
|
+
return base;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
export { Empty, Shape, forward };
|
|
@@ -1,75 +1,62 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}
|
|
64
|
-
static sort(left, right) {
|
|
65
|
-
if (left.isAfter(right)) {
|
|
66
|
-
return 1;
|
|
67
|
-
}
|
|
68
|
-
if (left.isBefore(right)) {
|
|
69
|
-
return -1;
|
|
70
|
-
}
|
|
71
|
-
return 0;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
exports.MicrosecondTimestamp = MicrosecondTimestamp;
|
|
75
|
-
//# sourceMappingURL=microsecond-timestamp.js.map
|
|
1
|
+
|
|
2
|
+
//#region src/addons/microsecond-timestamp.ts
|
|
3
|
+
var MicrosecondTimestamp = class MicrosecondTimestamp {
|
|
4
|
+
static MILLISECOND = new MicrosecondTimestamp(BigInt(1e3));
|
|
5
|
+
static SECOND = this.MILLISECOND.mult(1e3);
|
|
6
|
+
static MINUTE = this.SECOND.mult(60);
|
|
7
|
+
static HOUR = this.MINUTE.mult(60);
|
|
8
|
+
static DAY = this.HOUR.mult(24);
|
|
9
|
+
static WEEK = this.DAY.mult(7);
|
|
10
|
+
static MONTH = this.DAY.mult(30);
|
|
11
|
+
constructor(micros) {
|
|
12
|
+
this.micros = micros;
|
|
13
|
+
}
|
|
14
|
+
isAfter(other) {
|
|
15
|
+
return this.micros > other.micros;
|
|
16
|
+
}
|
|
17
|
+
equals(other) {
|
|
18
|
+
return this.micros === other.micros;
|
|
19
|
+
}
|
|
20
|
+
isBefore(other) {
|
|
21
|
+
return this.micros < other.micros;
|
|
22
|
+
}
|
|
23
|
+
add(micros) {
|
|
24
|
+
const value = micros instanceof MicrosecondTimestamp ? micros.micros : micros;
|
|
25
|
+
return new MicrosecondTimestamp(this.micros + value);
|
|
26
|
+
}
|
|
27
|
+
sub(micros) {
|
|
28
|
+
const value = micros instanceof MicrosecondTimestamp ? micros.micros : micros;
|
|
29
|
+
return new MicrosecondTimestamp(this.micros - value);
|
|
30
|
+
}
|
|
31
|
+
mult(factor) {
|
|
32
|
+
return new MicrosecondTimestamp(this.micros * BigInt(factor));
|
|
33
|
+
}
|
|
34
|
+
static now() {
|
|
35
|
+
return new MicrosecondTimestamp(BigInt(Date.now()) * BigInt(1e3));
|
|
36
|
+
}
|
|
37
|
+
static fromNanoseconds(nanoseconds) {
|
|
38
|
+
return new MicrosecondTimestamp(nanoseconds / BigInt(1e3));
|
|
39
|
+
}
|
|
40
|
+
static fromMicroseconds(microseconds) {
|
|
41
|
+
return new MicrosecondTimestamp(microseconds);
|
|
42
|
+
}
|
|
43
|
+
static deserialize(serialized) {
|
|
44
|
+
if (serialized instanceof MicrosecondTimestamp) return serialized;
|
|
45
|
+
if (typeof serialized === "bigint") return new MicrosecondTimestamp(serialized);
|
|
46
|
+
if ("microseconds" in serialized && typeof serialized.microseconds === "bigint") return new MicrosecondTimestamp(serialized.microseconds);
|
|
47
|
+
return new MicrosecondTimestamp(BigInt(serialized.getTime()) * BigInt(1e3));
|
|
48
|
+
}
|
|
49
|
+
serialize() {
|
|
50
|
+
const date = new Date(Number(this.micros / BigInt(1e3)));
|
|
51
|
+
date.microseconds = this.micros;
|
|
52
|
+
return date;
|
|
53
|
+
}
|
|
54
|
+
static sort(left, right) {
|
|
55
|
+
if (left.isAfter(right)) return 1;
|
|
56
|
+
if (left.isBefore(right)) return -1;
|
|
57
|
+
return 0;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
//#endregion
|
|
62
|
+
exports.MicrosecondTimestamp = MicrosecondTimestamp;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
//#region src/addons/microsecond-timestamp.ts
|
|
2
|
+
var MicrosecondTimestamp = class MicrosecondTimestamp {
|
|
3
|
+
static MILLISECOND = new MicrosecondTimestamp(BigInt(1e3));
|
|
4
|
+
static SECOND = this.MILLISECOND.mult(1e3);
|
|
5
|
+
static MINUTE = this.SECOND.mult(60);
|
|
6
|
+
static HOUR = this.MINUTE.mult(60);
|
|
7
|
+
static DAY = this.HOUR.mult(24);
|
|
8
|
+
static WEEK = this.DAY.mult(7);
|
|
9
|
+
static MONTH = this.DAY.mult(30);
|
|
10
|
+
constructor(micros) {
|
|
11
|
+
this.micros = micros;
|
|
12
|
+
}
|
|
13
|
+
isAfter(other) {
|
|
14
|
+
return this.micros > other.micros;
|
|
15
|
+
}
|
|
16
|
+
equals(other) {
|
|
17
|
+
return this.micros === other.micros;
|
|
18
|
+
}
|
|
19
|
+
isBefore(other) {
|
|
20
|
+
return this.micros < other.micros;
|
|
21
|
+
}
|
|
22
|
+
add(micros) {
|
|
23
|
+
const value = micros instanceof MicrosecondTimestamp ? micros.micros : micros;
|
|
24
|
+
return new MicrosecondTimestamp(this.micros + value);
|
|
25
|
+
}
|
|
26
|
+
sub(micros) {
|
|
27
|
+
const value = micros instanceof MicrosecondTimestamp ? micros.micros : micros;
|
|
28
|
+
return new MicrosecondTimestamp(this.micros - value);
|
|
29
|
+
}
|
|
30
|
+
mult(factor) {
|
|
31
|
+
return new MicrosecondTimestamp(this.micros * BigInt(factor));
|
|
32
|
+
}
|
|
33
|
+
static now() {
|
|
34
|
+
return new MicrosecondTimestamp(BigInt(Date.now()) * BigInt(1e3));
|
|
35
|
+
}
|
|
36
|
+
static fromNanoseconds(nanoseconds) {
|
|
37
|
+
return new MicrosecondTimestamp(nanoseconds / BigInt(1e3));
|
|
38
|
+
}
|
|
39
|
+
static fromMicroseconds(microseconds) {
|
|
40
|
+
return new MicrosecondTimestamp(microseconds);
|
|
41
|
+
}
|
|
42
|
+
static deserialize(serialized) {
|
|
43
|
+
if (serialized instanceof MicrosecondTimestamp) return serialized;
|
|
44
|
+
if (typeof serialized === "bigint") return new MicrosecondTimestamp(serialized);
|
|
45
|
+
if ("microseconds" in serialized && typeof serialized.microseconds === "bigint") return new MicrosecondTimestamp(serialized.microseconds);
|
|
46
|
+
return new MicrosecondTimestamp(BigInt(serialized.getTime()) * BigInt(1e3));
|
|
47
|
+
}
|
|
48
|
+
serialize() {
|
|
49
|
+
const date = new Date(Number(this.micros / BigInt(1e3)));
|
|
50
|
+
date.microseconds = this.micros;
|
|
51
|
+
return date;
|
|
52
|
+
}
|
|
53
|
+
static sort(left, right) {
|
|
54
|
+
if (left.isAfter(right)) return 1;
|
|
55
|
+
if (left.isBefore(right)) return -1;
|
|
56
|
+
return 0;
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
//#endregion
|
|
61
|
+
export { MicrosecondTimestamp };
|
package/dist/choice.d.ts
CHANGED
package/dist/choice.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"choice.d.ts","sourceRoot":"","sources":["../src/choice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"choice.d.ts","sourceRoot":"","sources":["../src/choice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,EAAe,KAAK,WAAW,EAAE,MAAM,KAAK,CAAC;AAErF,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,MAAM,EAAE,IACxC;KACG,GAAG,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG,MAAM,GAAG;CAC9B,GACD,CA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
|
|
44
|
-
}
|
|
45
|
-
return $Choice;
|
|
1
|
+
const require__ = require('./_.js');
|
|
2
|
+
|
|
3
|
+
//#region src/choice.ts
|
|
4
|
+
const Choice = (config, base = require__.Empty) => {
|
|
5
|
+
class $Choice extends base {
|
|
6
|
+
static $shape = "choice";
|
|
7
|
+
static $of = config;
|
|
8
|
+
static values = config;
|
|
9
|
+
constructor(value) {
|
|
10
|
+
super();
|
|
11
|
+
this.value = value;
|
|
12
|
+
}
|
|
13
|
+
is(value) {
|
|
14
|
+
return this.value === value;
|
|
15
|
+
}
|
|
16
|
+
match(matcher) {
|
|
17
|
+
const handler = matcher[this.value];
|
|
18
|
+
if (handler) return handler();
|
|
19
|
+
return matcher._();
|
|
20
|
+
}
|
|
21
|
+
serialize() {
|
|
22
|
+
return this.value;
|
|
23
|
+
}
|
|
24
|
+
static deserialize(value) {
|
|
25
|
+
return new this(value);
|
|
26
|
+
}
|
|
27
|
+
static $deserialize(value) {
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
static $serialize(value) {
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
static $inline;
|
|
34
|
+
static {
|
|
35
|
+
for (const choice of config) this[choice] = function() {
|
|
36
|
+
return new this(choice);
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return $Choice;
|
|
46
41
|
};
|
|
47
|
-
|
|
48
|
-
//#
|
|
49
|
-
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
exports.Choice = Choice;
|
package/dist/choice.mjs
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Empty } from "./_.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/choice.ts
|
|
4
|
+
const Choice = (config, base = Empty) => {
|
|
5
|
+
class $Choice extends base {
|
|
6
|
+
static $shape = "choice";
|
|
7
|
+
static $of = config;
|
|
8
|
+
static values = config;
|
|
9
|
+
constructor(value) {
|
|
10
|
+
super();
|
|
11
|
+
this.value = value;
|
|
12
|
+
}
|
|
13
|
+
is(value) {
|
|
14
|
+
return this.value === value;
|
|
15
|
+
}
|
|
16
|
+
match(matcher) {
|
|
17
|
+
const handler = matcher[this.value];
|
|
18
|
+
if (handler) return handler();
|
|
19
|
+
return matcher._();
|
|
20
|
+
}
|
|
21
|
+
serialize() {
|
|
22
|
+
return this.value;
|
|
23
|
+
}
|
|
24
|
+
static deserialize(value) {
|
|
25
|
+
return new this(value);
|
|
26
|
+
}
|
|
27
|
+
static $deserialize(value) {
|
|
28
|
+
return value;
|
|
29
|
+
}
|
|
30
|
+
static $serialize(value) {
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
static $inline;
|
|
34
|
+
static {
|
|
35
|
+
for (const choice of config) this[choice] = function() {
|
|
36
|
+
return new this(choice);
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return $Choice;
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
//#endregion
|
|
44
|
+
export { Choice };
|
package/dist/class.d.ts
CHANGED
package/dist/class.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../src/class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"class.d.ts","sourceRoot":"","sources":["../src/class.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,mBAAmB,EAAE,KAAK,EAAE,KAAK,WAAW,EAAE,KAAK,MAAM,EAAE,MAAM,KAAK,CAAC;AAErF,MAAM,MAAM,cAAc,GAAG,WAAW,CAAC;IAAE,SAAS,IAAI,GAAG,CAAA;CAAE,CAAC,GAAG;IAC/D,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,GAAG,CAAC;CAC9B,CAAC;AAEF,eAAO,MAAM,KAAK,GAChB,CAAC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CAAC"}
|
package/dist/class.js
CHANGED
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
return $Class;
|
|
1
|
+
const require__ = require('./_.js');
|
|
2
|
+
|
|
3
|
+
//#region src/class.ts
|
|
4
|
+
const Class = (of, base = require__.Empty) => {
|
|
5
|
+
class $Class extends base {
|
|
6
|
+
static $shape = "class";
|
|
7
|
+
static $of = of;
|
|
8
|
+
constructor(value) {
|
|
9
|
+
super();
|
|
10
|
+
this.value = value;
|
|
11
|
+
}
|
|
12
|
+
static deserialize(value) {
|
|
13
|
+
return new this(of.deserialize(value));
|
|
14
|
+
}
|
|
15
|
+
serialize() {
|
|
16
|
+
return this.value.serialize();
|
|
17
|
+
}
|
|
18
|
+
static $deserialize(value) {
|
|
19
|
+
return of.deserialize(value);
|
|
20
|
+
}
|
|
21
|
+
static $serialize(value) {
|
|
22
|
+
return value.serialize();
|
|
23
|
+
}
|
|
24
|
+
static $inline;
|
|
25
|
+
}
|
|
26
|
+
return $Class;
|
|
29
27
|
};
|
|
30
|
-
|
|
31
|
-
//#
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
exports.Class = Class;
|
package/dist/class.mjs
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Empty } from "./_.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/class.ts
|
|
4
|
+
const Class = (of, base = Empty) => {
|
|
5
|
+
class $Class extends base {
|
|
6
|
+
static $shape = "class";
|
|
7
|
+
static $of = of;
|
|
8
|
+
constructor(value) {
|
|
9
|
+
super();
|
|
10
|
+
this.value = value;
|
|
11
|
+
}
|
|
12
|
+
static deserialize(value) {
|
|
13
|
+
return new this(of.deserialize(value));
|
|
14
|
+
}
|
|
15
|
+
serialize() {
|
|
16
|
+
return this.value.serialize();
|
|
17
|
+
}
|
|
18
|
+
static $deserialize(value) {
|
|
19
|
+
return of.deserialize(value);
|
|
20
|
+
}
|
|
21
|
+
static $serialize(value) {
|
|
22
|
+
return value.serialize();
|
|
23
|
+
}
|
|
24
|
+
static $inline;
|
|
25
|
+
}
|
|
26
|
+
return $Class;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
//#endregion
|
|
30
|
+
export { Class };
|