@voiceflow/common 7.26.1 → 7.27.2

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.
@@ -1,4 +1,5 @@
1
1
  import { AnyRecord, Struct } from "../../types";
2
+ export { default as shallowEquals } from 'shallowequal';
2
3
  export declare const selectField: <K extends string | number>(field: K) => <T extends { [key in K]: any; }>(obj: T) => T[K];
3
4
  export declare const selectID: <T extends {
4
5
  id: any;
@@ -23,4 +24,7 @@ export declare const omitBy: PickOmitBy;
23
24
  * @deprecated use pickBy instead
24
25
  */
25
26
  export declare const filterEntries: PickOmitBy;
26
- export {};
27
+ export declare const mapValue: <T, R>(obj: Record<string | number | symbol, T>, callback: (value: T) => R) => {
28
+ [k: string]: R;
29
+ };
30
+ export declare const shallowPartialEquals: <T extends object>(obj: T, partial: Partial<T>) => boolean;
@@ -1,6 +1,11 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.filterEntries = exports.omitBy = exports.pickBy = exports.pick = exports.omit = exports.hasProperty = exports.isObject = exports.selectValue = exports.selectKey = exports.selectID = exports.selectField = void 0;
6
+ exports.shallowPartialEquals = exports.mapValue = exports.filterEntries = exports.omitBy = exports.pickBy = exports.pick = exports.omit = exports.hasProperty = exports.isObject = exports.selectValue = exports.selectKey = exports.selectID = exports.selectField = exports.shallowEquals = void 0;
7
+ var shallowequal_1 = require("shallowequal");
8
+ Object.defineProperty(exports, "shallowEquals", { enumerable: true, get: function () { return __importDefault(shallowequal_1).default; } });
4
9
  const selectField = (field) => (obj) => obj[field];
5
10
  exports.selectField = selectField;
6
11
  exports.selectID = (0, exports.selectField)('id');
@@ -61,3 +66,7 @@ exports.omitBy = omitBy;
61
66
  * @deprecated use pickBy instead
62
67
  */
63
68
  exports.filterEntries = exports.pickBy;
69
+ const mapValue = (obj, callback) => Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, callback(value)]));
70
+ exports.mapValue = mapValue;
71
+ const shallowPartialEquals = (obj, partial) => Object.entries(partial).every(([key, partialValue]) => (0, exports.hasProperty)(obj, key) && partialValue === obj[key]);
72
+ exports.shallowPartialEquals = shallowPartialEquals;
@@ -1,4 +1,5 @@
1
1
  import { AnyRecord, Struct } from "../../types";
2
+ export { default as shallowEquals } from 'shallowequal';
2
3
  export declare const selectField: <K extends string | number>(field: K) => <T extends { [key in K]: any; }>(obj: T) => T[K];
3
4
  export declare const selectID: <T extends {
4
5
  id: any;
@@ -23,4 +24,7 @@ export declare const omitBy: PickOmitBy;
23
24
  * @deprecated use pickBy instead
24
25
  */
25
26
  export declare const filterEntries: PickOmitBy;
26
- export {};
27
+ export declare const mapValue: <T, R>(obj: Record<string | number | symbol, T>, callback: (value: T) => R) => {
28
+ [k: string]: R;
29
+ };
30
+ export declare const shallowPartialEquals: <T extends object>(obj: T, partial: Partial<T>) => boolean;
@@ -1,3 +1,4 @@
1
+ export { default as shallowEquals } from 'shallowequal';
1
2
  export const selectField = (field) => (obj) => obj[field];
2
3
  export const selectID = selectField('id');
3
4
  export const selectKey = selectField('key');
@@ -51,3 +52,5 @@ export const omitBy = (obj, predicate) => Object.entries(obj).reduce((acc, [key,
51
52
  * @deprecated use pickBy instead
52
53
  */
53
54
  export const filterEntries = pickBy;
55
+ export const mapValue = (obj, callback) => Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, callback(value)]));
56
+ export const shallowPartialEquals = (obj, partial) => Object.entries(partial).every(([key, partialValue]) => hasProperty(obj, key) && partialValue === obj[key]);
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@voiceflow/common",
3
3
  "description": "Junk drawer of utility functions",
4
- "version": "7.26.1",
4
+ "version": "7.27.2",
5
5
  "author": "Voiceflow",
6
6
  "bugs": {
7
7
  "url": "https://github.com/voiceflow/libs/issues"
8
8
  },
9
9
  "dependencies": {
10
10
  "@types/crypto-js": "^4.0.2",
11
+ "@types/shallowequal": "^1.1.1",
11
12
  "bson-objectid": "^2.0.1",
12
13
  "crypto-js": "^4.1.1",
13
14
  "cuid": "^2.1.8",
@@ -15,6 +16,7 @@
15
16
  "lodash": "^4.17.21",
16
17
  "murmurhash-wasm": "^1.3.0",
17
18
  "number-to-words": "^1.2.4",
19
+ "shallowequal": "^1.1.0",
18
20
  "typescript-fsa": "3.0.0"
19
21
  },
20
22
  "devDependencies": {
@@ -76,5 +78,5 @@
76
78
  "test:single": "NODE_ENV=test ts-mocha --paths --config config/tests/mocharc.yml",
77
79
  "test:unit": "NODE_ENV=test nyc --report-dir=nyc_coverage_unit ts-mocha --paths --config config/tests/mocharc.yml 'tests/**/*.unit.ts'"
78
80
  },
79
- "gitHead": "d3c1af71d24f5b17dd6d78538b2c92c7fdfc3c43"
81
+ "gitHead": "097deb91076fee24e982436cb7d37f66a4e74d9e"
80
82
  }