json-storage-formatter 2.0.4 → 2.0.6

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.4",
3
+ "version": "2.0.6",
4
4
  "description": "Package for json stringify objects without losing data types",
5
5
  "main": "./bundle.js",
6
6
  "types": "./index.d.ts",
@@ -78,7 +78,8 @@
78
78
  "build": "webpack --config webpack.config.js",
79
79
  "prepare": "npm run build",
80
80
  "version": "npm run format && git add -A src",
81
- "postversion": "git push && git push --tags"
81
+ "postversion": "git push && git push --tags",
82
+ "clean": "find . -maxdepth 1 -type f \\( -name '*.js' -o -name '*.d.ts' \\) ! -name 'webpack.config.js' -exec rm {} +"
82
83
  },
83
84
  "repository": {
84
85
  "type": "git",
package/clone.d.ts DELETED
@@ -1,12 +0,0 @@
1
- /**
2
- * Deep clone an object, it also support Map, Set, Arrays
3
- * @param value
4
- * @returns
5
- * A deep clone of the object
6
- * */
7
- export declare const clone: <T>(value: T, { shallow, }?: {
8
- /**
9
- * If true, it will only clone the first level of the object
10
- */
11
- shallow?: boolean;
12
- }) => T;
@@ -1,11 +0,0 @@
1
- /**
2
- * Format an value with possible metadata to his original form, it also supports Map, Set, Arrays
3
- * @param value
4
- * @returns
5
- * Original form of the value
6
- */
7
- export declare const formatFromStore: <T = unknown>(value: unknown, { jsonParse, sortKeys, }?: {
8
- /** If the value should be parsed from json before formatting */
9
- jsonParse?: boolean;
10
- sortKeys?: boolean | ((a: string, b: string) => number);
11
- }) => T;
@@ -1,24 +0,0 @@
1
- import { TPrimitives } from "./types";
2
- /**
3
- * Add metadata to a value to store it as json, it also supports Map, Set, Arrays,
4
- * Returns a new object which is a clone of the original object with metadata
5
- * @template {TValue} The type of the value to format
6
- * @template {TStringify} If the value should be stringified
7
- * @param {TValue} value The value to format
8
- * @param {{ stringify: TStringify }} { stringify: boolean } If the value should be stringified
9
- */
10
- export declare const formatToStore: <TValue, TStringify extends boolean = false>(value: TValue, { stringify, validator, excludeTypes, excludeKeys, sortKeys, }?: {
11
- stringify?: TStringify;
12
- excludeTypes?: TPrimitives[] | Set<TPrimitives>;
13
- excludeKeys?: string[] | Set<string>;
14
- sortKeys?: boolean | ((a: string, b: string) => number);
15
- /**
16
- * Returns true if the value should be included in the stringified version,
17
- * if provided it will override the default validator and the excludesTypes and excludeKeys
18
- */
19
- validator?: ({ obj, key, value, }: {
20
- obj: unknown;
21
- key: string;
22
- value: unknown;
23
- }) => boolean | undefined;
24
- }) => TStringify extends true ? string : unknown;
package/index.d.ts DELETED
@@ -1,12 +0,0 @@
1
- export { clone } from "./clone";
2
- export { isNil } from "./isNil";
3
- export { isNumber } from "./isNumber";
4
- export { isBoolean } from "./isBoolean";
5
- export { isString } from "./isString";
6
- export { isDate } from "./isDate";
7
- export { isRegex } from "./isRegex";
8
- export { isFunction } from "./isFunction";
9
- export { isPrimitive } from "./isPrimitive";
10
- export { TPrimitives, IValueWithMetaData } from "./types";
11
- export { formatFromStore } from "./formatFromStore";
12
- export { formatToStore } from "./formatToStore";
package/isBoolean.d.ts DELETED
@@ -1,8 +0,0 @@
1
- /**
2
- * Check if a value is a boolean
3
- * @param value
4
- * @returns
5
- * true if the value is a boolean
6
- * false otherwise
7
- * */
8
- export declare const isBoolean: (value: unknown) => value is boolean;
package/isDate.d.ts DELETED
@@ -1,7 +0,0 @@
1
- /** Check if a value is a Date
2
- * @param value
3
- * @returns
4
- * true if the value is a Date
5
- * false otherwise
6
- */
7
- export declare const isDate: (value: unknown) => value is Date;
package/isFunction.d.ts DELETED
@@ -1,6 +0,0 @@
1
- /**
2
- * Check if a value is a function
3
- * @param value The value to check
4
- * @returns true if the value is a function, false otherwise
5
- * */
6
- export declare const isFunction: <T extends (...args: Parameters<T>) => ReturnType<T>>(value: unknown) => value is NonNullable<T>;
package/isNil.d.ts DELETED
@@ -1,8 +0,0 @@
1
- /**
2
- * Check if a value is null or undefined
3
- * @param value
4
- * @returns
5
- * true if the value is null or undefined
6
- * false otherwise
7
- * */
8
- export declare const isNil: (value: unknown) => value is null | undefined;
package/isNumber.d.ts DELETED
@@ -1,8 +0,0 @@
1
- /**
2
- * Check if a value is a number
3
- * @param value
4
- * @returns
5
- * true if the value is a number
6
- * false otherwise
7
- * */
8
- export declare const isNumber: (value: unknown) => value is number;
package/isPrimitive.d.ts DELETED
@@ -1,9 +0,0 @@
1
- /**
2
- * Check if a value is a primitive
3
- * @param value
4
- * @returns
5
- * true if the value is a primitive
6
- * false otherwise
7
- * null, number, boolean, string, symbol
8
- */
9
- export declare const isPrimitive: (value: unknown) => value is string | number | boolean | symbol;
package/isRegex.d.ts DELETED
@@ -1,6 +0,0 @@
1
- /**
2
- * Check if a value is a RegExp
3
- * @param value The value to check
4
- * @returns true if the value is a RegExp, false otherwise
5
- * */
6
- export declare const isRegex: (value: unknown) => value is RegExp;
package/isString.d.ts DELETED
@@ -1,8 +0,0 @@
1
- /**
2
- * Check if a value is a string
3
- * @param value
4
- * @returns
5
- * true if the value is a string
6
- * false otherwise
7
- * */
8
- export declare const isString: (value: unknown) => value is string;
package/types.d.ts DELETED
@@ -1,5 +0,0 @@
1
- export type IValueWithMetaData = {
2
- $t?: 'map' | 'set' | 'date' | 'regex' | 'error' | 'function';
3
- $v?: unknown;
4
- };
5
- export type TPrimitives = 'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'undefined' | 'function' | 'object';
package/webpack.config.js DELETED
@@ -1,66 +0,0 @@
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
- };