src/ResourceIdentifier.ts
last analyzed

Complexity

Total Complexity 0
Complexity/F 0

Size

Lines of Code 24
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 60%

Importance

Changes 0
Metric Value
wmc 0
eloc 17
mnd 0
bc 0
fnc 0
dl 0
loc 24
ccs 3
cts 5
cp 0.6
bpm 0
cpm 0
noi 0
c 0
b 0
f 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