@voiceflow/common 7.27.0 → 7.27.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.
- package/build/common/utils/emails.js +2 -2
- package/build/common/utils/object/common.d.ts +2 -1
- package/build/common/utils/object/common.js +8 -1
- package/build/esm/utils/emails.js +2 -2
- package/build/esm/utils/object/common.d.ts +2 -1
- package/build/esm/utils/object/common.js +2 -0
- package/package.json +4 -2
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getEmailDomain = exports.isValidEmail = void 0;
|
|
4
|
-
const FORMAT =
|
|
5
|
-
const isValidEmail = (email) =>
|
|
4
|
+
const FORMAT = /^[\w!#$%&'*+./=?^`{|}~-]+@[\dA-Za-z](?:[\dA-Za-z-]{0,61}[\dA-Za-z])?(?:\.[\dA-Za-z](?:[\dA-Za-z-]{0,61}[\dA-Za-z])?)*$/;
|
|
5
|
+
const isValidEmail = (email) => email.length < 320 && FORMAT.test(email);
|
|
6
6
|
exports.isValidEmail = isValidEmail;
|
|
7
7
|
const getEmailDomain = (email) => email.slice(Math.max(0, email.lastIndexOf('@') + 1));
|
|
8
8
|
exports.getEmailDomain = getEmailDomain;
|
|
@@ -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;
|
|
@@ -26,4 +27,4 @@ export declare const filterEntries: PickOmitBy;
|
|
|
26
27
|
export declare const mapValue: <T, R>(obj: Record<string | number | symbol, T>, callback: (value: T) => R) => {
|
|
27
28
|
[k: string]: R;
|
|
28
29
|
};
|
|
29
|
-
export
|
|
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.mapValue = 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');
|
|
@@ -63,3 +68,5 @@ exports.omitBy = omitBy;
|
|
|
63
68
|
exports.filterEntries = exports.pickBy;
|
|
64
69
|
const mapValue = (obj, callback) => Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, callback(value)]));
|
|
65
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,3 +1,3 @@
|
|
|
1
|
-
const FORMAT =
|
|
2
|
-
export const isValidEmail = (email) =>
|
|
1
|
+
const FORMAT = /^[\w!#$%&'*+./=?^`{|}~-]+@[\dA-Za-z](?:[\dA-Za-z-]{0,61}[\dA-Za-z])?(?:\.[\dA-Za-z](?:[\dA-Za-z-]{0,61}[\dA-Za-z])?)*$/;
|
|
2
|
+
export const isValidEmail = (email) => email.length < 320 && FORMAT.test(email);
|
|
3
3
|
export const getEmailDomain = (email) => email.slice(Math.max(0, email.lastIndexOf('@') + 1));
|
|
@@ -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;
|
|
@@ -26,4 +27,4 @@ export declare const filterEntries: PickOmitBy;
|
|
|
26
27
|
export declare const mapValue: <T, R>(obj: Record<string | number | symbol, T>, callback: (value: T) => R) => {
|
|
27
28
|
[k: string]: R;
|
|
28
29
|
};
|
|
29
|
-
export
|
|
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');
|
|
@@ -52,3 +53,4 @@ export const omitBy = (obj, predicate) => Object.entries(obj).reduce((acc, [key,
|
|
|
52
53
|
*/
|
|
53
54
|
export const filterEntries = pickBy;
|
|
54
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.27.
|
|
4
|
+
"version": "7.27.3",
|
|
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": "
|
|
81
|
+
"gitHead": "aaef6e55ca6d58d392b421df752be011840163c0"
|
|
80
82
|
}
|