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 14, 2024
1 parent 40a0012 commit a4c16af
Show file tree
Hide file tree
Showing 9 changed files with 177 additions and 86 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
64 changes: 64 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"name": "@baetheus/fun",
"version": "2.0.1",
"exports": {
"applicable": "./applicable.ts",
"array": "./array.ts",
"async": "./async.ts",
"async_either": "./async_either.ts",
"async_iterable": "./async_iterable.ts",
"bimappable": "./bimappable.ts",
"boolean": "./boolean.ts",
"combinable": "./combinable.ts",
"comparable": "./comparable.ts",
"composable": "./composable.ts",
"datum": "./datum.ts",
"decoder": "./decoder.ts",
"either": "./either.ts",
"failable": "./failable.ts",
"filterable": "./filterable.ts",
"flatmappable": "./flatmappable.ts",
"fn": "./fn.ts",
"fn_either": "./fn_either.ts",
"foldable": "./foldable.ts",
"identity": "./identity.ts",
"initializable": "./initializable.ts",
"iterable": "./iterable.ts",
"json_schema": "./json_schema.ts",
"kind": "./kind.ts",
"map": "./map.ts",
"mappable": "./mappable.ts",
"newtype": "./newtype.ts",
"nil": "./nil.ts",
"number": "./number.ts",
"optic": "./optic.ts",
"option": "./option.ts",
"pair": "./pair.ts",
"predicate": "./predicate.ts",
"premappable": "./premappable.ts",
"promise": "./promise.ts",
"record": "./record.ts",
"refinement": "./refinement.ts",
"schemable": "./schemable.ts",
"set": "./set.ts",
"showable": "./showable.ts",
"sortable": "./sortable.ts",
"state": "./state.ts",
"string": "./string.ts",
"sync": "./sync.ts",
"sync_either": "./sync_either.ts",
"these": "./these.ts",
"traversable": "./traversable.ts",
"tree": "./tree.ts",
"wrappable": "./wrappable.ts",
"contrib/fast-check": "./contrib/fast-check.ts",
"contrib/free": "./contrib/free.ts",
"contrib/generator": "./contrib/generator.ts",
"contrib/most": "./contrib/most.ts"
},
"include": [
"LICENSE",
"README.md",
"deno.json"
]
}
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
55 changes: 0 additions & 55 deletions mod.ts

This file was deleted.

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
3 changes: 3 additions & 0 deletions scripts/exports.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env zsh

for i in *.ts contrib/*.ts; do echo "\"${i:s/\.ts//}\": \"./$i\","; done
15 changes: 0 additions & 15 deletions scripts/mod.sh

This file was deleted.

0 comments on commit a4c16af

Please sign in to comment.