@cratis/fundamentals 7.22.3 → 7.22.4
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/JsonSerializer.ts +36 -14
- package/dist/JsonSerializer.d.ts.map +1 -1
- package/dist/JsonSerializer.js +29 -9
- package/dist/JsonSerializer.js.map +1 -1
- package/dist/cjs/JsonSerializer.d.ts.map +1 -1
- package/dist/cjs/JsonSerializer.js +28 -8
- package/dist/cjs/JsonSerializer.js.map +1 -1
- package/dist/cjs/index.js +3 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/typeKey.d.ts +3 -0
- package/dist/cjs/typeKey.d.ts.map +1 -1
- package/dist/cjs/typeKey.js +6 -0
- package/dist/cjs/typeKey.js.map +1 -1
- package/dist/esm/JsonSerializer.d.ts.map +1 -1
- package/dist/esm/JsonSerializer.js +29 -9
- package/dist/esm/JsonSerializer.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/typeKey.d.ts +3 -0
- package/dist/esm/typeKey.d.ts.map +1 -1
- package/dist/esm/typeKey.js +4 -1
- package/dist/esm/typeKey.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/typeKey.d.ts +3 -0
- package/dist/typeKey.d.ts.map +1 -1
- package/dist/typeKey.js +3 -0
- package/dist/typeKey.js.map +1 -1
- package/for_JsonSerializer/when_deserializing_a_value_map_with_c_sharp_written_negative_time_span_keys.ts +19 -0
- package/for_JsonSerializer/when_deserializing_a_value_map_with_c_sharp_written_time_only_keys.ts +19 -0
- package/for_JsonSerializer/when_deserializing_a_value_map_with_c_sharp_written_whole_second_time_span_keys.ts +19 -0
- package/for_JsonSerializer/when_deserializing_a_value_map_with_legacy_quoted_date_only_keys.ts +19 -0
- package/for_JsonSerializer/when_deserializing_a_value_map_with_legacy_quoted_time_only_keys.ts +19 -0
- package/for_JsonSerializer/when_deserializing_a_value_map_with_legacy_quoted_time_span_keys.ts +19 -0
- package/for_JsonSerializer/when_deserializing_a_value_map_with_malformed_date_only_keys.ts +20 -0
- package/for_JsonSerializer/when_deserializing_a_value_map_with_malformed_time_only_keys.ts +20 -0
- package/for_JsonSerializer/when_deserializing_a_value_map_with_malformed_time_span_keys.ts +20 -0
- package/for_JsonSerializer/when_round_tripping_a_value_map_with_date_only_keys.ts +26 -0
- package/for_JsonSerializer/when_round_tripping_a_value_map_with_time_only_keys.ts +26 -0
- package/for_JsonSerializer/when_round_tripping_a_value_map_with_time_span_keys.ts +26 -0
- package/package.json +1 -1
- package/typeKey.ts +9 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
|
|
4
|
+
import { TimeSpan } from '../TimeSpan';
|
|
5
|
+
import { JsonSerializer } from '../JsonSerializer';
|
|
6
|
+
import { ValueMap } from '../ValueMap';
|
|
7
|
+
import { field } from '../fieldDecorator';
|
|
8
|
+
|
|
9
|
+
class Totals {
|
|
10
|
+
@field(ValueMap, { genericArguments: [TimeSpan, Number] })
|
|
11
|
+
byKey!: ValueMap<TimeSpan, number>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
describe('when round tripping a value map with TimeSpan keys', () => {
|
|
15
|
+
const key = TimeSpan.parse('1.02:03:04.5');
|
|
16
|
+
const totals = new Totals();
|
|
17
|
+
totals.byKey = new ValueMap<TimeSpan, number>().set(key, 42);
|
|
18
|
+
|
|
19
|
+
const written = JsonSerializer.serialize(totals);
|
|
20
|
+
const read = JsonSerializer.deserialize(Totals, written);
|
|
21
|
+
|
|
22
|
+
it('should write the key as the plain string', () => written.should.equal('{"byKey":{"1.02:03:04.5":42}}'));
|
|
23
|
+
it('should read the key back as a TimeSpan', () => [...read.byKey.entries()][0][0].should.be.instanceof(TimeSpan));
|
|
24
|
+
it('should read the key back as the original value', () => [...read.byKey.entries()][0][0].toString().should.equal('1.02:03:04.5'));
|
|
25
|
+
it('should find the value by the original key', () => read.byKey.get(key)!.should.equal(42));
|
|
26
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cratis/fundamentals",
|
|
3
|
-
"version": "7.22.
|
|
3
|
+
"version": "7.22.4",
|
|
4
4
|
"description": "The shared building blocks beneath the Cratis stack — GUIDs, concepts, derived-type serialization, property-path proxies, and decorators for TypeScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cratis",
|
package/typeKey.ts
CHANGED
|
@@ -55,3 +55,12 @@ export const valueMapTypeKey = 'ValueMap';
|
|
|
55
55
|
|
|
56
56
|
/** The key `Guid` declares. */
|
|
57
57
|
export const guidTypeKey = 'Guid';
|
|
58
|
+
|
|
59
|
+
/** The key `DateOnly` declares. */
|
|
60
|
+
export const dateOnlyTypeKey = 'DateOnly';
|
|
61
|
+
|
|
62
|
+
/** The key `TimeOnly` declares. */
|
|
63
|
+
export const timeOnlyTypeKey = 'TimeOnly';
|
|
64
|
+
|
|
65
|
+
/** The key `TimeSpan` declares. */
|
|
66
|
+
export const timeSpanTypeKey = 'TimeSpan';
|