From f709f23aa9ab0010deee9e27d0ee7ae417f6451b Mon Sep 17 00:00:00 2001 From: EuAndreh Date: Wed, 6 Mar 2024 12:11:33 -0300 Subject: src/utils.mjs: Add first(), rest(), butlast() and last() --- src/utils.mjs | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/utils.mjs') diff --git a/src/utils.mjs b/src/utils.mjs index 7d27c0d..1080219 100644 --- a/src/utils.mjs +++ b/src/utils.mjs @@ -47,3 +47,8 @@ export const partial = (fn, ...startArgs) => export const strSortFn = (a, b) => a.localeCompare(b, "POSIX"); export const undefinedAsNull = x => x === undefined ? null : x; + +export const first = a => a[0]; +export const rest = a => a.slice(1); +export const butlast = a => a.slice(a, a.length - 1); +export const last = a => a[a.length - 1]; -- cgit v1.2.3