Skip to content

Commit

Permalink
fix: update some types in array.ts and add deno.json
Browse files Browse the repository at this point in the history
This is the first published release of fun as @baetheus/fun on jsr.io. Let's
hope it works great!
  • Loading branch information
baetheus committed Mar 10, 2024
1 parent 40a0012 commit ed15a76
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 16 deletions.
28 changes: 20 additions & 8 deletions array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -938,7 +938,9 @@ export function prepend<A>(
*
* @since 2.0.0
*/
export function insert<A>(value: A) {
export function insert<A>(
value: A,
): (index: number) => (arr: ReadonlyArray<A>) => ReadonlyArray<A> {
return (index: number) => (arr: ReadonlyArray<A>): ReadonlyArray<A> =>
index < 0 || index > arr.length ? arr : _unsafeInsertAt(index, value, arr);
}
Expand All @@ -965,7 +967,9 @@ export function insert<A>(value: A) {
*
* @since 2.0.0
*/
export function insertAt(index: number) {
export function insertAt(
index: number,
): <A>(value: A) => (arr: ReadonlyArray<A>) => ReadonlyArray<A> {
return <A>(value: A) => (arr: ReadonlyArray<A>): ReadonlyArray<A> =>
index < 0 || index > arr.length ? arr : _unsafeInsertAt(index, value, arr);
}
Expand All @@ -989,7 +993,9 @@ export function insertAt(index: number) {
*
* @since 2.0.0
*/
export function update<A>(value: A) {
export function update<A>(
value: A,
): (index: number) => (arr: ReadonlyArray<A>) => ReadonlyArray<A> {
return (index: number) => (arr: ReadonlyArray<A>): ReadonlyArray<A> =>
isOutOfBounds(index, arr) ? arr : _unsafeUpdateAt(index, value, arr);
}
Expand All @@ -1013,8 +1019,10 @@ export function update<A>(value: A) {
*
* @since 2.0.0
*/
export function updateAt(index: number) {
return <A>(value: A) => (arr: ReadonlyArray<A>): ReadonlyArray<A> =>
export function updateAt(
index: number,
): <A>(value: A) => (arr: ReadonlyArray<A>) => ReadonlyArray<A> {
return (value) => (arr) =>
isOutOfBounds(index, arr) ? arr : _unsafeUpdateAt(index, value, arr);
}

Expand Down Expand Up @@ -1063,7 +1071,9 @@ export function modify<A>(modifyFn: (a: A) => A) {
*
* @since 2.0.0
*/
export function modifyAt(index: number) {
export function modifyAt(
index: number,
): <A>(modifyFn: (a: A) => A) => (arr: ReadonlyArray<A>) => ReadonlyArray<A> {
return <A>(modifyFn: (a: A) => A) =>
(arr: ReadonlyArray<A>): ReadonlyArray<A> =>
isOutOfBounds(index, arr)
Expand Down Expand Up @@ -1092,7 +1102,7 @@ export function modifyAt(index: number) {
*
* @since 2.0.0
*/
export function lookup(index: number) {
export function lookup(index: number): <A>(arr: ReadonlyArray<A>) => Option<A> {
return <A>(as: ReadonlyArray<A>): Option<A> =>
isOutOfBounds(index, as) ? none : some(as[index]);
}
Expand Down Expand Up @@ -1505,7 +1515,9 @@ export const WrappableArray: Wrappable<KindArray> = { wrap };
/**
* @since 2.0.0
*/
export const tap = createTap(FlatmappableArray);
export const tap: <A>(
fa: (value: A) => void,
) => (ua: ReadonlyArray<A>) => ReadonlyArray<A> = createTap(FlatmappableArray);

/**
* @since 2.0.0
Expand Down
14 changes: 14 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "@baetheus/fun",
"version": "2.0.0",
"exports": "./mod.ts",
"publish": {
"include": [
"LICENSE",
"README.md",
"deno.json",
"*.ts",
"contrib/*.ts"
]
}
}
82 changes: 82 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
};

shell = with pkgs; mkShell {
buildInputs = [ deno nodejs jq lcov jujutsu ];
buildInputs = [ deno jq lcov ];
};

in
Expand Down
2 changes: 1 addition & 1 deletion scripts/coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ trap exiting SIGINT
rm -rf $OUTPUT_DIR
deno fmt
deno test --doc --parallel --coverage=$OUTPUT_DIR
deno coverage --unstable ./$OUTPUT_DIR --lcov > ./$OUTPUT_DIR/lcov.info
deno coverage ./$OUTPUT_DIR --lcov > ./$OUTPUT_DIR/lcov.info
genhtml ./$OUTPUT_DIR/lcov.info --output-directory $OUTPUT_DIR
darkhttpd ./$OUTPUT_DIR

0 comments on commit ed15a76

Please sign in to comment.