Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
common
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
npm
common
Commits
635a1aae
Commit
635a1aae
authored
Jan 24, 2019
by
Vladislav Lagunov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Упрощение декодеров
parent
66f77534
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
9 deletions
+4
-9
decoder/index.ts
+4
-9
No files found.
decoder/index.ts
View file @
635a1aae
...
@@ -328,14 +328,9 @@ export { anyDecoder as any, stringDecoder as string, booleanDecoder as boolean,
...
@@ -328,14 +328,9 @@ export { anyDecoder as any, stringDecoder as string, booleanDecoder as boolean,
* Сопоставление с несколькими декодерами до первого успешного
* Сопоставление с несколькими декодерами до первого успешного
* сравнвния
* сравнвния
*/
*/
export
function
oneOf
<
A
>
(
a
:
Decoder
<
A
>
):
OneOf
<
A
>
;
export
function
oneOf
<
XS
extends
Decoder
<
any
>
[]
>
(...
array
:
XS
):
OneOf
<
XS
[
number
][
'_A'
]
>
;
export
function
oneOf
<
A
,
B
>
(
a
:
Decoder
<
A
>
,
b
:
Decoder
<
B
>
):
OneOf
<
A
|
B
>
;
export
function
oneOf
<
XS
extends
Decoder
<
any
>
[]
>
(
array
:
XS
):
OneOf
<
XS
[
number
][
'_A'
]
>
;
export
function
oneOf
<
A
,
B
,
C
>
(
a
:
Decoder
<
A
>
,
b
:
Decoder
<
B
>
,
c
:
Decoder
<
C
>
):
OneOf
<
A
|
B
|
C
>
;
export
function
oneOf
():
OneOf
<
any
>
{
export
function
oneOf
<
A
,
B
,
C
,
D
>
(
a
:
Decoder
<
A
>
,
b
:
Decoder
<
B
>
,
c
:
Decoder
<
C
>
,
d
:
Decoder
<
D
>
):
OneOf
<
A
|
B
|
C
|
D
>
;
export
function
oneOf
<
A
,
B
,
C
,
D
,
E
>
(
a
:
Decoder
<
A
>
,
b
:
Decoder
<
B
>
,
c
:
Decoder
<
C
>
,
d
:
Decoder
<
D
>
,
e
:
Decoder
<
E
>
):
OneOf
<
A
|
B
|
C
|
D
|
E
>
;
export
function
oneOf
<
A
,
B
,
C
,
D
,
E
,
F
>
(
a
:
Decoder
<
A
>
,
b
:
Decoder
<
B
>
,
c
:
Decoder
<
C
>
,
d
:
Decoder
<
D
>
,
e
:
Decoder
<
E
>
,
f
:
Decoder
<
F
>
):
OneOf
<
A
|
B
|
C
|
D
|
E
|
F
>
;
export
function
oneOf
<
array
extends
Decoder
<
any
>
[]
>
(
array
:
array
):
Decoder
<
array
[
number
][
'_A'
]
>
;
export
function
oneOf
():
Decoder
<
any
>
{
const
decoders
=
Array
.
isArray
(
arguments
[
0
])
?
arguments
[
0
]
:
Array
.
prototype
.
slice
.
call
(
arguments
);
const
decoders
=
Array
.
isArray
(
arguments
[
0
])
?
arguments
[
0
]
:
Array
.
prototype
.
slice
.
call
(
arguments
);
return
new
OneOf
(
decoders
);
return
new
OneOf
(
decoders
);
}
}
...
@@ -345,7 +340,7 @@ export function array<A>(decoder: Decoder<A>): Decoder<A[]> {
...
@@ -345,7 +340,7 @@ export function array<A>(decoder: Decoder<A>): Decoder<A[]> {
return
new
ArrayDecoder
(
decoder
);
return
new
ArrayDecoder
(
decoder
);
}
}
export
function
record
<
fields
extends
{
[
k
:
string
]:
Decoder
<
any
>
}
>
(
fields
:
fields
):
RecordDecoder
<
{[
k
in
keyof
fields
]:
fields
[
k
][
'_A'
]
}
>
{
export
function
record
<
T
>
(
fields
:
{
[
K
in
keyof
T
]:
Decoder
<
T
[
K
]
>
}):
RecordDecoder
<
T
>
{
return
new
RecordDecoder
(
fields
);
return
new
RecordDecoder
(
fields
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment