json-storage-formatter 2.0.2 → 2.0.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "json-storage-formatter",
3
- "version": "2.0.2",
3
+ "version": "2.0.5",
4
4
  "description": "Package for json stringify objects without losing data types",
5
5
  "main": "./bundle.js",
6
6
  "types": "./index.d.ts",
@@ -68,8 +68,8 @@
68
68
  }
69
69
  },
70
70
  "files": [
71
- "lib/*.js",
72
- "lib/*.d.ts"
71
+ "./*.js",
72
+ "./*.d.ts"
73
73
  ],
74
74
  "scripts": {
75
75
  "test:debug": "node --inspect-brk node_modules/.bin/jest --watch --runInBand",
@@ -0,0 +1,66 @@
1
+ const path = require('path');
2
+
3
+ module.exports = {
4
+ mode: 'production',
5
+ entry: {
6
+ bundle: "./src/index.ts",
7
+ clone: "./src/clone.ts",
8
+ isNil: "./src/isNil.ts",
9
+ isNumber: "./src/isNumber.ts",
10
+ isBoolean: "./src/isBoolean.ts",
11
+ isString: "./src/isString.ts",
12
+ isDate: "./src/isDate.ts",
13
+ isRegex: "./src/isRegex.ts",
14
+ isFunction: "./src/isFunction.ts",
15
+ isPrimitive: "./src/isPrimitive.ts",
16
+ types: "./src/types.ts",
17
+ formatFromStore: "./src/formatFromStore.ts",
18
+ formatToStore: "./src/formatToStore.ts",
19
+ },
20
+ output: {
21
+ path: path.resolve(__dirname),//'lib'
22
+ filename: ({ chunk: { name } }) => {
23
+ if (name.includes('worker')) {
24
+ return `${name}.worker.js`;
25
+ }
26
+
27
+ return `${name}.js`;
28
+ },
29
+ libraryTarget: 'umd',
30
+ library: 'json-storage-formatter',
31
+ globalObject: 'this',
32
+ },
33
+ resolve: {
34
+ extensions: ['.ts', '.js'],
35
+ alias: {
36
+ 'json-storage-formatter': path.resolve(
37
+ __dirname,
38
+ 'node_modules/json-storage-formatter/package.json'
39
+ ),
40
+ },
41
+ },
42
+ module: {
43
+ rules: [
44
+ {
45
+ test: /\.ts$/,
46
+ use: [
47
+ {
48
+ loader: 'babel-loader',
49
+ options: {
50
+ presets: ['@babel/preset-env', '@babel/preset-typescript'],
51
+ plugins: [
52
+ '@babel/plugin-transform-modules-commonjs',
53
+ '@babel/plugin-proposal-class-properties',
54
+ '@babel/plugin-proposal-export-namespace-from',
55
+ ],
56
+ },
57
+ },
58
+ {
59
+ loader: 'ts-loader',
60
+ },
61
+ ],
62
+ exclude: /node_modules/,
63
+ },
64
+ ],
65
+ },
66
+ };
@@ -1,111 +0,0 @@
1
- export type IValueWithMetaData = {
2
- $t?: 'map' | 'set' | 'date' | 'regex' | 'error' | 'function';
3
- $v?: unknown;
4
- };
5
- /**
6
- * Deep clone an object, it also suppors Map, Set, Arrays
7
- * @param value
8
- * @returns
9
- * A deep clone of the object
10
- * */
11
- export declare const clone: <T>(value: T, { shallow, }?: {
12
- /**
13
- * If true, it will only clone the first level of the object
14
- */
15
- shallow?: boolean;
16
- }) => T;
17
- /**
18
- * Check if a value is null or undefined
19
- * @param value
20
- * @returns
21
- * true if the value is null or undefined
22
- * false otherwise
23
- * */
24
- export declare const isNil: (value: unknown) => value is null | undefined;
25
- /**
26
- * Check if a value is a number
27
- * @param value
28
- * @returns
29
- * true if the value is a number
30
- * false otherwise
31
- * */
32
- export declare const isNumber: (value: unknown) => value is number;
33
- /**
34
- * Check if a value is a boolean
35
- * @param value
36
- * @returns
37
- * true if the value is a boolean
38
- * false otherwise
39
- * */
40
- export declare const isBoolean: (value: unknown) => value is boolean;
41
- /**
42
- * Check if a value is a string
43
- * @param value
44
- * @returns
45
- * true if the value is a string
46
- * false otherwise
47
- * */
48
- export declare const isString: (value: unknown) => value is string;
49
- /** Check if a value is a Date
50
- * @param value
51
- * @returns
52
- * true if the value is a Date
53
- * false otherwise
54
- */
55
- export declare const isDate: (value: unknown) => value is Date;
56
- /**
57
- * Check if a value is a RegExp
58
- * @param value The value to check
59
- * @returns true if the value is a RegExp, false otherwise
60
- * */
61
- export declare const isRegex: (value: unknown) => value is RegExp;
62
- /**
63
- * Check if a value is a function
64
- * @param value The value to check
65
- * @returns true if the value is a function, false otherwise
66
- * */
67
- export declare const isFunction: <T extends (...args: Parameters<T>) => ReturnType<T>>(value: unknown) => value is NonNullable<T>;
68
- /**
69
- * Check if a value is a primitive
70
- * @param value
71
- * @returns
72
- * true if the value is a primitive
73
- * false otherwise
74
- * null, number, boolean, string, symbol
75
- */
76
- export declare const isPrimitive: (value: unknown) => value is string | number | boolean | symbol;
77
- /**
78
- * Format an value with possible metadata to his original form, it also supports Map, Set, Arrays
79
- * @param value
80
- * @returns
81
- * Original form of the value
82
- */
83
- export declare const formatFromStore: <T = unknown>(value: unknown, { jsonParse, sortKeys, }?: {
84
- /** If the value should be parsed from json before formatting */
85
- jsonParse?: boolean;
86
- sortKeys?: boolean | ((a: string, b: string) => number);
87
- }) => T;
88
- export type TPrimitives = 'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'undefined' | 'function' | 'object';
89
- /**
90
- * Add metadata to a value to store it as json, it also supports Map, Set, Arrays,
91
- * Returns a new object which is a clone of the original object with metadata
92
- * @template {TValue} The type of the value to format
93
- * @template {TStringify} If the value should be stringified
94
- * @param {TValue} value The value to format
95
- * @param {{ stringify: TStringify }} { stringify: boolean } If the value should be stringified
96
- */
97
- export declare const formatToStore: <TValue, TStringify extends boolean = false>(value: TValue, { stringify, validator, excludeTypes, excludeKeys, sortKeys, }?: {
98
- stringify?: TStringify;
99
- excludeTypes?: TPrimitives[] | Set<TPrimitives>;
100
- excludeKeys?: string[] | Set<string>;
101
- sortKeys?: boolean | ((a: string, b: string) => number);
102
- /**
103
- * Returns true if the value should be included in the stringified version,
104
- * if provided it will override the default validator and the excludesTypes and excludeKeys
105
- */
106
- validator?: ({ obj, key, value, }: {
107
- obj: unknown;
108
- key: string;
109
- value: unknown;
110
- }) => boolean | undefined;
111
- }) => TStringify extends true ? string : unknown;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes