@voiceflow/common
Advanced tools
Comparing version 7.20.1 to 7.20.2
import cuid from 'cuid'; | ||
import { EmptyObject } from '../types'; | ||
export { cuid }; | ||
export declare const objectID: () => string; | ||
export declare const remapObjectIDs: <T extends Readonly<EmptyObject>>(object: T, lookupMap: Record<string, string> | Map<string, string>) => T; |
@@ -6,8 +6,21 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.objectID = exports.cuid = void 0; | ||
exports.remapObjectIDs = exports.objectID = exports.cuid = void 0; | ||
const bson_objectid_1 = __importDefault(require("bson-objectid")); | ||
const cuid_1 = __importDefault(require("cuid")); | ||
exports.cuid = cuid_1.default; | ||
const deep_map_1 = __importDefault(require("deep-map")); | ||
const deep_map_keys_1 = __importDefault(require("deep-map-keys")); | ||
const objectID = () => new bson_objectid_1.default().toHexString(); | ||
exports.objectID = objectID; | ||
const remapObjectIDs = (object, lookupMap) => { | ||
const map = lookupMap instanceof Map ? lookupMap : new Map(Object.entries(lookupMap)); | ||
const mapping = (value) => { | ||
if (typeof value === 'string' && map.has(value)) { | ||
return map.get(value); | ||
} | ||
return value; | ||
}; | ||
return (0, deep_map_keys_1.default)((0, deep_map_1.default)(object, mapping), mapping); | ||
}; | ||
exports.remapObjectIDs = remapObjectIDs; | ||
//# sourceMappingURL=id.js.map |
import cuid from 'cuid'; | ||
import { EmptyObject } from '../types'; | ||
export { cuid }; | ||
export declare const objectID: () => string; | ||
export declare const remapObjectIDs: <T extends Readonly<EmptyObject>>(object: T, lookupMap: Record<string, string> | Map<string, string>) => T; |
import ObjectId from 'bson-objectid'; | ||
import cuid from 'cuid'; | ||
import deepMap from 'deep-map'; | ||
import deepMapKeys from 'deep-map-keys'; | ||
export { cuid }; | ||
export const objectID = () => new ObjectId().toHexString(); | ||
export const remapObjectIDs = (object, lookupMap) => { | ||
const map = lookupMap instanceof Map ? lookupMap : new Map(Object.entries(lookupMap)); | ||
const mapping = (value) => { | ||
if (typeof value === 'string' && map.has(value)) { | ||
return map.get(value); | ||
} | ||
return value; | ||
}; | ||
return deepMapKeys(deepMap(object, mapping), mapping); | ||
}; | ||
//# sourceMappingURL=id.js.map |
{ | ||
"name": "@voiceflow/common", | ||
"description": "Junk drawer of utility functions", | ||
"version": "7.20.1", | ||
"version": "7.20.2", | ||
"author": "Voiceflow", | ||
@@ -15,2 +15,5 @@ "bugs": { | ||
"dayjs": "^1.10.7", | ||
"deep-map": "2.0.0", | ||
"deep-map-keys": "2.0.1", | ||
"es6-weak-map": "2.0.3", | ||
"lodash": "^4.17.21", | ||
@@ -79,3 +82,3 @@ "murmurhash-wasm": "^1.3.0", | ||
}, | ||
"gitHead": "434247de43ee27aeb92c2964309fb35c1dd69434" | ||
"gitHead": "132bb4a23c41ee02103ac2f1e332cbf7793f2ba3" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
389585
6873
12
+ Addeddeep-map@2.0.0
+ Addeddeep-map-keys@2.0.1
+ Addedes6-weak-map@2.0.3
+ Addedd@1.0.2(transitive)
+ Addeddeep-map@2.0.0(transitive)
+ Addeddeep-map-keys@2.0.1(transitive)
+ Addedes5-ext@0.10.64(transitive)
+ Addedes6-iterator@2.0.3(transitive)
+ Addedes6-symbol@3.1.4(transitive)
+ Addedes6-weak-map@2.0.3(transitive)
+ Addedesniff@2.0.1(transitive)
+ Addedevent-emitter@0.3.5(transitive)
+ Addedext@1.7.0(transitive)
+ Addednext-tick@1.1.0(transitive)
+ Addedtslib@1.14.1(transitive)
+ Addedtype@2.7.3(transitive)