UNPKG

@svta/common-media-library

Version:
23 lines 882 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.parseOptions = parseOptions; // Helper function to parse input into groups separated by 'groupDelim', and // interpet each group as a key/value pair separated by 'keyValueDelim'. function parseOptions(input, callback, keyValueDelim, groupDelim) { // TODO: Optimize parsing to avoid creating new arrays and strings. const groups = groupDelim ? input.split(groupDelim) : [input]; for (const i in groups) { if (typeof groups[i] !== 'string') { continue; } const kv = groups[i].split(keyValueDelim); if (kv.length !== 2) { continue; } const k = kv[0]; const v = kv[1].trim(); // TODO: Return a value instead of using a callback. callback(k, v); } } //# sourceMappingURL=parseOptions.js.map