@contrail/util 1.0.64 → 1.1.0

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
@@ -5,3 +5,4 @@ export * from './map-util/map-util';
5
5
  export * from './app-util/app-util';
6
6
  export * from './timer-util/timer-util';
7
7
  export * from './promise-util/promise-util';
8
+ export * from './order-util/order-util';
package/lib/index.js CHANGED
@@ -21,3 +21,4 @@ __exportStar(require("./map-util/map-util"), exports);
21
21
  __exportStar(require("./app-util/app-util"), exports);
22
22
  __exportStar(require("./timer-util/timer-util"), exports);
23
23
  __exportStar(require("./promise-util/promise-util"), exports);
24
+ __exportStar(require("./order-util/order-util"), exports);
@@ -8,7 +8,13 @@ const compareDeep_1 = require("./compareDeep/compareDeep");
8
8
  const applyChangesIfEqual_1 = require("./applyChangesIfEqual/applyChangesIfEqual");
9
9
  class ObjectUtil {
10
10
  static getByPath(obj, path, def = null) {
11
- const pathUnits = path.replace(/\[/g, '.').replace(/]/g, '').split('.');
11
+ if (obj == undefined)
12
+ return def;
13
+ if (path.indexOf('.') === -1) {
14
+ const value = obj[path];
15
+ return value === undefined ? def : value;
16
+ }
17
+ const pathUnits = path.split('.');
12
18
  pathUnits.forEach((level) => {
13
19
  if (obj) {
14
20
  obj = obj[level];
@@ -0,0 +1,3 @@
1
+ export declare class OrderUtil {
2
+ static move(inputElements: any, from: any, to: any): any;
3
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrderUtil = void 0;
4
+ class OrderUtil {
5
+ static move(inputElements, from, to) {
6
+ let numberOfDeletedElement = 1;
7
+ const element = inputElements.splice(from, numberOfDeletedElement)[0];
8
+ numberOfDeletedElement = 0;
9
+ inputElements.splice(to, numberOfDeletedElement, element);
10
+ return inputElements;
11
+ }
12
+ }
13
+ exports.OrderUtil = OrderUtil;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contrail/util",
3
- "version": "1.0.64",
3
+ "version": "1.1.0",
4
4
  "description": "General javascript utilities",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",