github
3356 of 3548 branches covered (94.59%)
Branch coverage included in aggregate %.
243 of 243 new or added lines in 35 files covered. (100.0%)
31205 of 32058 relevant lines covered (97.34%)
472.66 hits per line
1 |
import { createHash } from 'crypto'; |
22✔ |
2 |
import { ensure, isDefined, TinyType } from 'tiny-types'; |
22✔ |
3 |
|
22✔ |
4 |
/**
|
22✔ |
5 |
* @package |
22✔ |
6 |
*/ |
22✔ |
7 |
export class Hash extends TinyType { |
22✔ |
8 |
static of(value: string): Hash { |
|
9 |
return new Hash(createHash('sha1').update(value).digest('hex')); |
2,048✔ |
10 |
} |
2,048✔ |
11 |
|
22✔ |
12 |
constructor(public readonly value: string) { |
|
13 |
super(); |
2,048✔ |
14 |
ensure(this.constructor.name, value, isDefined());
|
2,048✔ |
15 |
} |
2,048✔ |
16 |
|
22✔ |
17 |
long(): string { |
22✔ |
18 |
return this.value; |
× |
19 |
} |
× |
20 |
|
22✔ |
21 |
short(): string { |
|
22 |
return this.value.slice(0, 10); |
2,048✔ |
23 |
} |
2,048✔ |
24 |
} |
22✔ |