mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
26 lines
580 B
JavaScript
26 lines
580 B
JavaScript
//#region src/core/combine.ts
|
|
/**
|
|
* Combines multiple slices into a single slice.
|
|
*
|
|
* @param slices - The slices to combine.
|
|
* @returns A new slice that represents the combination of the input slices.
|
|
*/
|
|
function combine(...slices) {
|
|
return {
|
|
state: (ctx) => {
|
|
const states = slices.map((slice) => slice.state(ctx));
|
|
return Object.assign({}, ...states);
|
|
},
|
|
attach: (ctx) => {
|
|
for (const slice of slices) try {
|
|
slice.attach?.(ctx);
|
|
} catch (err) {
|
|
ctx.reportError(err);
|
|
}
|
|
}
|
|
};
|
|
}
|
|
//#endregion
|
|
export { combine };
|
|
|
|
//# sourceMappingURL=combine.js.map
|