@ddd-ts/shape 0.0.35 → 0.0.36
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.
|
@@ -5,6 +5,8 @@ export declare class MicrosecondTimestamp {
|
|
|
5
5
|
static MINUTE: MicrosecondTimestamp;
|
|
6
6
|
static HOUR: MicrosecondTimestamp;
|
|
7
7
|
static DAY: MicrosecondTimestamp;
|
|
8
|
+
static WEEK: MicrosecondTimestamp;
|
|
9
|
+
static MONTH: MicrosecondTimestamp;
|
|
8
10
|
constructor(micros: bigint);
|
|
9
11
|
isAfter(other: MicrosecondTimestamp): boolean;
|
|
10
12
|
equals(other: MicrosecondTimestamp): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"microsecond-timestamp.d.ts","sourceRoot":"","sources":["../../src/addons/microsecond-timestamp.ts"],"names":[],"mappings":"AAAA,qBAAa,oBAAoB;
|
|
1
|
+
{"version":3,"file":"microsecond-timestamp.d.ts","sourceRoot":"","sources":["../../src/addons/microsecond-timestamp.ts"],"names":[],"mappings":"AAAA,qBAAa,oBAAoB;IASnB,QAAQ,CAAC,MAAM,EAAE,MAAM;IARnC,MAAM,CAAC,WAAW,uBAA2C;IAC7D,MAAM,CAAC,MAAM,uBAA+B;IAC5C,MAAM,CAAC,MAAM,uBAAwB;IACrC,MAAM,CAAC,IAAI,uBAAwB;IACnC,MAAM,CAAC,GAAG,uBAAsB;IAChC,MAAM,CAAC,IAAI,uBAAoB;IAC/B,MAAM,CAAC,KAAK,uBAAqB;gBAEZ,MAAM,EAAE,MAAM;IAEnC,OAAO,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO;IAI7C,MAAM,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO;IAI5C,QAAQ,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO;IAI9C,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,GAAG,oBAAoB;IAMhE,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,GAAG,oBAAoB;IAMhE,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB;IAI1C,MAAM,CAAC,GAAG,IAAI,oBAAoB;IAIlC,MAAM,CAAC,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,oBAAoB;IAIjE,MAAM,CAAC,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,oBAAoB;IAInE,MAAM,CAAC,WAAW,CAChB,UAAU,EAAE,IAAI,GAAG,oBAAoB,GAAG,MAAM,GAC/C,oBAAoB;IAmBvB,SAAS;IAMT,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,oBAAoB,EAAE,KAAK,EAAE,oBAAoB,GAAG,MAAM;CAS7E"}
|
|
@@ -8,6 +8,8 @@ class MicrosecondTimestamp {
|
|
|
8
8
|
static MINUTE = this.SECOND.mult(60);
|
|
9
9
|
static HOUR = this.MINUTE.mult(60);
|
|
10
10
|
static DAY = this.HOUR.mult(24);
|
|
11
|
+
static WEEK = this.DAY.mult(7);
|
|
12
|
+
static MONTH = this.DAY.mult(30);
|
|
11
13
|
constructor(micros) {
|
|
12
14
|
this.micros = micros;
|
|
13
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"microsecond-timestamp.js","sourceRoot":"","sources":["../../src/addons/microsecond-timestamp.ts"],"names":[],"mappings":";;;AAAA,MAAa,oBAAoB;
|
|
1
|
+
{"version":3,"file":"microsecond-timestamp.js","sourceRoot":"","sources":["../../src/addons/microsecond-timestamp.ts"],"names":[],"mappings":";;;AAAA,MAAa,oBAAoB;IASV;IARrB,MAAM,CAAC,WAAW,GAAG,IAAI,oBAAoB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC7D,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5C,MAAM,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CA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,CAAC,IAAI,CAAC,IAA0B,EAAE,KAA2B;QACjE,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACxB,OAAO,CAAC,CAAC;QACX,CAAC;QACD,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,OAAO,CAAC,CAAC,CAAC;QACZ,CAAC;QACD,OAAO,CAAC,CAAC;IACX,CAAC;;AAtFH,oDAuFC","sourcesContent":["export class MicrosecondTimestamp {\n static MILLISECOND = new MicrosecondTimestamp(BigInt(1_000));\n static SECOND = this.MILLISECOND.mult(1000);\n static MINUTE = this.SECOND.mult(60);\n static HOUR = this.MINUTE.mult(60);\n static DAY = this.HOUR.mult(24);\n static WEEK = this.DAY.mult(7);\n static MONTH = this.DAY.mult(30);\n\n constructor(readonly micros: bigint) {}\n\n isAfter(other: MicrosecondTimestamp): boolean {\n return this.micros > other.micros;\n }\n\n equals(other: MicrosecondTimestamp): boolean {\n return this.micros === other.micros;\n }\n\n isBefore(other: MicrosecondTimestamp): boolean {\n return this.micros < other.micros;\n }\n\n add(micros: bigint | MicrosecondTimestamp): MicrosecondTimestamp {\n const value =\n micros instanceof MicrosecondTimestamp ? micros.micros : micros;\n return new MicrosecondTimestamp(this.micros + value);\n }\n\n sub(micros: bigint | MicrosecondTimestamp): MicrosecondTimestamp {\n const value =\n micros instanceof MicrosecondTimestamp ? micros.micros : micros;\n return new MicrosecondTimestamp(this.micros - value);\n }\n\n mult(factor: number): MicrosecondTimestamp {\n return new MicrosecondTimestamp(this.micros * BigInt(factor));\n }\n\n static now(): MicrosecondTimestamp {\n return new MicrosecondTimestamp(BigInt(Date.now()) * BigInt(1000));\n }\n\n static fromNanoseconds(nanoseconds: bigint): MicrosecondTimestamp {\n return new MicrosecondTimestamp(nanoseconds / BigInt(1000));\n }\n\n static fromMicroseconds(microseconds: bigint): MicrosecondTimestamp {\n return new MicrosecondTimestamp(microseconds);\n }\n\n static deserialize(\n serialized: Date | MicrosecondTimestamp | bigint,\n ): MicrosecondTimestamp {\n if (serialized instanceof MicrosecondTimestamp) {\n return serialized;\n }\n if (typeof serialized === \"bigint\") {\n return new MicrosecondTimestamp(serialized);\n }\n\n if (\n \"microseconds\" in serialized &&\n typeof serialized.microseconds === \"bigint\"\n ) {\n return new MicrosecondTimestamp(serialized.microseconds);\n }\n\n const micros = BigInt(serialized.getTime()) * BigInt(1000);\n return new MicrosecondTimestamp(micros);\n }\n\n serialize() {\n const date = new Date(Number(this.micros / BigInt(1000)));\n (date as any).microseconds = this.micros;\n return date;\n }\n\n static sort(left: MicrosecondTimestamp, right: MicrosecondTimestamp): number {\n if (left.isAfter(right)) {\n return 1;\n }\n if (left.isBefore(right)) {\n return -1;\n }\n return 0;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ddd-ts/shape",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.36",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
"test": "jest --config node_modules/@ddd-ts/tools/jest.config.js"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@ddd-ts/traits": "0.0.
|
|
15
|
+
"@ddd-ts/traits": "0.0.36"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@ddd-ts/tools": "0.0.
|
|
19
|
-
"@ddd-ts/types": "0.0.
|
|
18
|
+
"@ddd-ts/tools": "0.0.36",
|
|
19
|
+
"@ddd-ts/types": "0.0.36",
|
|
20
20
|
"@types/jest": "^29.5.1"
|
|
21
21
|
}
|
|
22
22
|
}
|