From fe6d99d4f1fcf70ec901e8fbf464290ace8e1a76 Mon Sep 17 00:00:00 2001 From: Felix Roos Date: Fri, 7 Jul 2023 21:48:19 +0200 Subject: [PATCH] slice array notation --- packages/core/pattern.mjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core/pattern.mjs b/packages/core/pattern.mjs index b234c9d1..522b6238 100644 --- a/packages/core/pattern.mjs +++ b/packages/core/pattern.mjs @@ -2258,9 +2258,9 @@ export const slice = register( opat.outerBind((o) => { // If it's not an object, assume it's a string and make it a 's' control parameter o = o instanceof Object ? o : { s: o }; - // Remember we must stay pure and avoid editing the object directly - const toAdd = { begin: i / n, end: (i + 1) / n, _slices: n }; - return pure({ ...toAdd, ...o }); + const begin = Array.isArray(n) ? n[i] : i / n; + const end = Array.isArray(n) ? n[i + 1] : (i + 1) / n; + return pure({ begin, end, _slices: n, ...o }); }), ), );