core-mb 1.1.2 → 1.1.3

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.
File without changes
@@ -0,0 +1 @@
1
+ "use strict";
File without changes
@@ -0,0 +1 @@
1
+ "use strict";
package/dist/index.d.ts CHANGED
@@ -5,3 +5,4 @@ export * from "./validation.helper";
5
5
  export * from "class-validator";
6
6
  export * from "./transformer.helper";
7
7
  export * from './logging.helper';
8
+ export * from './object.helper';
package/dist/index.js CHANGED
@@ -21,3 +21,4 @@ __exportStar(require("./validation.helper"), exports);
21
21
  __exportStar(require("class-validator"), exports);
22
22
  __exportStar(require("./transformer.helper"), exports);
23
23
  __exportStar(require("./logging.helper"), exports);
24
+ __exportStar(require("./object.helper"), exports);
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Omit specified keys from an object
3
+ */
4
+ export declare function omit<T, K extends keyof T>(obj: T, keys: K[]): Omit<T, K>;
5
+ /**
6
+ * Pick only specified keys from an object
7
+ */
8
+ export declare function pick<T, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.omit = omit;
4
+ exports.pick = pick;
5
+ /**
6
+ * Omit specified keys from an object
7
+ */
8
+ function omit(obj, keys) {
9
+ const result = { ...obj };
10
+ keys.forEach(k => delete result[k]);
11
+ return result;
12
+ }
13
+ /**
14
+ * Pick only specified keys from an object
15
+ */
16
+ function pick(obj, keys) {
17
+ const result = {};
18
+ keys.forEach(k => {
19
+ if (obj[k] !== undefined)
20
+ result[k] = obj[k];
21
+ });
22
+ return result;
23
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "core-mb",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Core utility functions for the MB ecosystem in TypeScript",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/enum.hr.ts ADDED
File without changes
File without changes
package/src/index.ts CHANGED
@@ -4,4 +4,5 @@ export * from "./security.helper"
4
4
  export * from "./validation.helper"
5
5
  export * from "class-validator"
6
6
  export * from "./transformer.helper";
7
- export * from './logging.helper';
7
+ export * from './logging.helper';
8
+ export * from './object.helper';
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Omit specified keys from an object
3
+ */
4
+ export function omit<T, K extends keyof T>(obj: T, keys: K[]): Omit<T, K> {
5
+ const result = { ...obj }
6
+ keys.forEach(k => delete result[k])
7
+ return result
8
+ }
9
+
10
+ /**
11
+ * Pick only specified keys from an object
12
+ */
13
+ export function pick<T, K extends keyof T>(obj: T, keys: K[]): Pick<T, K> {
14
+ const result = {} as Pick<T, K>
15
+ keys.forEach(k => {
16
+ if (obj[k] !== undefined) result[k] = obj[k]
17
+ })
18
+ return result
19
+ }