Skip to content

Commit

Permalink
refactor(transducers-patch): update reducer handling due to updates i…
Browse files Browse the repository at this point in the history
…n thi.ng/transducers pkg
  • Loading branch information
postspectacular committed Apr 3, 2024
1 parent 25ef274 commit a5d296e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions packages/transducers-patch/src/patch-array.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import type { PatchArrayOp } from "./api.js";
*/
export function patchArray<T>(
immutable?: boolean
): Reducer<T[], PatchArrayOp<T> | PatchArrayOp<T>[]>;
): Reducer<PatchArrayOp<T> | PatchArrayOp<T>[], T[]>;
export function patchArray<T>(
immutable: boolean,
init: T[],
Expand Down Expand Up @@ -88,7 +88,7 @@ export function patchArray<T>(...args: any[]) {

return patches
? reduce(patchArray<T>(immutable), init!, patches)
: reducer<T[], PatchArrayOp<T> | PatchArrayOp<T>[]>(
: reducer<PatchArrayOp<T> | PatchArrayOp<T>[], T[]>(
() => [],
(acc, x) => {
immutable && (acc = acc.slice());
Expand Down
4 changes: 2 additions & 2 deletions packages/transducers-patch/src/patch-obj.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type { PatchObjOp } from "./api.js";
* - UPDATE
* - DELETE
*/
export function patchObj(): Reducer<any, PatchObjOp>;
export function patchObj(): Reducer<PatchObjOp, any>;
export function patchObj(init: any, patches: Iterable<PatchObjOp>): any;
export function patchObj(init?: any, patches?: Iterable<PatchObjOp>) {
const edit = (acc: any, x: PatchObjOp) => {
Expand All @@ -33,7 +33,7 @@ export function patchObj(init?: any, patches?: Iterable<PatchObjOp>) {
};
return patches
? reduce(patchObj(), init, patches)
: reducer<any, PatchObjOp>(
: reducer<PatchObjOp, any>(
() => <any>{},
(acc, x) => {
if (isString(x[0])) {
Expand Down

0 comments on commit a5d296e

Please sign in to comment.