json-storage-formatter 1.0.0 → 1.0.2

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # json-storage-formater
1
+ # json-storage-formatter
2
2
 
3
3
  Package for json stringify objects without losing data types. The transformation of the data includes extra metadata into the resulted string which later on is used to restored all the data structures to the their origninal forms.
4
4
 
@@ -13,67 +13,67 @@ The main methods of the library are **formatToStore** and **formatFromStore**
13
13
  Format an object to be stored as JSON
14
14
 
15
15
  ```TS
16
- const objectWithMetadata = formatToStore(object);
17
-
18
- // The result can be JSON.stringify
19
- console.log(objectWithMetadata);
20
- /*
21
- {
22
- _type_: 'map',
23
- value: [
24
- [
25
- 'key1',
26
- {
27
- _type_: 'date',
28
- value: '2021-05-08T13:30:00.000Z',
29
- },
30
- ],
31
- [
32
- 'key2',
16
+ const objectWithMetadata = formatToStore(object);
17
+
18
+ // The result can be JSON.stringify
19
+ console.log(objectWithMetadata);
20
+ /*
21
+ {
22
+ _type_: 'map',
23
+ value: [
24
+ [
25
+ 'key1',
26
+ {
27
+ _type_: 'date',
28
+ value: '2021-05-08T13:30:00.000Z',
29
+ },
30
+ ],
31
+ [
32
+ 'key2',
33
+ {
34
+ _type_: 'set',
35
+ value: [
33
36
  {
34
- _type_: 'set',
37
+ _type_: 'map',
35
38
  value: [
36
- {
37
- _type_: 'map',
38
- value: [
39
- [
40
- 'key1',
41
- {
42
- _type_: 'date',
43
- value: '2021-05-08T13:30:00.000Z',
44
- },
45
- ],
46
- ],
47
- },
39
+ [
40
+ 'key1',
41
+ {
42
+ _type_: 'date',
43
+ value: '2021-05-08T13:30:00.000Z',
44
+ },
45
+ ],
48
46
  ],
49
47
  },
50
48
  ],
49
+ },
51
50
  ],
52
- }
53
- */
51
+ ],
52
+ }
53
+ */
54
54
 
55
55
  ```
56
56
 
57
57
  ## formatFromStore
58
58
 
59
- Format an value with possible metadata to his original form, it also supports Map, Set, Arrays
59
+ Format a value with possible metadata to his original form, it also supports Map, Set, Arrays
60
60
 
61
61
  ```TS
62
- const object = formatFromStore(objectWithMetadata);
63
-
64
- // Original types of the object with metadata
65
- console.log(object);
66
-
67
- /*
68
- // the result will be the same than executing the following code
69
- const formatFromStoreResultExample = new Map<string, unknown>([
70
- ['key1', new Date('2021-05-08T13:30:00.000Z')],
71
- [
72
- 'key2',
73
- new Set([new Map([['key1', new Date('2021-05-08T13:30:00.000Z')]])]),
74
- ],
75
- ]);
76
- */
62
+ const object = formatFromStore(objectWithMetadata);
63
+
64
+ // Original types of the object with metadata
65
+ console.log(object);
66
+
67
+ /*
68
+ // the result will be the same than executing the following code
69
+ const formatFromStoreResultExample = new Map<string, unknown>([
70
+ ['key1', new Date('2021-05-08T13:30:00.000Z')],
71
+ [
72
+ 'key2',
73
+ new Set([new Map([['key1', new Date('2021-05-08T13:30:00.000Z')]])]),
74
+ ],
75
+ ]);
76
+ */
77
77
  ```
78
78
 
79
79
  ## clone
@@ -1 +1 @@
1
- {"version":3,"file":"json-storage-formatter.d.ts","sourceRoot":"","sources":["../src/json-storage-formatter.ts"],"names":[],"mappings":"AAKA;;;;;KAKK;AACL,eAAO,MAAM,KAAK,kBAsCjB,CAAC;AAEF;;;;;;KAMK;AACL,eAAO,MAAM,KAAK,UAAW,OAAO,YAA0C,CAAC;AAE/E;;;;;;MAMM;AACN,eAAO,MAAM,QAAQ,UAAW,OAAO,YAA8B,CAAC;AAEtE;;;;;;KAMK;AACL,eAAO,MAAM,SAAS,UAAW,OAAO,YAA+B,CAAC;AAExE;;;;;;KAMK;AACL,eAAO,MAAM,QAAQ,UAAW,OAAO,YAA8B,CAAC;AAEtE;;;;;GAKG;AACH,eAAO,MAAM,MAAM,UAAW,OAAO,YAA0B,CAAC;AAEhE;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,UAAW,OAAO,YAKf,CAAC;AAE5B;;;;;GAKG;AACH,eAAO,MAAM,eAAe,mBAAkB,OAoD7C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,mBAAkB,OAwD3C,CAAC"}
1
+ {"version":3,"file":"json-storage-formatter.d.ts","sourceRoot":"","sources":["../src/json-storage-formatter.ts"],"names":[],"mappings":"AAKA;;;;;KAKK;AACL,eAAO,MAAM,KAAK,kBAqCjB,CAAC;AAEF;;;;;;KAMK;AACL,eAAO,MAAM,KAAK,UAAW,OAAO,YAA0C,CAAC;AAE/E;;;;;;MAMM;AACN,eAAO,MAAM,QAAQ,UAAW,OAAO,YAA8B,CAAC;AAEtE;;;;;;KAMK;AACL,eAAO,MAAM,SAAS,UAAW,OAAO,YAA+B,CAAC;AAExE;;;;;;KAMK;AACL,eAAO,MAAM,QAAQ,UAAW,OAAO,YAA8B,CAAC;AAEtE;;;;;GAKG;AACH,eAAO,MAAM,MAAM,UAAW,OAAO,YAA0B,CAAC;AAEhE;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,UAAW,OAAO,YAKf,CAAC;AAE5B;;;;;GAKG;AACH,eAAO,MAAM,eAAe,mBAAkB,OAoD7C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,aAAa,mBAAkB,OAwD3C,CAAC"}
@@ -8,7 +8,6 @@ exports.formatToStore = exports.formatFromStore = exports.isPrimitive = exports.
8
8
  * A deep clone of the object
9
9
  * */
10
10
  const clone = (obj) => {
11
- debugger;
12
11
  if ((0, exports.isPrimitive)(obj) || (0, exports.isDate)(obj)) {
13
12
  return obj;
14
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "json-storage-formatter",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Package for json stringify objects without losing data types",
5
5
  "main": "lib/json-storage-formatter.js",
6
6
  "files": [