@voiceflow/common 7.22.1 → 7.23.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/common/utils/index.d.ts +1 -0
- package/build/common/utils/index.js +2 -1
- package/build/common/utils/map.d.ts +5 -0
- package/build/common/utils/map.js +15 -0
- package/build/esm/utils/index.d.ts +1 -0
- package/build/esm/utils/index.js +1 -0
- package/build/esm/utils/map.d.ts +5 -0
- package/build/esm/utils/map.js +11 -0
- package/package.json +2 -2
|
@@ -4,6 +4,7 @@ export * as functional from './functional';
|
|
|
4
4
|
export { generate, generateHash } from './generate';
|
|
5
5
|
export * as id from './id';
|
|
6
6
|
export * as intent from './intent';
|
|
7
|
+
export * as map from './map';
|
|
7
8
|
export * as mathjs from './mathjs';
|
|
8
9
|
export * as normalized from './normalized';
|
|
9
10
|
export * as number from './number';
|
|
@@ -22,7 +22,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
22
22
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.variables = exports.typeguard = exports.timezones = exports.time = exports.string = exports.slot = exports.protocol = exports.promise = exports.object = exports.number = exports.normalized = exports.mathjs = exports.intent = exports.id = exports.generateHash = exports.generate = exports.functional = exports.emails = exports.array = void 0;
|
|
25
|
+
exports.variables = exports.typeguard = exports.timezones = exports.time = exports.string = exports.slot = exports.protocol = exports.promise = exports.object = exports.number = exports.normalized = exports.mathjs = exports.map = exports.intent = exports.id = exports.generateHash = exports.generate = exports.functional = exports.emails = exports.array = void 0;
|
|
26
26
|
exports.array = __importStar(require("./array"));
|
|
27
27
|
exports.emails = __importStar(require("./emails"));
|
|
28
28
|
exports.functional = __importStar(require("./functional"));
|
|
@@ -31,6 +31,7 @@ Object.defineProperty(exports, "generate", { enumerable: true, get: function ()
|
|
|
31
31
|
Object.defineProperty(exports, "generateHash", { enumerable: true, get: function () { return generate_1.generateHash; } });
|
|
32
32
|
exports.id = __importStar(require("./id"));
|
|
33
33
|
exports.intent = __importStar(require("./intent"));
|
|
34
|
+
exports.map = __importStar(require("./map"));
|
|
34
35
|
exports.mathjs = __importStar(require("./mathjs"));
|
|
35
36
|
exports.normalized = __importStar(require("./normalized"));
|
|
36
37
|
exports.number = __importStar(require("./number"));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getOrDefault = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Retrieve the value at the given key inside the map.
|
|
6
|
+
* If the key does not exist, insert the default value into the map and return that value.
|
|
7
|
+
*/
|
|
8
|
+
const getOrDefault = (map, key, defaultValue) => {
|
|
9
|
+
if (!map.has(key)) {
|
|
10
|
+
map.set(key, defaultValue);
|
|
11
|
+
return defaultValue;
|
|
12
|
+
}
|
|
13
|
+
return map.get(key);
|
|
14
|
+
};
|
|
15
|
+
exports.getOrDefault = getOrDefault;
|
|
@@ -4,6 +4,7 @@ export * as functional from './functional';
|
|
|
4
4
|
export { generate, generateHash } from './generate';
|
|
5
5
|
export * as id from './id';
|
|
6
6
|
export * as intent from './intent';
|
|
7
|
+
export * as map from './map';
|
|
7
8
|
export * as mathjs from './mathjs';
|
|
8
9
|
export * as normalized from './normalized';
|
|
9
10
|
export * as number from './number';
|
package/build/esm/utils/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export * as functional from './functional';
|
|
|
4
4
|
export { generate, generateHash } from './generate';
|
|
5
5
|
export * as id from './id';
|
|
6
6
|
export * as intent from './intent';
|
|
7
|
+
export * as map from './map';
|
|
7
8
|
export * as mathjs from './mathjs';
|
|
8
9
|
export * as normalized from './normalized';
|
|
9
10
|
export * as number from './number';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieve the value at the given key inside the map.
|
|
3
|
+
* If the key does not exist, insert the default value into the map and return that value.
|
|
4
|
+
*/
|
|
5
|
+
export const getOrDefault = (map, key, defaultValue) => {
|
|
6
|
+
if (!map.has(key)) {
|
|
7
|
+
map.set(key, defaultValue);
|
|
8
|
+
return defaultValue;
|
|
9
|
+
}
|
|
10
|
+
return map.get(key);
|
|
11
|
+
};
|
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.23.0",
|
|
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": "8a42f59e14588817d901cee1d3545040eefa2dee"
|
|
80
80
|
}
|