| Total Complexity | 0 |
| Complexity/F | 0 |
| Lines of Code | 24 |
| Function Count | 0 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Coverage | 60% |
| Changes | 0 | ||
| 1 | import * as t from 'io-ts'; |
||
| 2 | import {NonEmptyString} from 'io-ts-types/lib/NonEmptyString'; |
||
| 3 | 1 | import {Iso} from 'monocle-ts'; |
|
| 4 | import {ResourceIdentifierC} from './io/ResourceIdentifierC'; |
||
| 5 | |||
| 6 | export interface ResourceIdentifier extends t.TypeOf<typeof ResourceIdentifierC> { |
||
| 7 | } |
||
| 8 | |||
| 9 | 1 | export const ResourceIdentifier = { |
|
| 10 | iso: { |
||
| 11 | string: new Iso<ResourceIdentifier, string>( |
||
| 12 | 17 | s => `${s.type}:${s.id}`, |
|
| 13 | a => { |
||
| 14 | const strings = a.split(':'); |
||
| 15 | |||
| 16 | return { |
||
| 17 | type: strings[0] as NonEmptyString, |
||
| 18 | id: strings[1] as NonEmptyString |
||
| 19 | }; |
||
| 20 | } |
||
| 21 | ) |
||
| 22 | } |
||
| 23 | }; |
||
| 24 |