Skip to content

Commit f0ce6ff

Browse files
authored
Try to avoid scroll in readme table (#49)
1 parent 3a40352 commit f0ce6ff

File tree

1 file changed

+101
-87
lines changed

1 file changed

+101
-87
lines changed

README.md

+101-87
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,14 @@ Here’s a summary of all codecs (with slightly simplified type annotations) and
178178
1,
179179
2,
180180
true
181-
]) =>
182-
Codec<
183-
"string1"
184-
| "string2"
185-
| "stringN"
186-
| 1
187-
| 2
188-
| true
189-
&gt;</pre></td>
181+
]) =&gt; Codec&lt;
182+
"string1"
183+
| "string2"
184+
| "stringN"
185+
| 1
186+
| 2
187+
| true
188+
&gt;</pre></td>
190189
<td>string, number, boolean, null</td>
191190
<td><pre>"string1"
192191
| "string2"
@@ -198,157 +197,172 @@ Here’s a summary of all codecs (with slightly simplified type annotations) and
198197
<tr>
199198
<th><a href="#array">array</a></th>
200199
<td><pre>(decoder: Codec&lt;T&gt;) =&gt;
201-
Codec&lt;Array&lt;T&gt;&gt;</pre></td>
200+
Codec&lt;Array&lt;T&gt;&gt;</pre></td>
202201
<td>array</td>
203202
<td><code>Array&lt;T&gt;</code></td>
204203
</tr>
205204
<tr>
206205
<th><a href="#record">record</a></th>
207206
<td><pre>(decoder: Codec&lt;T&gt;) =&gt;
208-
Codec&lt;Record&lt;string, T&gt;&gt;</pre></td>
207+
Codec&lt;Record&lt;string, T&gt;&gt;</pre></td>
209208
<td>object</td>
210209
<td><code>Record&lt;string, T&gt;</code></td>
211210
</tr>
212211
<tr>
213212
<th><a href="#fields">fields</a></th>
214213
<td><pre>(mapping: {
215-
field1: Codec&lt;T1&gt;,
216-
field2: Field&lt;T2, {optional: true}&gt;,
217-
field3: Field&lt;T3, {renameFrom: "field_3"}&gt;,
218-
fieldN: Codec&lt;TN&gt;
219-
}) =&gt;
220-
Codec&lt;{
221-
field1: T1,
222-
field2?: T2,
223-
field3: T3,
224-
fieldN: TN
225-
}&gt;</pre></td>
214+
field1: Codec&lt;T1&gt;,
215+
field2: Field&lt;
216+
T2,
217+
{ optional: true }
218+
&gt;,
219+
field3: Field&lt;
220+
T3,
221+
{ renameFrom: "field_3" }
222+
&gt;,
223+
fieldN: Codec&lt;TN&gt;
224+
}) =&gt; Codec&lt;{
225+
field1: T1,
226+
field2?: T2,
227+
field3: T3,
228+
fieldN: TN
229+
}&gt;</pre></td>
226230
<td><pre>{
227-
"field1": ...,
228-
"field2": ...,
229-
"field_3": ...,
230-
"fieldN": ...
231+
"field1": ...,
232+
"field2": ...,
233+
"field_3": ...,
234+
"fieldN": ...
231235
}</pre> or: <pre>{
232-
"field1": ...,
233-
"field_3": ...,
234-
"fieldN": ...
236+
"field1": ...,
237+
"field_3": ...,
238+
"fieldN": ...
235239
}</pre></td>
236240
<td><pre>{
237-
field1: T1,
238-
field2?: T2,
239-
field3: T3,
240-
fieldN: TN
241+
field1: T1,
242+
field2?: T2,
243+
field3: T3,
244+
fieldN: TN
241245
}</pre></td>
242246
</tr>
243247
<tr>
244248
<th><a href="#field">field</a></th>
245249
<td><pre>(
246-
codec: Codec&lt;Decoded&gt;,
247-
meta: Meta,
248-
) => Field&lt;Decoded, Meta&gt;</pre></td>
250+
codec: Codec&lt;Decoded&gt;,
251+
meta: Meta,
252+
) =&gt; Field&lt;Decoded, Meta&gt;</pre></td>
249253
<td>n/a</td>
250254
<td>n/a, only used with <code>fields</code></td>
251255
</tr>
252256
<tr>
253257
<th><a href="#taggedunion">taggedUnion</a></th>
254258
<td><pre>(
255-
decodedCommonField: string,
256-
variants: Array&lt;
257-
Parameters&lt;typeof fields&gt;[0]
258-
&gt;,
259-
) =&gt;
260-
Codec&lt;T1 | T2 | TN&gt;</pre></td>
259+
decodedCommonField: string,
260+
variants: Array&lt;
261+
Parameters&lt;typeof fields&gt;[0]
262+
&gt;,
263+
) =&gt; Codec&lt;T1 | T2 | TN&gt;</pre></td>
261264
<td>object</td>
262265
<td><code>T1 | T2 | TN</code></td>
263266
</tr>
264267
<tr>
265268
<th><a href="#tag">tag</a></th>
266269
<td><pre>(
267-
decoded: "string literal",
268-
options?: Options,
269-
) => Field&lt;"string literal", Meta&gt;</pre></td>
270+
decoded: "string literal",
271+
options?: Options,
272+
) =&gt;
273+
Field&lt;"string literal", Meta&gt;</pre></td>
270274
<td>string</td>
271275
<td><code>"string literal"</code></td>
272276
</tr>
273277
<tr>
274278
<th><a href="#tuple">tuple</a></th>
275279
<td><pre>(codecs: [
276-
Codec&lt;T1&gt;,
277-
Codec&lt;T2&gt;,
278-
Codec&lt;TN&gt;
279-
]) =&gt;
280-
Codec&lt;[T1, T2, TN]&gt;</pre></td>
280+
Codec&lt;T1&gt;,
281+
Codec&lt;T2&gt;,
282+
Codec&lt;TN&gt;
283+
]) =&gt; Codec&lt;[T1, T2, TN]&gt;</pre></td>
281284
<td>array</td>
282285
<td><code>[T1, T2, TN]</code></td>
283286
</tr>
284287
<tr>
285288
<th><a href="#multi">multi</a></th>
286289
<td><pre>(types: [
287-
"type1",
288-
"type2",
289-
"type10"
290-
]) =&gt;
291-
Codec&lt;
292-
{ type: "type1", value: type1 }
293-
| { type: "type2", value: type2 }
294-
| { type: "type10", value: type10 }
295-
&gt;</pre></td>
290+
"type1",
291+
"type2",
292+
"type10"
293+
]) =&gt; Codec&lt;
294+
{ type: "type1",
295+
value: type1 }
296+
| { type: "type2",
297+
value: type2 }
298+
| { type: "type10",
299+
value: type10 }
300+
&gt;</pre></td>
296301
<td>you decide</td>
297-
<td>A subset of: <pre>{ type: "undefined"; value: undefined }
298-
| { type: "null"; value: null }
299-
| { type: "boolean"; value: boolean }
300-
| { type: "number"; value: number }
301-
| { type: "bigint"; value: bigint }
302-
| { type: "string"; value: string }
303-
| { type: "symbol"; value: symbol }
304-
| { type: "function"; value: Function }
305-
| { type: "array"; value: Array<unknown> }
306-
| { type: "object"; value: Record<string, unknown> }</pre></td>
302+
<td>A subset of: <pre> { type: "undefined";
303+
value: undefined }
304+
| { type: "null";
305+
value: null }
306+
| { type: "boolean";
307+
value: boolean }
308+
| { type: "number";
309+
value: number }
310+
| { type: "bigint";
311+
value: bigint }
312+
| { type: "string";
313+
value: string }
314+
| { type: "symbol";
315+
value: symbol }
316+
| { type: "function";
317+
value: Function }
318+
| { type: "array";
319+
value: Array<unknown> }
320+
| { type: "object";
321+
value: Record<string, unknown> }</pre></td>
307322
</tr>
308323
<tr>
309324
<th><a href="#recursive">recursive</a></th>
310-
<td><pre>(callback: () => Codec&lt;T&gt;) =&gt;
311-
Codec&lt;T&gt;</pre></td>
325+
<td><pre>(callback: () =&gt; Codec&lt;T&gt;) =&gt;
326+
Codec&lt;T&gt;</pre></td>
312327
<td>n/a</td>
313328
<td><code>T</code></td>
314329
</tr>
315330
<tr>
316331
<th><a href="#undefinedor">undefinedOr</a></th>
317332
<td><pre>(codec: Codec&lt;T&gt;) =&gt;
318-
Codec&lt;T | undefined&gt;</pre></td>
333+
Codec&lt;T | undefined&gt;</pre></td>
319334
<td>undefined or …</td>
320335
<td><code>T | undefined</code></td>
321336
</tr>
322337
<tr>
323338
<th><a href="#nullOr">nullOr</a></th>
324339
<td><pre>(codec: Codec&lt;T&gt;) =&gt;
325-
Codec&lt;T | null&gt;</pre></td>
340+
Codec&lt;T | null&gt;</pre></td>
326341
<td>null or …</td>
327342
<td><code>T | null</code></td>
328343
</tr>
329344
<tr>
330345
<th><a href="#map">map</a></th>
331346
<td><pre>(
332-
codec: Codec&lt;T&gt;,
333-
transform: {
334-
decoder: (value: T) =&gt; U;
335-
encoder: (value: U) =&gt; T;
336-
},
337-
) =&gt;
338-
Codec&lt;U&gt;</pre></td>
347+
codec: Codec&lt;T&gt;,
348+
transform: {
349+
decoder: (value: T) =&gt; U;
350+
encoder: (value: U) =&gt; T;
351+
},
352+
) =&gt; Codec&lt;U&gt;</pre></td>
339353
<td>n/a</td>
340354
<td><code>U</code></td>
341355
</tr>
342356
<tr>
343357
<th><a href="#flatmap">flatMap</a></th>
344358
<td><pre>(
345-
decoder: Codec&lt;T&gt;,
346-
transform: {
347-
decoder: (value: T) =&gt; DecoderResult&lt;U&gt;;
348-
encoder: (value: U) =&gt; T;
349-
},
350-
) =&gt;
351-
Codec&lt;U&gt;</pre></td>
359+
decoder: Codec&lt;T&gt;,
360+
transform: {
361+
decoder: (value: T) =&gt;
362+
DecoderResult&lt;U&gt;;
363+
encoder: (value: U) =&gt; T;
364+
},
365+
) =&gt; Codec&lt;U&gt;</pre></td>
352366
<td>n/a</td>
353367
<td><code>U</code></td>
354368
</tr>

0 commit comments

Comments
 (0)