@cratis/fundamentals 7.14.0 → 7.15.0

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.
Files changed (43) hide show
  1. package/Coordinate.ts +38 -0
  2. package/JsonSerializer.ts +14 -0
  3. package/README.md +10 -0
  4. package/dist/Coordinate.d.ts +7 -0
  5. package/dist/Coordinate.d.ts.map +1 -0
  6. package/dist/Coordinate.js +27 -0
  7. package/dist/Coordinate.js.map +1 -0
  8. package/dist/JsonSerializer.d.ts.map +1 -1
  9. package/dist/JsonSerializer.js +14 -0
  10. package/dist/JsonSerializer.js.map +1 -1
  11. package/dist/cjs/Coordinate.d.ts +7 -0
  12. package/dist/cjs/Coordinate.d.ts.map +1 -0
  13. package/dist/cjs/Coordinate.js +32 -0
  14. package/dist/cjs/Coordinate.js.map +1 -0
  15. package/dist/cjs/JsonSerializer.d.ts.map +1 -1
  16. package/dist/cjs/JsonSerializer.js +14 -0
  17. package/dist/cjs/JsonSerializer.js.map +1 -1
  18. package/dist/cjs/index.d.ts +1 -0
  19. package/dist/cjs/index.d.ts.map +1 -1
  20. package/dist/cjs/index.js +2 -0
  21. package/dist/cjs/index.js.map +1 -1
  22. package/dist/esm/Coordinate.d.ts +7 -0
  23. package/dist/esm/Coordinate.d.ts.map +1 -0
  24. package/dist/esm/Coordinate.js +30 -0
  25. package/dist/esm/Coordinate.js.map +1 -0
  26. package/dist/esm/JsonSerializer.d.ts.map +1 -1
  27. package/dist/esm/JsonSerializer.js +14 -0
  28. package/dist/esm/JsonSerializer.js.map +1 -1
  29. package/dist/esm/index.d.ts +1 -0
  30. package/dist/esm/index.d.ts.map +1 -1
  31. package/dist/esm/index.js +1 -0
  32. package/dist/esm/index.js.map +1 -1
  33. package/dist/index.d.ts +1 -0
  34. package/dist/index.d.ts.map +1 -1
  35. package/dist/index.js +1 -0
  36. package/dist/index.js.map +1 -1
  37. package/dist/tsconfig.tsbuildinfo +1 -1
  38. package/for_Coordinate/when_creating_coordinate.ts +11 -0
  39. package/for_Coordinate/when_deserializing_coordinate.ts +14 -0
  40. package/for_Coordinate/when_deserializing_coordinate_with_missing_properties.ts +13 -0
  41. package/for_Coordinate/when_serializing_coordinate.ts +14 -0
  42. package/index.ts +1 -0
  43. package/package.json +1 -1
@@ -0,0 +1,14 @@
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 { Coordinate } from '../Coordinate';
5
+ import { JsonSerializer } from '../JsonSerializer';
6
+
7
+ describe('when deserializing coordinate', () => {
8
+ const json = '{"longitude":10.5,"latitude":20.3}';
9
+ const result = JsonSerializer.deserialize(Coordinate, json);
10
+
11
+ it('should be a coordinate', () => result.should.be.instanceof(Coordinate));
12
+ it('should have correct longitude', () => result.longitude.should.equal(10.5));
13
+ it('should have correct latitude', () => result.latitude.should.equal(20.3));
14
+ });
@@ -0,0 +1,13 @@
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 { Coordinate } from '../Coordinate';
5
+ import { JsonSerializer } from '../JsonSerializer';
6
+
7
+ describe('when deserializing coordinate with missing properties', () => {
8
+ const json = '{"longitude":10.5}';
9
+
10
+ it('should throw an error', () => {
11
+ (() => JsonSerializer.deserialize(Coordinate, json)).should.throw('Cannot deserialize Coordinate: longitude and latitude are required');
12
+ });
13
+ });
@@ -0,0 +1,14 @@
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 { Coordinate } from '../Coordinate';
5
+ import { JsonSerializer } from '../JsonSerializer';
6
+
7
+ describe('when serializing coordinate', () => {
8
+ const coordinate = new Coordinate(10.5, 20.3);
9
+ const result = JsonSerializer.serialize(coordinate);
10
+ const deserialized = JSON.parse(result);
11
+
12
+ it('should have correct longitude', () => deserialized.longitude.should.equal(10.5));
13
+ it('should have correct latitude', () => deserialized.latitude.should.equal(20.3));
14
+ });
package/index.ts CHANGED
@@ -3,6 +3,7 @@
3
3
 
4
4
  export * from './ConceptAs';
5
5
  export * from './Constructor';
6
+ export * from './Coordinate';
6
7
  export * from './Field';
7
8
  export * from './Fields';
8
9
  export * from './Guid';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/fundamentals",
3
- "version": "7.14.0",
3
+ "version": "7.15.0",
4
4
  "description": "",
5
5
  "author": "Cratis",
6
6
  "license": "MIT",