UNPKG

@connectv/marked

Version:
67 lines 1.97 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); function normalize(x) { x = x.trim(); if ((x.startsWith('"') && x.endsWith('"')) || (x.startsWith('`') && x.endsWith('`')) || (x.startsWith("'") && x.endsWith("'"))) x = x.substr(1, x.length - 2); return x.trim(); } function extractCompProps(propString) { var props = {}; var mode = 'key'; var curr = undefined; var currkey = undefined; var strmark = undefined; for (var _i = 0, propString_1 = propString; _i < propString_1.length; _i++) { var c = propString_1[_i]; if (strmark) { if (c === strmark) { curr += c; strmark = undefined; } else curr += c; } else { if (c === '"' || c === '`' || c === "'") { strmark = c; curr = curr || ''; curr += c; } else if (c === '=') { if (mode === 'key') { currkey = curr; curr = undefined; mode = 'value'; } else { curr = curr || ''; curr += c; } } else if (c === ',') { if (mode === 'value') { props[normalize(currkey || '')] = normalize(curr || ''); curr = undefined; mode = 'key'; } else { curr = curr || ''; curr += c; } } else { curr = curr || ''; curr += c; } } } if (currkey) { props[normalize(currkey)] = normalize(curr || ''); } return props; } exports.extractCompProps = extractCompProps; //# sourceMappingURL=extract-comp-props.js.map