@contrail/util 1.0.16 → 1.0.19
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/lib/index.js
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
8
12
|
}));
|
|
9
13
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
-
for (var p in m) if (p !== "default" && !
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
15
|
};
|
|
12
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
17
|
__exportStar(require("./object-util/object-util"), exports);
|
|
@@ -6,9 +6,9 @@ function mergeDeep(target, ...sources) {
|
|
|
6
6
|
if (!sources.length)
|
|
7
7
|
return target;
|
|
8
8
|
const source = sources.shift();
|
|
9
|
-
if (isObject_1.isObject(target) && isObject_1.isObject(source)) {
|
|
9
|
+
if ((0, isObject_1.isObject)(target) && (0, isObject_1.isObject)(source)) {
|
|
10
10
|
for (const key in source) {
|
|
11
|
-
if (isObject_1.isObject(source[key])) {
|
|
11
|
+
if ((0, isObject_1.isObject)(source[key]) && !isDate(source[key])) {
|
|
12
12
|
if (!target[key])
|
|
13
13
|
Object.assign(target, { [key]: {} });
|
|
14
14
|
mergeDeep(target[key], source[key]);
|
|
@@ -21,3 +21,6 @@ function mergeDeep(target, ...sources) {
|
|
|
21
21
|
return mergeDeep(target, ...sources);
|
|
22
22
|
}
|
|
23
23
|
exports.mergeDeep = mergeDeep;
|
|
24
|
+
function isDate(object) {
|
|
25
|
+
return object != null && object instanceof Date;
|
|
26
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export declare class StringUtil {
|
|
2
2
|
static convertToHyphenCase(entityName: string, transformToLowerCase?: boolean): string;
|
|
3
3
|
static parseVariables(variableString: string, data: any, quoteStrings?: boolean): string;
|
|
4
|
+
static convertToCamelCase(str: any): any;
|
|
5
|
+
static convertToTitleCase(str: any): any;
|
|
4
6
|
static isString(value: any): boolean;
|
|
5
7
|
static isArray(value: any): boolean;
|
|
6
8
|
}
|
|
@@ -41,6 +41,16 @@ class StringUtil {
|
|
|
41
41
|
}
|
|
42
42
|
return currentVariableString;
|
|
43
43
|
}
|
|
44
|
+
static convertToCamelCase(str) {
|
|
45
|
+
return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
|
|
46
|
+
return index === 0 ? word.toLowerCase() : word.toUpperCase();
|
|
47
|
+
}).replace(/\s+/g, '');
|
|
48
|
+
}
|
|
49
|
+
static convertToTitleCase(str) {
|
|
50
|
+
const camelCase = this.convertToCamelCase(str);
|
|
51
|
+
const withSpaces = camelCase.replace(/([A-Z])/g, " $1");
|
|
52
|
+
return withSpaces.charAt(0).toUpperCase() + withSpaces.slice(1);
|
|
53
|
+
}
|
|
44
54
|
static isString(value) {
|
|
45
55
|
return typeof value === 'string' || value instanceof String;
|
|
46
56
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contrail/util",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.19",
|
|
4
4
|
"description": "General javascript utilities",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"ts-jest": "^23.10.5",
|
|
22
22
|
"tslint": "^5.11.0",
|
|
23
23
|
"tslint-config-prettier": "^1.18.0",
|
|
24
|
-
"typescript": "^
|
|
24
|
+
"typescript": "^4.0.0"
|
|
25
25
|
},
|
|
26
26
|
"jest": {
|
|
27
27
|
"moduleFileExtensions": [
|