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