@contrail/util 1.0.25 → 1.0.27

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.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './object-util/object-util';
2
2
  export * from './string-util/string-util';
3
3
  export * from './date-util/date-util';
4
+ export * from './map-util/map-util';
package/lib/index.js CHANGED
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./object-util/object-util"), exports);
18
18
  __exportStar(require("./string-util/string-util"), exports);
19
19
  __exportStar(require("./date-util/date-util"), exports);
20
+ __exportStar(require("./map-util/map-util"), exports);
@@ -0,0 +1,3 @@
1
+ export declare class MapUtil {
2
+ static keyBy(array: any[], variableString: any): {};
3
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MapUtil = void 0;
4
+ const string_util_1 = require("../string-util/string-util");
5
+ class MapUtil {
6
+ static keyBy(array, variableString) {
7
+ if (variableString.charAt(0) !== '{') {
8
+ variableString = `{${variableString}}`;
9
+ }
10
+ const map = {};
11
+ for (const obj of array) {
12
+ const value = string_util_1.StringUtil.parseVariables(variableString, obj);
13
+ map[value] = obj;
14
+ }
15
+ return map;
16
+ }
17
+ }
18
+ exports.MapUtil = MapUtil;
@@ -42,6 +42,7 @@ class StringUtil {
42
42
  return currentVariableString;
43
43
  }
44
44
  static convertToCamelCase(str) {
45
+ str = str.replace(/-/g, ' ');
45
46
  return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
46
47
  return index === 0 ? word.toLowerCase() : word.toUpperCase();
47
48
  }).replace(/\s+/g, '');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/util",
3
- "version": "1.0.25",
3
+ "version": "1.0.27",
4
4
  "description": "General javascript utilities",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -16,9 +16,9 @@
16
16
  "license": "ISC",
17
17
  "devDependencies": {
18
18
  "@types/jest": "^23.3.14",
19
- "jest": "^23.6.0",
19
+ "jest": "^29.3.1",
20
20
  "prettier": "^1.19.1",
21
- "ts-jest": "^23.10.5",
21
+ "ts-jest": "^29.0.3",
22
22
  "tslint": "^5.11.0",
23
23
  "tslint-config-prettier": "^1.18.0",
24
24
  "typescript": "^4.0.0"
@@ -36,6 +36,5 @@
36
36
  },
37
37
  "coverageDirectory": "../coverage",
38
38
  "testEnvironment": "node"
39
- },
40
- "dependencies": {}
39
+ }
41
40
  }