Skip to content

Commit fd5f8db

Browse files
fix lint errors
1 parent 69b34df commit fd5f8db

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/codecTools/createDefaultCodec.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
import * as t from 'io-ts';
44

55
/**
6-
* Creates a default value for an io-ts codec. This is useful
7-
*
6+
* Creates a default value for an io-ts codec.
87
* @param codec - the codec whose default we want to create
98
* @returns an object honoring the io-ts codec
10-
*
119
* @example Use Case: CSV Generation from Typed Objects
1210
* Consider the following codec:
13-
*
11+
*
1412
* const UserCodec = t.intersection([
1513
* t.type({
1614
* id: t.string,
@@ -22,23 +20,22 @@ import * as t from 'io-ts';
2220
* ])
2321
*
2422
* Suppose we want to generate a CSV file from the objects below with UserCodec type:
25-
*
23+
*
2624
* const users = [
2725
* { id: '1', name: 'Alice', email: 'alice@email.com' },
2826
* { id: '2', name: 'Bob' },
2927
* ]
30-
*
28+
*
3129
* To generate a CSV, we need a consistent set of columns (headers) that includes
3230
* ALL possible fields, even if some objects don't have all properties. In the example
3331
* above, though, notice that the second user does not have the email property.
34-
*
32+
*
3533
* In such a case, createDefaultCodec(UserCodec) is useful to construct an object
3634
* with all possible fields, which can then be used to generate the complete CSV header:
3735
* "id,name,email".
38-
*
36+
*
3937
* The example above is pretty simple, but things get very compliated the more complex
4038
* is the codec. In any case, createDefaultCodec is useful for outputting the expected CSV header.
41-
*
4239
*/
4340
export const createDefaultCodec = <C extends t.Mixed>(
4441
codec: C,

0 commit comments

Comments
 (0)