patronum
Version:
☄️ Effector utility library delivering modularity and convenience
26 lines (25 loc) • 673 B
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.format = format;
var _effector = require("effector");
function format(strings, ...stores) {
return (0, _effector.combine)({
and: [stores, stores => strings.reduce((acc, value, index) => acc.concat(isLastElement(strings, index) ? value : `${value}${toString(stores[index])}`), ''), {
skipVoid: false
}],
or: {
sid: "-yrbthp"
}
});
}
function toString(value) {
if (Array.isArray(value)) {
return value.map(value => String(value)).join(', ');
}
return String(value);
}
function isLastElement(array, index) {
return index === array.length - 1;
}
;