@michaelroling/ts-library 1.0.3 → 1.0.4
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/dist/index.d.ts +5 -0
- package/dist/json/index.d.ts +3 -0
- package/dist/json/index.js +2 -2
- package/dist/lib/index.d.ts +6 -0
- package/dist/prototype/array.d.ts +1 -0
- package/dist/prototype/number.d.ts +1 -0
- package/dist/prototype/string.d.ts +1 -0
- package/dist/types/index.d.ts +4 -4
- package/dist/types/json.d.ts +5 -2
- package/dist/types/lib.d.ts +11 -4
- package/package.json +9 -2
package/dist/index.d.ts
ADDED
package/dist/json/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export const toJsonString = (val) => JSON.stringify(val, null, 2);
|
|
2
|
-
export
|
|
2
|
+
export const toJSON = (val) => {
|
|
3
3
|
try {
|
|
4
4
|
return val ? { json: JSON.parse(val), isValidJson: true } : { json: null, isValidJson: false, error: "Value is null" };
|
|
5
5
|
}
|
|
6
6
|
catch (e) {
|
|
7
7
|
return { json: null, isValidJson: false, error: e };
|
|
8
8
|
}
|
|
9
|
-
}
|
|
9
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DeepCopy, IsDefined, IsFalsy, IsString, IsTruthy } from "../types/lib";
|
|
2
|
+
export declare const isTruthy: IsTruthy;
|
|
3
|
+
export declare const isFalsy: IsFalsy;
|
|
4
|
+
export declare const isDefined: IsDefined;
|
|
5
|
+
export declare const deepCopy: DeepCopy;
|
|
6
|
+
export declare const isString: IsString;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../types/array.d.ts";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../types/number.d.ts";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../types/string.d.ts";
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import "./array";
|
|
2
|
-
import "./json";
|
|
3
|
-
import "./lib";
|
|
4
|
-
import "./string";
|
|
1
|
+
import "./array";
|
|
2
|
+
import "./json";
|
|
3
|
+
import "./lib";
|
|
4
|
+
import "./string";
|
package/dist/types/json.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
export declare
|
|
1
|
+
export declare const toJSON: ToJSON;
|
|
2
|
+
export declare const toJsonString: ToJsonString;
|
|
3
|
+
|
|
4
|
+
export type ToJSON = <T>(val: string | null) => JsonResponse<T>;
|
|
5
|
+
export type ToJsonString = (val: string | number | boolean | object) => string;
|
|
3
6
|
|
|
4
7
|
export interface JsonResponse<T> {
|
|
5
8
|
json: T | null;
|
package/dist/types/lib.d.ts
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
export declare
|
|
2
|
-
export declare
|
|
3
|
-
export declare
|
|
4
|
-
export declare
|
|
1
|
+
export declare const isTruthy: IsTruthy;
|
|
2
|
+
export declare const isFalsy: IsFalsy;
|
|
3
|
+
export declare const isDefined: IsDefined;
|
|
4
|
+
export declare const deepCopy: DeepCopy;
|
|
5
|
+
export declare const isString: IsString;
|
|
6
|
+
|
|
7
|
+
export type IsTruthy = (value: any) => boolean;
|
|
8
|
+
export type IsFalsy = (value: any) => boolean;
|
|
9
|
+
export type IsDefined = <T>(value: T | undefined | null) => value is T;
|
|
10
|
+
export type DeepCopy = <T>(obj: T, errorHandler?: (e: any) => void) => T | undefined;
|
|
11
|
+
export type IsString = (value: unknown) => value is string;
|
package/package.json
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@michaelroling/ts-library",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
7
7
|
"module": "dist/index.js",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/types/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
8
15
|
"publishConfig": {
|
|
9
16
|
"access": "public"
|
|
10
17
|
},
|
|
@@ -36,7 +43,7 @@
|
|
|
36
43
|
"prepublishOnly": "yarn build"
|
|
37
44
|
},
|
|
38
45
|
"files": [
|
|
39
|
-
"dist",
|
|
46
|
+
"/dist",
|
|
40
47
|
"README.md",
|
|
41
48
|
"LICENSE"
|
|
42
49
|
],
|