Skip to content

Commit be3e78e

Browse files
committed
feat(push): add push function
1 parent 4238f37 commit be3e78e

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
@@ -74,6 +74,14 @@ export function tail<T>(array: ArrayLike<T>): T[] {
7474
return nativeSlice.call(array, 1);
7575
}
7676

77+
export function push<T>(array: ArrayLike<T>, value: T): T[] {
78+
return [...coerce(array), value];
79+
}
80+
81+
export function pushFn<T>(value: T): (array: ArrayLike<T>) => T[] {
82+
return array => push(array, value);
83+
}
84+
7785
export function initial<T>(array: ArrayLike<T>): T[] {
7886
return array.length === 0 ? [] : nativeSlice.call(array, 0, array.length - 1);
7987
}

0 commit comments

Comments
 (0)