Skip to content

Commit 06b0e9a

Browse files
committed
feat(unshift): add unshift function
1 parent be3e78e commit 06b0e9a

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ export function pushFn<T>(value: T): (array: ArrayLike<T>) => T[] {
8282
return array => push(array, value);
8383
}
8484

85+
export function unshift<T>(array: ArrayLike<T>, value: T): T[] {
86+
return [value, ...coerce(array)];
87+
}
88+
89+
export function unshiftFn<T>(value: T): (array: ArrayLike<T>) => T[] {
90+
return array => unshift(array, value);
91+
}
92+
8593
export function initial<T>(array: ArrayLike<T>): T[] {
8694
return array.length === 0 ? [] : nativeSlice.call(array, 0, array.length - 1);
8795
}

0 commit comments

Comments
 (0)