@voiceflow/common 8.2.8 → 8.3.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/build/cjs/constants/environment.js +1 -1
- package/build/cjs/constants/regexp.d.ts +5 -5
- package/build/cjs/constants/regexp.d.ts.map +1 -1
- package/build/cjs/crypto/hex2abc.d.ts.map +1 -1
- package/build/cjs/types.d.ts +26 -26
- package/build/cjs/types.d.ts.map +1 -1
- package/build/cjs/utils/array.d.ts +3 -3
- package/build/cjs/utils/array.d.ts.map +1 -1
- package/build/cjs/utils/array.js +2 -3
- package/build/cjs/utils/emails.d.ts.map +1 -1
- package/build/cjs/utils/functional.d.ts +4 -4
- package/build/cjs/utils/functional.d.ts.map +1 -1
- package/build/cjs/utils/functional.js +0 -1
- package/build/cjs/utils/id.d.ts +1 -1
- package/build/cjs/utils/id.d.ts.map +1 -1
- package/build/cjs/utils/intent.d.ts +6 -6
- package/build/cjs/utils/intent.d.ts.map +1 -1
- package/build/cjs/utils/intent.js +4 -2
- package/build/cjs/utils/mathjs.js +1 -1
- package/build/cjs/utils/normalized.d.ts +5 -5
- package/build/cjs/utils/normalized.d.ts.map +1 -1
- package/build/cjs/utils/number.d.ts.map +1 -1
- package/build/cjs/utils/object/common.d.ts +1 -1
- package/build/cjs/utils/object/common.d.ts.map +1 -1
- package/build/cjs/utils/object/deepMap.d.ts +1 -1
- package/build/cjs/utils/object/deepMap.d.ts.map +1 -1
- package/build/cjs/utils/object/deepMap.js +0 -2
- package/build/cjs/utils/object/diff.d.ts +1 -1
- package/build/cjs/utils/object/diff.d.ts.map +1 -1
- package/build/cjs/utils/object/keys.d.ts +2 -1
- package/build/cjs/utils/object/keys.d.ts.map +1 -1
- package/build/cjs/utils/promise.d.ts.map +1 -1
- package/build/cjs/utils/protocol.d.ts +2 -2
- package/build/cjs/utils/protocol.d.ts.map +1 -1
- package/build/cjs/utils/slot.d.ts.map +1 -1
- package/build/cjs/utils/typeguard.d.ts +2 -2
- package/build/cjs/utils/typeguard.d.ts.map +1 -1
- package/build/cjs/utils/variables.d.ts +2 -2
- package/build/cjs/utils/variables.d.ts.map +1 -1
- package/build/esm/constants/regexp.d.ts +5 -5
- package/build/esm/constants/regexp.d.ts.map +1 -1
- package/build/esm/crypto/hex2abc.d.ts.map +1 -1
- package/build/esm/types.d.ts +26 -26
- package/build/esm/types.d.ts.map +1 -1
- package/build/esm/utils/array.d.ts +3 -3
- package/build/esm/utils/array.d.ts.map +1 -1
- package/build/esm/utils/array.js +2 -3
- package/build/esm/utils/emails.d.ts.map +1 -1
- package/build/esm/utils/functional.d.ts +4 -4
- package/build/esm/utils/functional.d.ts.map +1 -1
- package/build/esm/utils/functional.js +0 -1
- package/build/esm/utils/id.d.ts +1 -1
- package/build/esm/utils/id.d.ts.map +1 -1
- package/build/esm/utils/intent.d.ts +6 -6
- package/build/esm/utils/intent.d.ts.map +1 -1
- package/build/esm/utils/intent.js +4 -2
- package/build/esm/utils/mathjs.js +1 -1
- package/build/esm/utils/normalized.d.ts +5 -5
- package/build/esm/utils/normalized.d.ts.map +1 -1
- package/build/esm/utils/number.d.ts.map +1 -1
- package/build/esm/utils/object/common.d.ts +1 -1
- package/build/esm/utils/object/common.d.ts.map +1 -1
- package/build/esm/utils/object/deepMap.d.ts +1 -1
- package/build/esm/utils/object/deepMap.d.ts.map +1 -1
- package/build/esm/utils/object/deepMap.js +0 -2
- package/build/esm/utils/object/diff.d.ts +1 -1
- package/build/esm/utils/object/diff.d.ts.map +1 -1
- package/build/esm/utils/object/keys.d.ts +2 -1
- package/build/esm/utils/object/keys.d.ts.map +1 -1
- package/build/esm/utils/promise.d.ts.map +1 -1
- package/build/esm/utils/protocol.d.ts +2 -2
- package/build/esm/utils/protocol.d.ts.map +1 -1
- package/build/esm/utils/slot.d.ts.map +1 -1
- package/build/esm/utils/typeguard.d.ts +2 -2
- package/build/esm/utils/typeguard.d.ts.map +1 -1
- package/build/esm/utils/variables.d.ts +2 -2
- package/build/esm/utils/variables.d.ts.map +1 -1
- package/package.json +46 -48
- package/build/cjs/crypto/hex2abc.test.d.ts +0 -2
- package/build/cjs/crypto/hex2abc.test.d.ts.map +0 -1
- package/build/cjs/crypto/hex2abc.test.js +0 -12
- package/build/cjs/crypto/murmurhash.test.d.ts +0 -2
- package/build/cjs/crypto/murmurhash.test.d.ts.map +0 -1
- package/build/cjs/crypto/murmurhash.test.js +0 -23
- package/build/cjs/utils/__fixtures__/name.json +0 -64
- package/build/cjs/utils/array.test.d.ts +0 -2
- package/build/cjs/utils/array.test.d.ts.map +0 -1
- package/build/cjs/utils/array.test.js +0 -237
- package/build/cjs/utils/email.test.d.ts +0 -2
- package/build/cjs/utils/email.test.d.ts.map +0 -1
- package/build/cjs/utils/email.test.js +0 -22
- package/build/cjs/utils/functional.test.d.ts +0 -2
- package/build/cjs/utils/functional.test.d.ts.map +0 -1
- package/build/cjs/utils/functional.test.js +0 -139
- package/build/cjs/utils/id.test.d.ts +0 -2
- package/build/cjs/utils/id.test.d.ts.map +0 -1
- package/build/cjs/utils/id.test.js +0 -66
- package/build/cjs/utils/intent.test.d.ts +0 -2
- package/build/cjs/utils/intent.test.d.ts.map +0 -1
- package/build/cjs/utils/intent.test.js +0 -100
- package/build/cjs/utils/map.test.d.ts +0 -2
- package/build/cjs/utils/map.test.d.ts.map +0 -1
- package/build/cjs/utils/map.test.js +0 -22
- package/build/cjs/utils/object/common.test.d.ts +0 -2
- package/build/cjs/utils/object/common.test.d.ts.map +0 -1
- package/build/cjs/utils/object/common.test.js +0 -175
- package/build/cjs/utils/object/deepMap.test.d.ts +0 -2
- package/build/cjs/utils/object/deepMap.test.d.ts.map +0 -1
- package/build/cjs/utils/object/deepMap.test.js +0 -114
- package/build/cjs/utils/object/diff.test.d.ts +0 -2
- package/build/cjs/utils/object/diff.test.d.ts.map +0 -1
- package/build/cjs/utils/object/diff.test.js +0 -19
- package/build/cjs/utils/object/keys.test.d.ts +0 -2
- package/build/cjs/utils/object/keys.test.d.ts.map +0 -1
- package/build/cjs/utils/object/keys.test.js +0 -15
- package/build/cjs/utils/promise.test.d.ts +0 -2
- package/build/cjs/utils/promise.test.d.ts.map +0 -1
- package/build/cjs/utils/promise.test.js +0 -25
- package/build/cjs/utils/protocol.test.d.ts +0 -2
- package/build/cjs/utils/protocol.test.d.ts.map +0 -1
- package/build/cjs/utils/protocol.test.js +0 -40
- package/build/cjs/utils/slot.test.d.ts +0 -2
- package/build/cjs/utils/slot.test.d.ts.map +0 -1
- package/build/cjs/utils/slot.test.js +0 -38
- package/build/cjs/utils/string.test.d.ts +0 -2
- package/build/cjs/utils/string.test.d.ts.map +0 -1
- package/build/cjs/utils/string.test.js +0 -53
- package/build/cjs/utils/timezones.test.d.ts +0 -2
- package/build/cjs/utils/timezones.test.d.ts.map +0 -1
- package/build/cjs/utils/timezones.test.js +0 -12
- package/build/cjs/utils/typeguard.test.d.ts +0 -2
- package/build/cjs/utils/typeguard.test.d.ts.map +0 -1
- package/build/cjs/utils/typeguard.test.js +0 -55
- package/build/esm/crypto/hex2abc.test.d.ts +0 -2
- package/build/esm/crypto/hex2abc.test.d.ts.map +0 -1
- package/build/esm/crypto/hex2abc.test.js +0 -10
- package/build/esm/crypto/murmurhash.test.d.ts +0 -2
- package/build/esm/crypto/murmurhash.test.d.ts.map +0 -1
- package/build/esm/crypto/murmurhash.test.js +0 -21
- package/build/esm/utils/__fixtures__/name.json +0 -64
- package/build/esm/utils/array.test.d.ts +0 -2
- package/build/esm/utils/array.test.d.ts.map +0 -1
- package/build/esm/utils/array.test.js +0 -235
- package/build/esm/utils/email.test.d.ts +0 -2
- package/build/esm/utils/email.test.d.ts.map +0 -1
- package/build/esm/utils/email.test.js +0 -20
- package/build/esm/utils/functional.test.d.ts +0 -2
- package/build/esm/utils/functional.test.d.ts.map +0 -1
- package/build/esm/utils/functional.test.js +0 -137
- package/build/esm/utils/id.test.d.ts +0 -2
- package/build/esm/utils/id.test.d.ts.map +0 -1
- package/build/esm/utils/id.test.js +0 -64
- package/build/esm/utils/intent.test.d.ts +0 -2
- package/build/esm/utils/intent.test.d.ts.map +0 -1
- package/build/esm/utils/intent.test.js +0 -75
- package/build/esm/utils/map.test.d.ts +0 -2
- package/build/esm/utils/map.test.d.ts.map +0 -1
- package/build/esm/utils/map.test.js +0 -20
- package/build/esm/utils/object/common.test.d.ts +0 -2
- package/build/esm/utils/object/common.test.d.ts.map +0 -1
- package/build/esm/utils/object/common.test.js +0 -173
- package/build/esm/utils/object/deepMap.test.d.ts +0 -2
- package/build/esm/utils/object/deepMap.test.d.ts.map +0 -1
- package/build/esm/utils/object/deepMap.test.js +0 -109
- package/build/esm/utils/object/diff.test.d.ts +0 -2
- package/build/esm/utils/object/diff.test.d.ts.map +0 -1
- package/build/esm/utils/object/diff.test.js +0 -17
- package/build/esm/utils/object/keys.test.d.ts +0 -2
- package/build/esm/utils/object/keys.test.d.ts.map +0 -1
- package/build/esm/utils/object/keys.test.js +0 -13
- package/build/esm/utils/promise.test.d.ts +0 -2
- package/build/esm/utils/promise.test.d.ts.map +0 -1
- package/build/esm/utils/promise.test.js +0 -23
- package/build/esm/utils/protocol.test.d.ts +0 -2
- package/build/esm/utils/protocol.test.d.ts.map +0 -1
- package/build/esm/utils/protocol.test.js +0 -38
- package/build/esm/utils/slot.test.d.ts +0 -2
- package/build/esm/utils/slot.test.d.ts.map +0 -1
- package/build/esm/utils/slot.test.js +0 -13
- package/build/esm/utils/string.test.d.ts +0 -2
- package/build/esm/utils/string.test.d.ts.map +0 -1
- package/build/esm/utils/string.test.js +0 -51
- package/build/esm/utils/timezones.test.d.ts +0 -2
- package/build/esm/utils/timezones.test.d.ts.map +0 -1
- package/build/esm/utils/timezones.test.js +0 -10
- package/build/esm/utils/typeguard.test.d.ts +0 -2
- package/build/esm/utils/typeguard.test.d.ts.map +0 -1
- package/build/esm/utils/typeguard.test.js +0 -53
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"slot.test.d.ts","sourceRoot":"","sources":["../../../src/utils/slot.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
const SlotUtils = __importStar(require("./slot"));
|
|
27
|
-
describe('Utils | slot', () => {
|
|
28
|
-
describe('getValueWithSynonyms', () => {
|
|
29
|
-
it('extracts synonyms', () => {
|
|
30
|
-
expect(SlotUtils.getValueWithSynonyms('a, b, c, d')).toEqual(['a', ['b', 'c', 'd']]);
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
describe('mapSlotAnnotations', () => {
|
|
34
|
-
it('renames keys and maps', () => {
|
|
35
|
-
expect(SlotUtils.mapSlotAnnotations('test {{[name].key}} thing', () => ({ key: 'newKey', name: 'newName' }))).toEqual('test {{[newName].newKey}} thing');
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"string.test.d.ts","sourceRoot":"","sources":["../../../src/utils/string.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const string_1 = require("./string");
|
|
4
|
-
describe('Utils | string', () => {
|
|
5
|
-
describe('capitalizeFirstLetter()', () => {
|
|
6
|
-
it('capitalizes the first letter', () => {
|
|
7
|
-
expect((0, string_1.capitalizeFirstLetter)('')).toBe('');
|
|
8
|
-
expect((0, string_1.capitalizeFirstLetter)('123')).toBe('123');
|
|
9
|
-
expect((0, string_1.capitalizeFirstLetter)('abc')).toBe('Abc');
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
describe('capitalizeAllWords()', () => {
|
|
13
|
-
it('capitalizes all the space-delimited words', () => {
|
|
14
|
-
expect((0, string_1.capitalizeAllWords)('')).toBe('');
|
|
15
|
-
expect((0, string_1.capitalizeAllWords)('abc')).toBe('Abc');
|
|
16
|
-
expect((0, string_1.capitalizeAllWords)('abc def')).toBe('Abc Def');
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
describe('arrayStringReplace()', () => {
|
|
20
|
-
it('replace a pattern for each item in an array', () => {
|
|
21
|
-
expect((0, string_1.arrayStringReplace)('x', 'y', [])).toEqual([]);
|
|
22
|
-
expect((0, string_1.arrayStringReplace)('x', 'y', ['foo'])).toEqual(['foo']);
|
|
23
|
-
expect((0, string_1.arrayStringReplace)('x', 'y', ['xyz', 'foo', 'fox', 'bar'])).toEqual(['yyz', 'foo', 'foy', 'bar']);
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
describe('stripHTMLTags()', () => {
|
|
27
|
-
it('remove HTML tags from a string', () => {
|
|
28
|
-
expect((0, string_1.stripHTMLTags)('')).toBe('');
|
|
29
|
-
expect((0, string_1.stripHTMLTags)('<')).toBe('<');
|
|
30
|
-
expect((0, string_1.stripHTMLTags)('<>')).toBe('<>');
|
|
31
|
-
expect((0, string_1.stripHTMLTags)('<foo>')).toBe('');
|
|
32
|
-
expect((0, string_1.stripHTMLTags)('a b c d')).toBe('a b c d');
|
|
33
|
-
expect((0, string_1.stripHTMLTags)('a <foo> b <bar> c <fizz> d')).toBe('a b c d');
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
describe('removeTrailingUnderscores()', () => {
|
|
37
|
-
it('remove leading and trailing underscore characters', () => {
|
|
38
|
-
expect((0, string_1.removeTrailingUnderscores)('')).toBe('');
|
|
39
|
-
expect((0, string_1.removeTrailingUnderscores)('foo')).toBe('foo');
|
|
40
|
-
expect((0, string_1.removeTrailingUnderscores)('__foo')).toBe('foo');
|
|
41
|
-
expect((0, string_1.removeTrailingUnderscores)('foo__')).toBe('foo');
|
|
42
|
-
expect((0, string_1.removeTrailingUnderscores)('__foo__')).toBe('foo');
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
describe('conditionalReplace()', () => {
|
|
46
|
-
it('do nothing with falsey value', () => {
|
|
47
|
-
expect((0, string_1.conditionalReplace)('fizz', /i/)).toBe('fizz');
|
|
48
|
-
});
|
|
49
|
-
it('use truthy value as replacement value', () => {
|
|
50
|
-
expect((0, string_1.conditionalReplace)('fizz', /i/, 'u')).toBe('fuzz');
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"timezones.test.d.ts","sourceRoot":"","sources":["../../../src/utils/timezones.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const array_1 = require("./array");
|
|
4
|
-
const timezones_1 = require("./timezones");
|
|
5
|
-
describe('Utils | timezones', () => {
|
|
6
|
-
describe('TIMEZONES', () => {
|
|
7
|
-
it('a list of all timezones', () => {
|
|
8
|
-
expect(timezones_1.TIMEZONES.length).toBe(490);
|
|
9
|
-
expect((0, array_1.unique)(timezones_1.TIMEZONES)).toEqual(timezones_1.TIMEZONES);
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"typeguard.test.d.ts","sourceRoot":"","sources":["../../../src/utils/typeguard.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const typeguard_1 = require("./typeguard");
|
|
4
|
-
describe('Utils | typeguard', () => {
|
|
5
|
-
describe('createTypeguardCreator()', () => {
|
|
6
|
-
it('casts the guarded argument', () => {
|
|
7
|
-
const createTypeguard = (0, typeguard_1.createTypeguardCreator)();
|
|
8
|
-
const input = 'foo';
|
|
9
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
10
|
-
const assertTyped = (_arg) => undefined;
|
|
11
|
-
const typeguard = createTypeguard('foo');
|
|
12
|
-
if (typeguard(input)) {
|
|
13
|
-
assertTyped(input);
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
it('typeguard against a single value', () => {
|
|
17
|
-
const createTypeguard = (0, typeguard_1.createTypeguardCreator)();
|
|
18
|
-
const typeguard = createTypeguard('foo');
|
|
19
|
-
expect(typeguard('foo')).toBe(true);
|
|
20
|
-
expect(typeguard('bar')).toBe(false);
|
|
21
|
-
});
|
|
22
|
-
it('typeguard against an array of values', () => {
|
|
23
|
-
const createTypeguard = (0, typeguard_1.createTypeguardCreator)();
|
|
24
|
-
const typeguard = createTypeguard(['foo', 'bar']);
|
|
25
|
-
expect(typeguard('foo')).toBe(true);
|
|
26
|
-
expect(typeguard('bar')).toBe(true);
|
|
27
|
-
expect(typeguard('fizz')).toBe(false);
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
describe('createTypedTypeguardCreator()', () => {
|
|
31
|
-
it('casts the guarded argument', () => {
|
|
32
|
-
const createTypeguard = (0, typeguard_1.createTypedTypeguardCreator)();
|
|
33
|
-
const input = { type: 'foo', id: 123 };
|
|
34
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
35
|
-
const assertTyped = (_arg) => undefined;
|
|
36
|
-
const typeguard = createTypeguard('foo');
|
|
37
|
-
if (typeguard(input)) {
|
|
38
|
-
assertTyped(input);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
it('typeguard against a single value', () => {
|
|
42
|
-
const createTypeguard = (0, typeguard_1.createTypedTypeguardCreator)();
|
|
43
|
-
const typeguard = createTypeguard('foo');
|
|
44
|
-
expect(typeguard({ type: 'foo', id: 1 })).toBe(true);
|
|
45
|
-
expect(typeguard({ type: 'bar', id: 2 })).toBe(false);
|
|
46
|
-
});
|
|
47
|
-
it('typeguard against an array of values', () => {
|
|
48
|
-
const createTypeguard = (0, typeguard_1.createTypedTypeguardCreator)();
|
|
49
|
-
const typeguard = createTypeguard(['foo', 'bar']);
|
|
50
|
-
expect(typeguard({ type: 'foo', id: 1 })).toBe(true);
|
|
51
|
-
expect(typeguard({ type: 'bar', id: 2 })).toBe(true);
|
|
52
|
-
expect(typeguard({ type: 'fizz', id: 3 })).toBe(false);
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hex2abc.test.d.ts","sourceRoot":"","sources":["../../../src/crypto/hex2abc.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { hex2abc } from './hex2abc.js';
|
|
2
|
-
describe('hex2abc()', () => {
|
|
3
|
-
it('works', () => {
|
|
4
|
-
expect(hex2abc('abcdef')).toBe('abcdef');
|
|
5
|
-
expect(hex2abc('0123456789')).toBe('ghijklmnop');
|
|
6
|
-
});
|
|
7
|
-
it('works with 0x prefixes', () => {
|
|
8
|
-
expect(hex2abc('0xabc123')).toBe('gxabchij');
|
|
9
|
-
});
|
|
10
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"murmurhash.test.d.ts","sourceRoot":"","sources":["../../../src/crypto/murmurhash.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { MurmurHash } from './murmurhash.js';
|
|
2
|
-
// for second test check (4 byte chunk)
|
|
3
|
-
// const buf_left = Buffer.of(0xff, 0xff, 0xff, 0xff);
|
|
4
|
-
// const buf_right = Buffer.of(0x76, 0x29, 0x3b, 0x50);
|
|
5
|
-
// for third test check (correct endian order)
|
|
6
|
-
// const buf_left_two = Buffer.of(0x21, 0x43, 0x65, 0x87);
|
|
7
|
-
// const buf_right_two = Buffer.of(0xf5, 0x5b, 0x51, 0x6b);
|
|
8
|
-
describe('hash()', () => {
|
|
9
|
-
it('return a 32-bit hash resulting from the murmurhash3 algorithm', () => {
|
|
10
|
-
expect(MurmurHash.hash('hello', 0)).toBe('lokkdakm');
|
|
11
|
-
expect(MurmurHash.hash('hello world', 0)).toBe('kkehkpgl');
|
|
12
|
-
expect(MurmurHash.hash('helloworld', 0)).toBe('holkilfm');
|
|
13
|
-
expect(MurmurHash.hash('HELLOWORLD', 0)).toBe('dohkopda');
|
|
14
|
-
expect(MurmurHash.hash('', 0)).toBe('g'); // not sure why '0000 0000' fails as a test
|
|
15
|
-
expect(MurmurHash.hash('abc', 0)).toBe('bjddpjfa');
|
|
16
|
-
expect(MurmurHash.hash('ABC', 0)).toBe('kjchcljl');
|
|
17
|
-
// from https://github.com/jonahsnider/murmurhash-wasm/blob/main/test/murmur-hash3/hash-32.test.ts
|
|
18
|
-
// expect(MurmurHash.hash(buf_left.toString('hex'), 0)).to.eql(buf_right.toString('hex'));
|
|
19
|
-
// expect(MurmurHash.hash(buf_left_two.toString('hex'), 0)).to.eql(buf_right_two.toString('hex'));
|
|
20
|
-
});
|
|
21
|
-
});
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"slots": [
|
|
3
|
-
{
|
|
4
|
-
"key": "4i3h3mmi",
|
|
5
|
-
"name": "slotmans",
|
|
6
|
-
"type": {
|
|
7
|
-
"value": "custom"
|
|
8
|
-
},
|
|
9
|
-
"color": "#4F9ED1",
|
|
10
|
-
"inputs": ["tyler", "john", "scott", "michael", "william", "andy", "peter", "frank", "igor", "steven", "jessica"]
|
|
11
|
-
}
|
|
12
|
-
],
|
|
13
|
-
"intents": [
|
|
14
|
-
{
|
|
15
|
-
"key": "3sb53sup",
|
|
16
|
-
"name": "name_intent",
|
|
17
|
-
"slots": [
|
|
18
|
-
{
|
|
19
|
-
"id": "4i3h3mmi",
|
|
20
|
-
"dialog": {
|
|
21
|
-
"prompt": [
|
|
22
|
-
{
|
|
23
|
-
"text": "",
|
|
24
|
-
"slots": []
|
|
25
|
-
}
|
|
26
|
-
],
|
|
27
|
-
"confirm": [
|
|
28
|
-
{
|
|
29
|
-
"text": "",
|
|
30
|
-
"slots": []
|
|
31
|
-
}
|
|
32
|
-
],
|
|
33
|
-
"utterances": [
|
|
34
|
-
{
|
|
35
|
-
"text": "{{[name].4i3h3mmi}} ",
|
|
36
|
-
"slots": ["4i3h3mmi"]
|
|
37
|
-
}
|
|
38
|
-
],
|
|
39
|
-
"confirmEnabled": false
|
|
40
|
-
},
|
|
41
|
-
"required": false
|
|
42
|
-
}
|
|
43
|
-
],
|
|
44
|
-
"inputs": [
|
|
45
|
-
{
|
|
46
|
-
"text": "It's {{[slotmans].4i3h3mmi}}",
|
|
47
|
-
"slots": ["4i3h3mmi"]
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
"text": "I'm {{[slotmans].4i3h3mmi}}",
|
|
51
|
-
"slots": ["4i3h3mmi"]
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
"text": "{{[slotmans].4i3h3mmi}}",
|
|
55
|
-
"slots": ["4i3h3mmi"]
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
"text": "my name is {{[slotmans].4i3h3mmi}}",
|
|
59
|
-
"slots": ["4i3h3mmi"]
|
|
60
|
-
}
|
|
61
|
-
]
|
|
62
|
-
}
|
|
63
|
-
]
|
|
64
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"array.test.d.ts","sourceRoot":"","sources":["../../../src/utils/array.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
import { append, createEntries, createMap, diff, filterAndGetLastRemovedValue, filterOutNullish, findUnion, hasIdenticalMembers, head, insert, insertAll, isNotNullish, isNullish, mergeByIdentifier, reorder, replace, separate, tail, toArray, toggleMembership, unique, without, withoutValue, withoutValues, } from './array.js';
|
|
2
|
-
describe('Utils | array', () => {
|
|
3
|
-
describe('unique()', () => {
|
|
4
|
-
it('return an array containing one instance of each value from the array passed to it', () => {
|
|
5
|
-
expect(unique([1, 1, 2, 0, 1, 4, 3, 1, 9, 9, 2])).toEqual([1, 2, 0, 4, 3, 9]);
|
|
6
|
-
});
|
|
7
|
-
});
|
|
8
|
-
describe('without()', () => {
|
|
9
|
-
it('return an array containing every value from the array passed to it except for the value at the provided index', () => {
|
|
10
|
-
expect(without([], -1)).toEqual([]);
|
|
11
|
-
expect(without([], 0)).toEqual([]);
|
|
12
|
-
expect(without(['a', 'b', 'c', 'd'], -1)).toEqual(['a', 'b', 'c', 'd']);
|
|
13
|
-
expect(without(['a', 'b', 'c', 'd'], 0)).toEqual(['b', 'c', 'd']);
|
|
14
|
-
expect(without(['a', 'b', 'c', 'd'], 2)).toEqual(['a', 'b', 'd']);
|
|
15
|
-
expect(without(['a', 'b', 'c', 'd'], 4)).toEqual(['a', 'b', 'c', 'd']);
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
describe('withoutValue()', () => {
|
|
19
|
-
it('return an array containing every value from the array passed to it except for first value that is directly equal to the provided value', () => {
|
|
20
|
-
expect(withoutValue([], 'd')).toEqual([]);
|
|
21
|
-
expect(withoutValue(['a', 'b', 'c', 'd'], 'g')).toEqual(['a', 'b', 'c', 'd']);
|
|
22
|
-
expect(withoutValue(['a', 'b', 'c', 'd'], 'b')).toEqual(['a', 'c', 'd']);
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
describe('withoutValues()', () => {
|
|
26
|
-
it('return an array containing every value from the array passed to it except for values from a second provided array', () => {
|
|
27
|
-
expect(withoutValues(['a', 'b', 'c', 'd'], [])).toEqual(['a', 'b', 'c', 'd']);
|
|
28
|
-
expect(withoutValues([], ['g', 'c', 'b', 'e'])).toEqual([]);
|
|
29
|
-
expect(withoutValues(['a', 'b', 'c', 'd'], ['g', 'c', 'b', 5])).toEqual(['a', 'd']);
|
|
30
|
-
expect(withoutValues(['a', 'b', 'c', 'd'], ['g', 'e'])).toEqual(['a', 'b', 'c', 'd']);
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
describe('replace()', () => {
|
|
34
|
-
it('return an array where the value at the provided index has been replaced with the new value', () => {
|
|
35
|
-
expect(insert([], 8, 'f')).toEqual(['f']);
|
|
36
|
-
expect(replace(['a', 'b', 'c', 'd'], -1, 'f')).toEqual(['a', 'b', 'c', 'd']);
|
|
37
|
-
expect(replace(['a', 'b', 'c', 'd'], 8, 'f')).toEqual(['a', 'b', 'c', 'd', 'f']);
|
|
38
|
-
expect(replace(['a', 'b', 'c', 'd'], 2, 'f')).toEqual(['a', 'b', 'f', 'd']);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
describe('insert()', () => {
|
|
42
|
-
it('return an array where the provided value has been inserted at the provided index', () => {
|
|
43
|
-
expect(insert([], 8, 'f')).toEqual(['f']);
|
|
44
|
-
expect(insert(['a', 'b', 'c', 'd'], -1, 'f')).toEqual(['f', 'a', 'b', 'c', 'd']);
|
|
45
|
-
expect(insert(['a', 'b', 'c', 'd'], 2, 'f')).toEqual(['a', 'b', 'f', 'c', 'd']);
|
|
46
|
-
expect(insert(['a', 'b', 'c', 'd'], 8, 'f')).toEqual(['a', 'b', 'c', 'd', 'f']);
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
describe('insertAll()', () => {
|
|
50
|
-
it('return an array where the provided array of values has been inserted at the provided index', () => {
|
|
51
|
-
expect(insertAll([], 8, ['f', 'g', 'h'])).toEqual(['f', 'g', 'h']);
|
|
52
|
-
expect(insertAll(['a', 'b', 'c', 'd'], -1, ['f', 'g', 'h'])).toEqual(['f', 'g', 'h', 'a', 'b', 'c', 'd']);
|
|
53
|
-
expect(insertAll(['a', 'b', 'c', 'd'], 2, ['f', 'g', 'h'])).toEqual(['a', 'b', 'f', 'g', 'h', 'c', 'd']);
|
|
54
|
-
expect(insertAll(['a', 'b', 'c', 'd'], 8, ['f', 'g', 'h'])).toEqual(['a', 'b', 'c', 'd', 'f', 'g', 'h']);
|
|
55
|
-
});
|
|
56
|
-
});
|
|
57
|
-
describe('append()', () => {
|
|
58
|
-
it('return an array with the provided value appended, does not add if already exists', () => {
|
|
59
|
-
expect(append([], 'f')).toEqual(['f']);
|
|
60
|
-
expect(append(['a', 'b', 'c', 'd'], 'f')).toEqual(['a', 'b', 'c', 'd', 'f']);
|
|
61
|
-
expect(append(['a', 'b', 'c'], 'c')).toEqual(['a', 'b', 'c']);
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
describe('toggleMembership()', () => {
|
|
65
|
-
it('return an array with the provided value included or excluded, the opposite of the current state', () => {
|
|
66
|
-
expect(toggleMembership(['a', 'b', 'c'], 'f')).toEqual(['a', 'b', 'c', 'f']);
|
|
67
|
-
expect(toggleMembership(['a', 'b', 'c', 'f'], 'f')).toEqual(['a', 'b', 'c']);
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
describe('head()', () => {
|
|
71
|
-
it('return the item at the head of the array and an array containing the remaining elements as a tuple pair', () => {
|
|
72
|
-
expect(head(['a', 'b', 'c', 'd'])).toEqual(['a', ['b', 'c', 'd']]);
|
|
73
|
-
expect(head(['a'])).toEqual(['a', []]);
|
|
74
|
-
expect(head([])).toEqual([undefined, []]);
|
|
75
|
-
});
|
|
76
|
-
});
|
|
77
|
-
describe('tail()', () => {
|
|
78
|
-
it('return the item at the end of the array and an array containing the remaining elements as a tuple pair', () => {
|
|
79
|
-
expect(tail(['a', 'b', 'c', 'd'])).toEqual([['a', 'b', 'c'], 'd']);
|
|
80
|
-
expect(tail(['a'])).toEqual([[], 'a']);
|
|
81
|
-
expect(tail([])).toEqual([[], undefined]);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
describe('filterOutNullish()', () => {
|
|
85
|
-
it('filters nullish values', () => {
|
|
86
|
-
expect(filterOutNullish([undefined, 1, null])).toEqual([1]);
|
|
87
|
-
expect(filterOutNullish([undefined, null])).toEqual([]);
|
|
88
|
-
expect(filterOutNullish([1])).toEqual([1]);
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
describe('isNullish()', () => {
|
|
92
|
-
it('works', () => {
|
|
93
|
-
expect(isNullish(null)).toBe(true);
|
|
94
|
-
expect(isNullish(undefined)).toBe(true);
|
|
95
|
-
expect(isNullish(0)).toBe(false);
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
describe('isNotNullish()', () => {
|
|
99
|
-
it('works', () => {
|
|
100
|
-
expect(isNotNullish(null)).toBe(false);
|
|
101
|
-
expect(isNotNullish(undefined)).toBe(false);
|
|
102
|
-
expect(isNotNullish(0)).toBe(true);
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
describe('toArray()', () => {
|
|
106
|
-
it('works with arrays', () => {
|
|
107
|
-
const value = [1];
|
|
108
|
-
expect(toArray(value)).toEqual([1]);
|
|
109
|
-
});
|
|
110
|
-
it('works with non-arrays', () => {
|
|
111
|
-
const value = 1;
|
|
112
|
-
expect(toArray(value)).toEqual([1]);
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
describe('reorder()', () => {
|
|
116
|
-
it('should do nothing if from index goes outside array', () => {
|
|
117
|
-
const array = [1, 2, 3];
|
|
118
|
-
expect(reorder(array, -1, 1)).toEqual(array);
|
|
119
|
-
expect(reorder(array, 3, 1)).toEqual(array);
|
|
120
|
-
});
|
|
121
|
-
it('should set as first item if toIndex is zero or lower than 0', () => {
|
|
122
|
-
const array = [1, 2, 3];
|
|
123
|
-
expect(reorder(array, 2, -1)).toEqual([3, 1, 2]);
|
|
124
|
-
expect(reorder(array, 2, 0)).toEqual([3, 1, 2]);
|
|
125
|
-
});
|
|
126
|
-
it('should set as last item if toIndex is the last or greater than last', () => {
|
|
127
|
-
const array = [1, 2, 3];
|
|
128
|
-
expect(reorder(array, 0, 2)).toEqual([2, 3, 1]);
|
|
129
|
-
expect(reorder(array, 0, 3)).toEqual([2, 3, 1]);
|
|
130
|
-
});
|
|
131
|
-
it('should reorder moving forward or backward', () => {
|
|
132
|
-
const array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
|
133
|
-
expect(reorder(array, 1, 2)).toEqual([1, 3, 2, 4, 5, 6, 7, 8, 9, 10]);
|
|
134
|
-
expect(reorder(array, 2, 3)).toEqual([1, 2, 4, 3, 5, 6, 7, 8, 9, 10]);
|
|
135
|
-
expect(reorder(array, 2, 8)).toEqual([1, 2, 4, 5, 6, 7, 8, 9, 3, 10]);
|
|
136
|
-
expect(reorder(array, 8, 1)).toEqual([1, 9, 2, 3, 4, 5, 6, 7, 8, 10]);
|
|
137
|
-
expect(reorder(array, 7, 2)).toEqual([1, 2, 8, 3, 4, 5, 6, 7, 9, 10]);
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
describe('separate()', () => {
|
|
141
|
-
it('separates items that pass and fail a predicate', () => {
|
|
142
|
-
const [passes, fails] = separate([20, 1, -3, 15, 8, 23, 40, 3], (x) => x > 10);
|
|
143
|
-
expect(passes).toEqual([20, 15, 23, 40]);
|
|
144
|
-
expect(fails).toEqual([1, -3, 8, 3]);
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
describe('createEntries()', () => {
|
|
148
|
-
it('creates entries by extracting a key for each item in an array', () => {
|
|
149
|
-
const entries = createEntries([{ index: 1 }, { index: 3 }, { index: 5 }], ({ index }) => String(index));
|
|
150
|
-
expect(entries).toEqual([
|
|
151
|
-
['1', { index: 1 }],
|
|
152
|
-
['3', { index: 3 }],
|
|
153
|
-
['5', { index: 5 }],
|
|
154
|
-
]);
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
describe('createMap()', () => {
|
|
158
|
-
it('creates object by extracting a key for each item in an array', () => {
|
|
159
|
-
const obj = createMap([{ index: 1 }, { index: 3 }, { index: 5 }], ({ index }) => String(index));
|
|
160
|
-
expect(obj).toEqual({
|
|
161
|
-
1: { index: 1 },
|
|
162
|
-
3: { index: 3 },
|
|
163
|
-
5: { index: 5 },
|
|
164
|
-
});
|
|
165
|
-
});
|
|
166
|
-
});
|
|
167
|
-
describe('findUnion()', () => {
|
|
168
|
-
it('finds the overlap between two lists', () => {
|
|
169
|
-
const { lhsOnly, rhsOnly, union } = findUnion([20, 1, -3, 15], [1, 8, 23, -3, 40, 3]);
|
|
170
|
-
expect(lhsOnly).toEqual([20, 15]);
|
|
171
|
-
expect(rhsOnly).toEqual([8, 23, 40, 3]);
|
|
172
|
-
expect(union).toEqual([1, -3]);
|
|
173
|
-
});
|
|
174
|
-
});
|
|
175
|
-
describe('diff()', () => {
|
|
176
|
-
it('finds items that only occur in one of two lists', () => {
|
|
177
|
-
expect(diff([20, 1, -3, 15], [1, 8, 23, -3, 40, 3])).toEqual([20, 15, 8, 23, 40, 3]);
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
describe('hasIdenticalMembers()', () => {
|
|
181
|
-
it('returns false if lists have different lengths', () => {
|
|
182
|
-
expect(hasIdenticalMembers([1, 2, 3], [3, 3, 2, 2, 1])).toBe(false);
|
|
183
|
-
});
|
|
184
|
-
it('returns false if either list has a unique member', () => {
|
|
185
|
-
expect(hasIdenticalMembers([1, 2, 3], [2, 3])).toBe(false);
|
|
186
|
-
});
|
|
187
|
-
it('returns true if both lists contain the same members', () => {
|
|
188
|
-
expect(hasIdenticalMembers([1, 2, 3], [3, 1, 2])).toBe(true);
|
|
189
|
-
});
|
|
190
|
-
it('returns true if both lists are empty', () => {
|
|
191
|
-
expect(hasIdenticalMembers([], [])).toBe(true);
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
describe('filterAndGetLastRemovedValue()', () => {
|
|
195
|
-
it('returns the last item which did not pass the filter predicate', () => {
|
|
196
|
-
expect(filterAndGetLastRemovedValue([1, 2, 3], () => true)).toEqual([[1, 2, 3], null]);
|
|
197
|
-
expect(filterAndGetLastRemovedValue([], () => false)).toEqual([[], null]);
|
|
198
|
-
expect(filterAndGetLastRemovedValue([1, 2, 3], (x) => x !== 2)).toEqual([[1, 3], 2]);
|
|
199
|
-
});
|
|
200
|
-
});
|
|
201
|
-
describe('mergeByIdentifier()', () => {
|
|
202
|
-
it('test', () => {
|
|
203
|
-
const array1 = [
|
|
204
|
-
{
|
|
205
|
-
key: 1,
|
|
206
|
-
value: [1, 2],
|
|
207
|
-
},
|
|
208
|
-
];
|
|
209
|
-
const array2 = [
|
|
210
|
-
{
|
|
211
|
-
key: 1,
|
|
212
|
-
value: [3],
|
|
213
|
-
},
|
|
214
|
-
{
|
|
215
|
-
key: 2,
|
|
216
|
-
value: [4, 5],
|
|
217
|
-
},
|
|
218
|
-
];
|
|
219
|
-
const result = mergeByIdentifier(array1, array2, (x) => x.key.toString(), (a, b) => ({
|
|
220
|
-
...a,
|
|
221
|
-
value: [...a.value, ...b.value],
|
|
222
|
-
}));
|
|
223
|
-
expect(result).toEqual([
|
|
224
|
-
{
|
|
225
|
-
key: 1,
|
|
226
|
-
value: [1, 2, 3],
|
|
227
|
-
},
|
|
228
|
-
{
|
|
229
|
-
key: 2,
|
|
230
|
-
value: [4, 5],
|
|
231
|
-
},
|
|
232
|
-
]);
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"email.test.d.ts","sourceRoot":"","sources":["../../../src/utils/email.test.ts"],"names":[],"mappings":""}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { getEmailDomain, isValidEmail } from './emails.js';
|
|
2
|
-
describe('Utils | email', () => {
|
|
3
|
-
describe('isValid()', () => {
|
|
4
|
-
it('should be valid', () => {
|
|
5
|
-
const validEmails = ['joe.doe@test.com', 'john.-last@sub.domain.com', 'test+@voiceflow.com', 't-est+34@voice-flow.com'];
|
|
6
|
-
validEmails.forEach((email) => expect(isValidEmail(email)).toBe(true));
|
|
7
|
-
});
|
|
8
|
-
it('should be invalid', () => {
|
|
9
|
-
const invalidEmails = ['joe@.com', 'joe@', '@voiceflow.com', '', 'voiceflow.com'];
|
|
10
|
-
invalidEmails.forEach((email) => expect(isValidEmail(email)).toBe(false));
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
describe('getEmailDomain()', () => {
|
|
14
|
-
it('works', () => {
|
|
15
|
-
expect(getEmailDomain('test@voiceflow.com')).toBe('voiceflow.com');
|
|
16
|
-
expect(getEmailDomain('')).toBe('');
|
|
17
|
-
expect(getEmailDomain('totally@invalid@voiceflow.com')).toBe('voiceflow.com');
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"functional.test.d.ts","sourceRoot":"","sources":["../../../src/utils/functional.test.ts"],"names":[],"mappings":""}
|