@jargon/platform-sdk-core
Version:
Core components of the Jargon Platform SDK for node.js
23 lines • 954 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.extractParamNames = void 0;
const intl_messageformat_parser_1 = require("intl-messageformat-parser");
const lodash_1 = require("lodash");
function extractParamNames(msg) {
const params = new Set();
const q = intl_messageformat_parser_1.parse(msg);
while (q.length > 0) {
const e = q.pop();
if (e.type !== intl_messageformat_parser_1.TYPE.literal && e.type !== intl_messageformat_parser_1.TYPE.pound) {
params.add(e.value);
if (e.type === intl_messageformat_parser_1.TYPE.plural || e.type === intl_messageformat_parser_1.TYPE.select) {
lodash_1.chain(Object.values(e.options))
.flatMap(pe => pe.value)
.forEach(e => q.push(e));
}
}
}
return params;
}
exports.extractParamNames = extractParamNames;
//# sourceMappingURL=icuUtils.js.map