@builder.io/mitosis
Version:
Write components once, run everywhere. Compiles to Vue, React, Solid, and Liquid. Import code from Figma and Builder.io
28 lines (27 loc) • 835 B
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.has = void 0;
const legacy_1 = __importDefault(require("neotraverse/legacy"));
const is_mitosis_node_1 = require("./is-mitosis-node");
/**
* Test if the component has something
*
* e.g.
* const hasSpread = has(component, node => some(node.bindings, { type: 'spread' }));
*/
function has(json, test) {
let found = false;
(0, legacy_1.default)(json).forEach(function (thing) {
if ((0, is_mitosis_node_1.isMitosisNode)(thing)) {
if (test(thing)) {
found = true;
this.stop();
}
}
});
return found;
}
exports.has = has;
;