-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8dd0b52
commit 0dc0392
Showing
19 changed files
with
307 additions
and
90 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,22 @@ | ||
import type { Some } from "fp-ts/Option"; | ||
import type { Option } from "fp-ts/Option"; | ||
import type { AtPath } from "../util/AtPath"; | ||
import type { Build } from "../util/Build"; | ||
import type { Paths } from "../util/Paths"; | ||
import type { GiveOpt, HasOptional } from "../util/predicates"; | ||
import { AddDots } from "../util/segments"; | ||
import { AddNullSegments } from "../util/segments"; | ||
|
||
export type Get = < | ||
Infer, | ||
Path extends unknown extends Infer ? string : Paths<Infer>, | ||
Ret extends unknown extends Infer ? unknown : GiveOpt<AtPath<Infer, AddDots<Path>>, AddDots<Path>> | ||
Ret extends unknown extends Infer ? unknown : GiveOpt<AtPath<Infer, AddNullSegments<Path>>, AddNullSegments<Path>> | ||
>( | ||
path: Path & string | ||
) => unknown extends Infer | ||
? unknown extends Ret | ||
? <Constructed extends Build<Path, unknown>>( | ||
obj: Constructed | ||
) => GiveOpt<AtPath<Constructed, AddDots<Path>>, AddDots<Path>> | ||
) => GiveOpt<AtPath<Constructed, AddNullSegments<Path>>, AddNullSegments<Path>> | ||
: true extends HasOptional<Path> | ||
? (obj: Build<Path, OptionType<Ret>>) => Ret | ||
? (obj: Build<Path, [Ret] extends [Option<infer A>] ? A : unknown>) => Ret | ||
: (obj: Build<Path, Ret>) => Ret | ||
: (obj: Infer) => Ret; | ||
|
||
type OptionType<S> = Extract<S, Some<unknown>>["value"]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
import type { Paths } from "../util/Paths"; | ||
import type { AtPath } from "../util/AtPath"; | ||
import { AddDots } from "../util/segments"; | ||
import { AddNullSegments } from "../util/segments"; | ||
|
||
export type Modify = <Infer, Path extends Paths<Infer>>( | ||
path: Path & string, | ||
modFunc: (v: AtPath<Infer, AddDots<Path>, "no-traversals">) => AtPath<Infer, AddDots<Path>, "no-traversals"> | ||
modFunc: ( | ||
v: AtPath<Infer, AddNullSegments<Path>, "no-traversals"> | ||
) => AtPath<Infer, AddNullSegments<Path>, "no-traversals"> | ||
) => (a: Infer) => Infer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import type { AtPath } from "../util/AtPath"; | ||
import type { Paths } from "../util/Paths"; | ||
import type { GiveOpt } from "../util/predicates"; | ||
import { AddDots } from "../util/segments"; | ||
import { AddNullSegments } from "../util/segments"; | ||
|
||
export type ModifyOption = <Infer, Path extends Paths<Infer>>( | ||
path: Path & string, | ||
modFunc: (v: AtPath<Infer, AddDots<Path>, "no-traversals">) => AtPath<Infer, AddDots<Path>, "no-traversals"> | ||
) => (a: Infer) => GiveOpt<Infer, AddDots<Path>>; | ||
modFunc: ( | ||
v: AtPath<Infer, AddNullSegments<Path>, "no-traversals"> | ||
) => AtPath<Infer, AddNullSegments<Path>, "no-traversals"> | ||
) => (a: Infer) => GiveOpt<Infer, AddNullSegments<Path>>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import type { Paths } from "../util/Paths"; | ||
import type { Build } from "../util/Build"; | ||
import { AtPath } from "../util/AtPath"; | ||
import { AddDots } from "../util/segments"; | ||
import { AddNullSegments } from "../util/segments"; | ||
|
||
export type Rename = <Infer, Path extends Paths<Infer, "dynamic">, NewKey extends string>( | ||
fullPath: Path & string, | ||
newKey: NewKey | ||
) => (a: Infer) => Build<Path, AtPath<Infer, AddDots<Path>>, Infer, NewKey>; | ||
) => (a: Infer) => Build<Path, AtPath<Infer, AddNullSegments<Path>>, Infer, NewKey>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import type { AtPath } from "../util/AtPath"; | ||
import type { Paths } from "../util/Paths"; | ||
import { AddDots } from "../util/segments"; | ||
import { AddNullSegments } from "../util/segments"; | ||
|
||
export type Set = <Infer, Path extends Paths<Infer>, Val extends AtPath<Infer, AddDots<Path>, "no-traversals">>( | ||
export type Set = <Infer, Path extends Paths<Infer>, Val extends AtPath<Infer, AddNullSegments<Path>, "no-traversals">>( | ||
path: Path & string, | ||
val: Val | ||
) => (obj: Infer) => Infer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
import type { AtPath } from "../util/AtPath"; | ||
import type { Paths } from "../util/Paths"; | ||
import type { GiveOpt } from "../util/predicates"; | ||
import { AddDots } from "../util/segments"; | ||
import { AddNullSegments } from "../util/segments"; | ||
|
||
export type SetOption = <Infer, Path extends Paths<Infer>, Val extends AtPath<Infer, AddDots<Path>, "no-traversals">>( | ||
export type SetOption = < | ||
Infer, | ||
Path extends Paths<Infer>, | ||
Val extends AtPath<Infer, AddNullSegments<Path>, "no-traversals"> | ||
>( | ||
path: Path & string, | ||
val: Val | ||
) => (obj: Infer) => GiveOpt<Infer, Path>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.