@builder.io/mitosis
Version:
Write components once, run everywhere. Compiles to Vue, React, Solid, and Liquid. Import code from Figma and Builder.io
18 lines (17 loc) • 1.11 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.prefixWithFunction = exports.extractGetterCodeBlock = exports.replaceFunctionWithGetter = exports.replaceGetterWithFunction = exports.stripGetter = exports.checkIsGetter = exports.SETTER = exports.GETTER = void 0;
exports.GETTER = /^\s*get /;
exports.SETTER = /^\s*set /;
const checkIsGetter = (code) => code.match(exports.GETTER);
exports.checkIsGetter = checkIsGetter;
const stripGetter = (str) => str.replace(exports.GETTER, '');
exports.stripGetter = stripGetter;
const replaceGetterWithFunction = (str) => str.replace(/^(get )?/, 'function ');
exports.replaceGetterWithFunction = replaceGetterWithFunction;
const replaceFunctionWithGetter = (str) => str.replace(/^(function )?/, 'get ');
exports.replaceFunctionWithGetter = replaceFunctionWithGetter;
const extractGetterCodeBlock = (getter) => getter.replace(/[\S\s]*\(\) \{([\S\s]*)\}[\S\s]*/, '$1').trim();
exports.extractGetterCodeBlock = extractGetterCodeBlock;
const prefixWithFunction = (str) => `function ${str}`;
exports.prefixWithFunction = prefixWithFunction;
;