boma 2.0.0 → 2.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.
Files changed (2) hide show
  1. package/package.json +3 -5
  2. package/readme.md +37 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "boma",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "Primitive JSON helper",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -15,10 +15,8 @@
15
15
  },
16
16
  "exports": {
17
17
  ".": {
18
- "import": {
19
- "default": "./dist/index.js",
20
- "types": "./dist/index.d.ts"
21
- }
18
+ "types": "./dist/index.d.ts",
19
+ "import": "./dist/index.js"
22
20
  }
23
21
  },
24
22
  "author": "Nick G.",
package/readme.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Boma JSON helper
2
2
  Super-simple helper for working with JSON
3
3
 
4
- Work only in synchronous mode.
4
+ Work only in synchronous mode for now.
5
5
 
6
6
  # Usage
7
7
 
@@ -14,10 +14,44 @@ logs = {
14
14
  }
15
15
  */
16
16
 
17
- saveJSON(filePath: string, objToSave: Serializable, format?: boolean); // Format for save line break's
17
+ saveJSON({ filePath: '/test.json', objToSave: { any: {}, key: {} }, format: true, logSaving: false }); // Format for save line break's
18
+ /* Will save:
19
+ {
20
+ "any": {}, // saved line break's
21
+ "key": {}
22
+ }
23
+ */
18
24
 
19
- addToJSON('/support.log', { 6sdf89g7dghg: { any: "data" } });
25
+ addToJSON({ filePath: '/support.log', dataToAdd: { 6sdf89g7dghg: { any: "data" }}, format: false, logSaving: false });
20
26
  /* Will save:
21
27
  "{ "any": {}, "key": {}, "6sdf89g7dghg": { "any": "data" } }"
22
28
  */
23
29
  ```
30
+
31
+ ## Types
32
+ ```typescript
33
+ export type SerializablePrimitive = string | number | boolean | null;
34
+ export type SerializableArray = Serializable[];
35
+ export type SerializableObject = { [key: string]: Serializable };
36
+ export type Serializable = SerializablePrimitive | SerializableArray | SerializableObject;
37
+
38
+ export interface ReadJSONProps {
39
+ filePath: string;
40
+ parseJSON?: boolean;
41
+ createIfNotFound?: boolean | SerializableObject | SerializableArray; // Файл с чем создать, если не создан
42
+ }
43
+
44
+ export interface SaveJSONProps {
45
+ filePath: string;
46
+ objToSave: Serializable;
47
+ format?: boolean
48
+ logSaving?: boolean;
49
+ }
50
+
51
+ export interface addToJSONProps {
52
+ filePath: string;
53
+ dataToAdd: SerializableObject | SerializableArray;
54
+ format?: boolean
55
+ logSaving?: boolean;
56
+ }
57
+ ```