@voiceflow/common 7.23.0 → 7.25.1
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/constants/regexp.d.ts +1 -0
- package/build/common/constants/regexp.js +2 -1
- package/build/common/utils/array.d.ts +1 -0
- package/build/common/utils/array.js +3 -1
- package/build/common/utils/map.d.ts +2 -5
- package/build/common/utils/map.js +6 -4
- package/build/esm/constants/regexp.d.ts +1 -0
- package/build/esm/constants/regexp.js +1 -0
- package/build/esm/utils/array.d.ts +1 -0
- package/build/esm/utils/array.js +1 -0
- package/build/esm/utils/map.d.ts +2 -5
- package/build/esm/utils/map.js +6 -4
- package/package.json +2 -2
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const SPACE_REGEXP: RegExp;
|
|
2
2
|
export declare const SLOT_REGEXP: RegExp;
|
|
3
|
+
export declare const SLOT_ANNOTATION_SIMPLE_REGEX: RegExp;
|
|
3
4
|
export declare const IS_VARIABLE_REGEXP: RegExp;
|
|
4
5
|
export declare const READABLE_VARIABLE_REGEXP: RegExp;
|
|
5
6
|
export declare const VALID_CHARACTER = "a-zA-Z";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.VALID_SAMPLE_UTTERANCE = exports.VALID_SAMPLE_CHARACTERS = exports.VALID_SAMPLE_CHARACTERS_WITHOUT_CURLY_BRACES_OR_SPACES = exports.VALID_SPOKEN_CHARACTER = exports.VALID_LATIN_CHARACTER = exports.VALID_CHARACTER = exports.READABLE_VARIABLE_REGEXP = exports.IS_VARIABLE_REGEXP = exports.SLOT_REGEXP = exports.SPACE_REGEXP = void 0;
|
|
3
|
+
exports.VALID_SAMPLE_UTTERANCE = exports.VALID_SAMPLE_CHARACTERS = exports.VALID_SAMPLE_CHARACTERS_WITHOUT_CURLY_BRACES_OR_SPACES = exports.VALID_SPOKEN_CHARACTER = exports.VALID_LATIN_CHARACTER = exports.VALID_CHARACTER = exports.READABLE_VARIABLE_REGEXP = exports.IS_VARIABLE_REGEXP = exports.SLOT_ANNOTATION_SIMPLE_REGEX = exports.SLOT_REGEXP = exports.SPACE_REGEXP = void 0;
|
|
4
4
|
exports.SPACE_REGEXP = / /g;
|
|
5
5
|
exports.SLOT_REGEXP = /{{\[([^ .[\]{}]*?)]\.([^ .[\]{}]*?)}}/g;
|
|
6
|
+
exports.SLOT_ANNOTATION_SIMPLE_REGEX = /{([^ .[\]{}]+?)}/g;
|
|
6
7
|
exports.IS_VARIABLE_REGEXP = /^{.*}$/;
|
|
7
8
|
exports.READABLE_VARIABLE_REGEXP = /{(\w{1,64})}/g;
|
|
8
9
|
exports.VALID_CHARACTER = 'a-zA-Z';
|
|
@@ -36,4 +36,5 @@ export declare const isNotNullish: <T>(value: T) => value is NonNullable<T>;
|
|
|
36
36
|
export declare const filterOutNullish: <T>(items: readonly T[]) => NonNullable<T>[];
|
|
37
37
|
export declare const filterAndGetLastRemovedValue: <T>(list: T[], filter: (item: T) => boolean) => [T[], T | null];
|
|
38
38
|
export declare const inferUnion: <T extends ArrayLike<unknown>>(array: T) => import("../types").SafeArray<T[number], T>;
|
|
39
|
+
export declare const toArray: <T>(valueOrArray: T | T[]) => T[];
|
|
39
40
|
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.inferUnion = exports.filterAndGetLastRemovedValue = exports.filterOutNullish = exports.isNotNullish = exports.isNullish = exports.asyncForEach = exports.hasIdenticalMembers = exports.diff = exports.findUnion = exports.createMap = exports.createEntries = exports.separate = exports.reorder = exports.tail = exports.head = exports.toggleMembership = exports.append = exports.insertAll = exports.insert = exports.replace = exports.withoutValues = exports.withoutValue = exports.without = exports.unique = void 0;
|
|
3
|
+
exports.toArray = exports.inferUnion = exports.filterAndGetLastRemovedValue = exports.filterOutNullish = exports.isNotNullish = exports.isNullish = exports.asyncForEach = exports.hasIdenticalMembers = exports.diff = exports.findUnion = exports.createMap = exports.createEntries = exports.separate = exports.reorder = exports.tail = exports.head = exports.toggleMembership = exports.append = exports.insertAll = exports.insert = exports.replace = exports.withoutValues = exports.withoutValue = exports.without = exports.unique = void 0;
|
|
4
4
|
const unique = (items) => Array.from(new Set(items));
|
|
5
5
|
exports.unique = unique;
|
|
6
6
|
const without = (items, index) => (index < 0 ? items : [...items.slice(0, index), ...items.slice(index + 1)]);
|
|
@@ -123,3 +123,5 @@ const filterAndGetLastRemovedValue = (list, filter) => {
|
|
|
123
123
|
exports.filterAndGetLastRemovedValue = filterAndGetLastRemovedValue;
|
|
124
124
|
const inferUnion = (array) => array;
|
|
125
125
|
exports.inferUnion = inferUnion;
|
|
126
|
+
const toArray = (valueOrArray) => (Array.isArray(valueOrArray) ? valueOrArray : [valueOrArray]);
|
|
127
|
+
exports.toArray = toArray;
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* If the key does not exist, insert the default value into the map and return that value.
|
|
4
|
-
*/
|
|
5
|
-
export declare const getOrDefault: <K, V>(map: Map<K, V>, key: K, defaultValue: V) => V;
|
|
1
|
+
export declare function getOrDefault<K, V>(map: Map<K, V>, key: K, defaultValue: V): V;
|
|
2
|
+
export declare function getOrDefault<K, V>(map: Map<K, V>, key: K, getDefaultValue: () => V): V;
|
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getOrDefault = void 0;
|
|
4
|
+
const functional_1 = require("./functional");
|
|
4
5
|
/**
|
|
5
6
|
* Retrieve the value at the given key inside the map.
|
|
6
7
|
* If the key does not exist, insert the default value into the map and return that value.
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
|
+
function getOrDefault(map, key, defaultValue) {
|
|
9
10
|
if (!map.has(key)) {
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
const value = (0, functional_1.isFunction)(defaultValue) ? defaultValue() : defaultValue;
|
|
12
|
+
map.set(key, value);
|
|
13
|
+
return value;
|
|
12
14
|
}
|
|
13
15
|
return map.get(key);
|
|
14
|
-
}
|
|
16
|
+
}
|
|
15
17
|
exports.getOrDefault = getOrDefault;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const SPACE_REGEXP: RegExp;
|
|
2
2
|
export declare const SLOT_REGEXP: RegExp;
|
|
3
|
+
export declare const SLOT_ANNOTATION_SIMPLE_REGEX: RegExp;
|
|
3
4
|
export declare const IS_VARIABLE_REGEXP: RegExp;
|
|
4
5
|
export declare const READABLE_VARIABLE_REGEXP: RegExp;
|
|
5
6
|
export declare const VALID_CHARACTER = "a-zA-Z";
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export const SPACE_REGEXP = / /g;
|
|
2
2
|
export const SLOT_REGEXP = /{{\[([^ .[\]{}]*?)]\.([^ .[\]{}]*?)}}/g;
|
|
3
|
+
export const SLOT_ANNOTATION_SIMPLE_REGEX = /{([^ .[\]{}]+?)}/g;
|
|
3
4
|
export const IS_VARIABLE_REGEXP = /^{.*}$/;
|
|
4
5
|
export const READABLE_VARIABLE_REGEXP = /{(\w{1,64})}/g;
|
|
5
6
|
export const VALID_CHARACTER = 'a-zA-Z';
|
|
@@ -36,4 +36,5 @@ export declare const isNotNullish: <T>(value: T) => value is NonNullable<T>;
|
|
|
36
36
|
export declare const filterOutNullish: <T>(items: readonly T[]) => NonNullable<T>[];
|
|
37
37
|
export declare const filterAndGetLastRemovedValue: <T>(list: T[], filter: (item: T) => boolean) => [T[], T | null];
|
|
38
38
|
export declare const inferUnion: <T extends ArrayLike<unknown>>(array: T) => import("../types").SafeArray<T[number], T>;
|
|
39
|
+
export declare const toArray: <T>(valueOrArray: T | T[]) => T[];
|
|
39
40
|
export {};
|
package/build/esm/utils/array.js
CHANGED
package/build/esm/utils/map.d.ts
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* If the key does not exist, insert the default value into the map and return that value.
|
|
4
|
-
*/
|
|
5
|
-
export declare const getOrDefault: <K, V>(map: Map<K, V>, key: K, defaultValue: V) => V;
|
|
1
|
+
export declare function getOrDefault<K, V>(map: Map<K, V>, key: K, defaultValue: V): V;
|
|
2
|
+
export declare function getOrDefault<K, V>(map: Map<K, V>, key: K, getDefaultValue: () => V): V;
|
package/build/esm/utils/map.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
+
import { isFunction } from './functional';
|
|
1
2
|
/**
|
|
2
3
|
* Retrieve the value at the given key inside the map.
|
|
3
4
|
* If the key does not exist, insert the default value into the map and return that value.
|
|
4
5
|
*/
|
|
5
|
-
export
|
|
6
|
+
export function getOrDefault(map, key, defaultValue) {
|
|
6
7
|
if (!map.has(key)) {
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
const value = isFunction(defaultValue) ? defaultValue() : defaultValue;
|
|
9
|
+
map.set(key, value);
|
|
10
|
+
return value;
|
|
9
11
|
}
|
|
10
12
|
return map.get(key);
|
|
11
|
-
}
|
|
13
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voiceflow/common",
|
|
3
3
|
"description": "Junk drawer of utility functions",
|
|
4
|
-
"version": "7.
|
|
4
|
+
"version": "7.25.1",
|
|
5
5
|
"author": "Voiceflow",
|
|
6
6
|
"bugs": {
|
|
7
7
|
"url": "https://github.com/voiceflow/libs/issues"
|
|
@@ -76,5 +76,5 @@
|
|
|
76
76
|
"test:single": "NODE_ENV=test ts-mocha --paths --config config/tests/mocharc.yml",
|
|
77
77
|
"test:unit": "NODE_ENV=test nyc --report-dir=nyc_coverage_unit ts-mocha --paths --config config/tests/mocharc.yml 'tests/**/*.unit.ts'"
|
|
78
78
|
},
|
|
79
|
-
"gitHead": "
|
|
79
|
+
"gitHead": "cb46007be51b23d0852dbe4899c55bdc2afcf9bd"
|
|
80
80
|
}
|