diff options
author | Elizabeth Hunt <me@liz.coffee> | 2025-07-27 17:03:10 -0700 |
---|---|---|
committer | Elizabeth Hunt <me@liz.coffee> | 2025-07-27 18:30:30 -0700 |
commit | 9970036d203ba2d0a46b35ba6fad21d49441cdd4 (patch) | |
tree | a585d13933bf4149dcb07e28526063d071453105 /lib/leftpadesque/prepend.ts | |
download | pengueno-9970036d203ba2d0a46b35ba6fad21d49441cdd4.tar.gz pengueno-9970036d203ba2d0a46b35ba6fad21d49441cdd4.zip |
hai
Diffstat (limited to 'lib/leftpadesque/prepend.ts')
-rw-r--r-- | lib/leftpadesque/prepend.ts | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/leftpadesque/prepend.ts b/lib/leftpadesque/prepend.ts new file mode 100644 index 0000000..1819536 --- /dev/null +++ b/lib/leftpadesque/prepend.ts @@ -0,0 +1,5 @@ +export const prependWith = (arr: string[], prep: string) => + Array(arr.length * 2) + .fill(0) + .map((_, i) => i % 2 === 0) + .map((isPrep, i) => (isPrep ? prep : arr[Math.floor(i / 2)]!)); |