diff options
author | EuAndreh <eu@euandre.org> | 2024-03-06 12:11:33 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-03-06 12:11:33 -0300 |
commit | f709f23aa9ab0010deee9e27d0ee7ae417f6451b (patch) | |
tree | 206fbd92a130c80c58598b35a068b263206fc1a8 /src/utils.mjs | |
parent | src/hero.mjs: Add rmIf() and mkfifo() (diff) | |
download | papod-f709f23aa9ab0010deee9e27d0ee7ae417f6451b.tar.gz papod-f709f23aa9ab0010deee9e27d0ee7ae417f6451b.tar.xz |
src/utils.mjs: Add first(), rest(), butlast() and last()
Diffstat (limited to 'src/utils.mjs')
-rw-r--r-- | src/utils.mjs | 5 |
1 files changed, 5 insertions, 0 deletions
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]; |