@turndown/library 0.0.8 → 0.0.10
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/helpers/index.js +2 -18
- package/dist/helpers/object/index.js +24 -47
- package/dist/helpers/string/index.js +10 -23
- package/dist/index.js +3 -21
- package/dist/types/base/index.js +2 -19
- package/dist/types/base/paging.types.js +1 -2
- package/dist/types/index.js +2 -18
- package/dist/types/user/index.js +2 -5
- package/package.json +3 -2
package/dist/helpers/index.js
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./object"), exports);
|
|
18
|
-
__exportStar(require("./string"), exports);
|
|
1
|
+
export * from "./object";
|
|
2
|
+
export * from "./string";
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.hasProperties = exports.hasProperty = exports.omitProperties = exports.chunkArray = exports.deletePropertyIfExists = exports.parseNumber = exports.formatNumber = exports.formatPhoneNumber = exports.resetPagination = exports.cleanFormData = exports.convertStringBooleans = exports.removeFormProperties = exports.replaceNulls = exports.sortArrayByProperty = exports.filterArrayById = exports.returnObject = exports.validPath = exports.removeUndefined = exports.JSONStringify = exports.parseJSON = void 0;
|
|
4
|
-
const parseJSON = (jsonString) => {
|
|
1
|
+
export const parseJSON = (jsonString) => {
|
|
5
2
|
try {
|
|
6
3
|
return JSON.parse(jsonString);
|
|
7
4
|
}
|
|
@@ -9,8 +6,7 @@ const parseJSON = (jsonString) => {
|
|
|
9
6
|
return {};
|
|
10
7
|
}
|
|
11
8
|
};
|
|
12
|
-
|
|
13
|
-
const JSONStringify = (obj) => {
|
|
9
|
+
export const JSONStringify = (obj) => {
|
|
14
10
|
let cache = [];
|
|
15
11
|
let str = JSON.stringify(obj, function (_key, value) {
|
|
16
12
|
if (typeof value === "object" && value !== null) {
|
|
@@ -24,20 +20,16 @@ const JSONStringify = (obj) => {
|
|
|
24
20
|
cache = null;
|
|
25
21
|
return str;
|
|
26
22
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return JSON.parse((0, exports.JSONStringify)(obj));
|
|
23
|
+
export const removeUndefined = (obj) => {
|
|
24
|
+
return JSON.parse(JSONStringify(obj));
|
|
30
25
|
};
|
|
31
|
-
|
|
32
|
-
const validPath = (location, key) => {
|
|
26
|
+
export const validPath = (location, key) => {
|
|
33
27
|
return location?.pathname === key;
|
|
34
28
|
};
|
|
35
|
-
|
|
36
|
-
const returnObject = (input) => {
|
|
29
|
+
export const returnObject = (input) => {
|
|
37
30
|
return Array.isArray(input) ? input[0] : input;
|
|
38
31
|
};
|
|
39
|
-
|
|
40
|
-
const filterArrayById = (array1, array2) => {
|
|
32
|
+
export const filterArrayById = (array1, array2) => {
|
|
41
33
|
try {
|
|
42
34
|
if (!array1 || !array2)
|
|
43
35
|
return [];
|
|
@@ -49,8 +41,7 @@ const filterArrayById = (array1, array2) => {
|
|
|
49
41
|
return [];
|
|
50
42
|
}
|
|
51
43
|
};
|
|
52
|
-
|
|
53
|
-
const sortArrayByProperty = (array, property) => {
|
|
44
|
+
export const sortArrayByProperty = (array, property) => {
|
|
54
45
|
if (!array || array.length === 0)
|
|
55
46
|
return [];
|
|
56
47
|
return array.sort((a, b) => {
|
|
@@ -61,27 +52,25 @@ const sortArrayByProperty = (array, property) => {
|
|
|
61
52
|
return 0;
|
|
62
53
|
});
|
|
63
54
|
};
|
|
64
|
-
|
|
65
|
-
const replaceNulls = (obj) => {
|
|
55
|
+
export const replaceNulls = (obj) => {
|
|
66
56
|
if (obj === null) {
|
|
67
57
|
return "";
|
|
68
58
|
}
|
|
69
59
|
else if (Array.isArray(obj)) {
|
|
70
|
-
return obj.map(
|
|
60
|
+
return obj.map(replaceNulls);
|
|
71
61
|
}
|
|
72
62
|
else if (typeof obj === "object" && obj !== null) {
|
|
73
63
|
const newObj = {};
|
|
74
64
|
for (const key in obj) {
|
|
75
65
|
if (obj.hasOwnProperty(key)) {
|
|
76
|
-
newObj[key] =
|
|
66
|
+
newObj[key] = replaceNulls(obj[key]);
|
|
77
67
|
}
|
|
78
68
|
}
|
|
79
69
|
return newObj;
|
|
80
70
|
}
|
|
81
71
|
return obj;
|
|
82
72
|
};
|
|
83
|
-
|
|
84
|
-
const removeFormProperties = (obj) => {
|
|
73
|
+
export const removeFormProperties = (obj) => {
|
|
85
74
|
const recursiveRemove = (input) => {
|
|
86
75
|
if (Array.isArray(input)) {
|
|
87
76
|
return input.map((item) => recursiveRemove(item));
|
|
@@ -102,8 +91,7 @@ const removeFormProperties = (obj) => {
|
|
|
102
91
|
};
|
|
103
92
|
return recursiveRemove(obj);
|
|
104
93
|
};
|
|
105
|
-
|
|
106
|
-
const convertStringBooleans = (obj) => {
|
|
94
|
+
export const convertStringBooleans = (obj) => {
|
|
107
95
|
const recursiveConvert = (input) => {
|
|
108
96
|
if (Array.isArray(input)) {
|
|
109
97
|
return input.map((item) => recursiveConvert(item));
|
|
@@ -128,12 +116,10 @@ const convertStringBooleans = (obj) => {
|
|
|
128
116
|
};
|
|
129
117
|
return recursiveConvert(obj);
|
|
130
118
|
};
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
return (0, exports.removeFormProperties)((0, exports.convertStringBooleans)((0, exports.removeUndefined)(obj)));
|
|
119
|
+
export const cleanFormData = (obj) => {
|
|
120
|
+
return removeFormProperties(convertStringBooleans(removeUndefined(obj)));
|
|
134
121
|
};
|
|
135
|
-
|
|
136
|
-
const resetPagination = (sort, filters) => {
|
|
122
|
+
export const resetPagination = (sort, filters) => {
|
|
137
123
|
return {
|
|
138
124
|
page: 1,
|
|
139
125
|
size: 25,
|
|
@@ -141,8 +127,7 @@ const resetPagination = (sort, filters) => {
|
|
|
141
127
|
filters: filters || [],
|
|
142
128
|
};
|
|
143
129
|
};
|
|
144
|
-
|
|
145
|
-
const formatPhoneNumber = (value) => {
|
|
130
|
+
export const formatPhoneNumber = (value) => {
|
|
146
131
|
const digits = value.toString().replace(/\D/g, "");
|
|
147
132
|
if (digits.length !== 10)
|
|
148
133
|
return value.toString();
|
|
@@ -151,44 +136,36 @@ const formatPhoneNumber = (value) => {
|
|
|
151
136
|
const line = digits.slice(6);
|
|
152
137
|
return `(${area}) ${prefix}-${line}`;
|
|
153
138
|
};
|
|
154
|
-
|
|
155
|
-
const formatNumber = (value) => {
|
|
139
|
+
export const formatNumber = (value) => {
|
|
156
140
|
return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
157
141
|
};
|
|
158
|
-
|
|
159
|
-
const parseNumber = (value) => {
|
|
142
|
+
export const parseNumber = (value) => {
|
|
160
143
|
return value.toString().replace(/\B(?=(\d{3})+(?!\d))/g, "");
|
|
161
144
|
};
|
|
162
|
-
|
|
163
|
-
const deletePropertyIfExists = (obj, propertyName) => {
|
|
145
|
+
export const deletePropertyIfExists = (obj, propertyName) => {
|
|
164
146
|
if (Object.prototype.hasOwnProperty.call(obj, propertyName)) {
|
|
165
147
|
delete obj[propertyName];
|
|
166
148
|
}
|
|
167
149
|
};
|
|
168
|
-
|
|
169
|
-
const chunkArray = (array, chunkSize) => {
|
|
150
|
+
export const chunkArray = (array, chunkSize) => {
|
|
170
151
|
const result = [];
|
|
171
152
|
for (let i = 0; i < array.length; i += chunkSize) {
|
|
172
153
|
result.push(array.slice(i, i + chunkSize));
|
|
173
154
|
}
|
|
174
155
|
return result;
|
|
175
156
|
};
|
|
176
|
-
|
|
177
|
-
const omitProperties = (obj, propsToOmit) => {
|
|
157
|
+
export const omitProperties = (obj, propsToOmit) => {
|
|
178
158
|
const newObj = { ...obj };
|
|
179
159
|
propsToOmit.forEach((prop) => {
|
|
180
160
|
delete newObj[prop];
|
|
181
161
|
});
|
|
182
162
|
return newObj;
|
|
183
163
|
};
|
|
184
|
-
|
|
185
|
-
const hasProperty = (obj, key) => {
|
|
164
|
+
export const hasProperty = (obj, key) => {
|
|
186
165
|
if (!obj)
|
|
187
166
|
return false;
|
|
188
167
|
return Object.prototype.hasOwnProperty.call(obj, key);
|
|
189
168
|
};
|
|
190
|
-
|
|
191
|
-
const hasProperties = (obj) => {
|
|
169
|
+
export const hasProperties = (obj) => {
|
|
192
170
|
return Object.keys(obj || {}).length > 0;
|
|
193
171
|
};
|
|
194
|
-
exports.hasProperties = hasProperties;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.kebabToSpaces = exports.snakeCaseToSpaces = exports.snakeCase = exports.kebabCase = exports.pascalCase = exports.camelCase = exports.lowerCase = exports.upperCase = exports.sentenceCase = exports.normalCase = void 0;
|
|
4
|
-
const normalCase = (str) => {
|
|
1
|
+
export const normalCase = (str) => {
|
|
5
2
|
if (!str)
|
|
6
3
|
return "";
|
|
7
4
|
return str
|
|
@@ -11,23 +8,19 @@ const normalCase = (str) => {
|
|
|
11
8
|
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
12
9
|
.join(" ");
|
|
13
10
|
};
|
|
14
|
-
|
|
15
|
-
const sentenceCase = (str) => {
|
|
11
|
+
export const sentenceCase = (str) => {
|
|
16
12
|
if (!str)
|
|
17
13
|
return "";
|
|
18
14
|
const s = str.trim();
|
|
19
15
|
return s.charAt(0).toUpperCase() + s.slice(1).toLowerCase();
|
|
20
16
|
};
|
|
21
|
-
|
|
22
|
-
const upperCase = (str) => {
|
|
17
|
+
export const upperCase = (str) => {
|
|
23
18
|
return str ? str.toUpperCase() : "";
|
|
24
19
|
};
|
|
25
|
-
|
|
26
|
-
const lowerCase = (str) => {
|
|
20
|
+
export const lowerCase = (str) => {
|
|
27
21
|
return str ? str.toLowerCase() : "";
|
|
28
22
|
};
|
|
29
|
-
|
|
30
|
-
const camelCase = (str) => {
|
|
23
|
+
export const camelCase = (str) => {
|
|
31
24
|
if (!str)
|
|
32
25
|
return "";
|
|
33
26
|
return str
|
|
@@ -38,8 +31,7 @@ const camelCase = (str) => {
|
|
|
38
31
|
: word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
39
32
|
.join("");
|
|
40
33
|
};
|
|
41
|
-
|
|
42
|
-
const pascalCase = (str) => {
|
|
34
|
+
export const pascalCase = (str) => {
|
|
43
35
|
if (!str)
|
|
44
36
|
return "";
|
|
45
37
|
return str
|
|
@@ -48,8 +40,7 @@ const pascalCase = (str) => {
|
|
|
48
40
|
.map((word) => word.charAt(0).toUpperCase() + word.slice(1))
|
|
49
41
|
.join("");
|
|
50
42
|
};
|
|
51
|
-
|
|
52
|
-
const kebabCase = (str) => {
|
|
43
|
+
export const kebabCase = (str) => {
|
|
53
44
|
if (!str)
|
|
54
45
|
return "";
|
|
55
46
|
return str
|
|
@@ -57,8 +48,7 @@ const kebabCase = (str) => {
|
|
|
57
48
|
.replace(/[\s_]+/g, "-")
|
|
58
49
|
.toLowerCase();
|
|
59
50
|
};
|
|
60
|
-
|
|
61
|
-
const snakeCase = (str) => {
|
|
51
|
+
export const snakeCase = (str) => {
|
|
62
52
|
if (!str)
|
|
63
53
|
return "";
|
|
64
54
|
return str
|
|
@@ -66,16 +56,13 @@ const snakeCase = (str) => {
|
|
|
66
56
|
.replace(/[\s-]+/g, "_")
|
|
67
57
|
.toLowerCase();
|
|
68
58
|
};
|
|
69
|
-
|
|
70
|
-
const snakeCaseToSpaces = (str) => {
|
|
59
|
+
export const snakeCaseToSpaces = (str) => {
|
|
71
60
|
if (!str)
|
|
72
61
|
return "";
|
|
73
62
|
return str.split("_").join(" ");
|
|
74
63
|
};
|
|
75
|
-
|
|
76
|
-
const kebabToSpaces = (str) => {
|
|
64
|
+
export const kebabToSpaces = (str) => {
|
|
77
65
|
if (!str)
|
|
78
66
|
return "";
|
|
79
67
|
return str.split("-").join(" ");
|
|
80
68
|
};
|
|
81
|
-
exports.kebabToSpaces = kebabToSpaces;
|
package/dist/index.js
CHANGED
|
@@ -1,23 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.test = void 0;
|
|
18
|
-
__exportStar(require("./helpers"), exports);
|
|
19
|
-
__exportStar(require("./types"), exports);
|
|
20
|
-
const test = () => {
|
|
1
|
+
export * from "./helpers";
|
|
2
|
+
export * from "./types";
|
|
3
|
+
export const test = () => {
|
|
21
4
|
console.log("working");
|
|
22
5
|
};
|
|
23
|
-
exports.test = test;
|
package/dist/types/base/index.js
CHANGED
|
@@ -1,22 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.STATUS = void 0;
|
|
18
|
-
exports.STATUS = {
|
|
1
|
+
export const STATUS = {
|
|
19
2
|
ACTIVE: "ACTIVE",
|
|
20
3
|
INACTIVE: "INACTIVE",
|
|
21
4
|
};
|
|
22
|
-
|
|
5
|
+
export * from "./paging.types";
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/types/index.js
CHANGED
|
@@ -1,18 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./user"), exports);
|
|
18
|
-
__exportStar(require("./base"), exports);
|
|
1
|
+
export * from "./user";
|
|
2
|
+
export * from "./base";
|
package/dist/types/user/index.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LANGUAGE = exports.ACCOUNT_TYPE = void 0;
|
|
4
|
-
exports.ACCOUNT_TYPE = {
|
|
1
|
+
export const ACCOUNT_TYPE = {
|
|
5
2
|
TURNDOWN_ADMIN: "TURNDOWN_ADMIN",
|
|
6
3
|
OWNER: "OWNER",
|
|
7
4
|
ACCOUNT_ADMIN: "ACCOUNT_ADMIN",
|
|
8
5
|
MAINTAINER: "MAINTAINER",
|
|
9
6
|
CLEANER: "CLEANER",
|
|
10
7
|
};
|
|
11
|
-
|
|
8
|
+
export const LANGUAGE = {
|
|
12
9
|
ENGLISH: "ENGLISH",
|
|
13
10
|
FRENCH: "FRENCH",
|
|
14
11
|
SPANISH: "SPANISH",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@turndown/library",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "Shared TypeScript library for the Turndown suite.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"types",
|
|
@@ -19,7 +19,8 @@
|
|
|
19
19
|
"exports": {
|
|
20
20
|
".": {
|
|
21
21
|
"types": "./dist/index.d.ts",
|
|
22
|
-
"
|
|
22
|
+
"import": "./dist/index.js",
|
|
23
|
+
"default": "./dist/index.js"
|
|
23
24
|
},
|
|
24
25
|
"./package.json": "./package.json"
|
|
25
26
|
},
|