diff options
Diffstat (limited to 'shared/extra-utils')
-rw-r--r-- | shared/extra-utils/crypto.ts | 20 | ||||
-rw-r--r-- | shared/extra-utils/file.ts | 11 | ||||
-rw-r--r-- | shared/extra-utils/index.ts | 3 | ||||
-rw-r--r-- | shared/extra-utils/uuid.ts | 32 |
4 files changed, 0 insertions, 66 deletions
diff --git a/shared/extra-utils/crypto.ts b/shared/extra-utils/crypto.ts deleted file mode 100644 index 1a583f1a0..000000000 --- a/shared/extra-utils/crypto.ts +++ /dev/null | |||
@@ -1,20 +0,0 @@ | |||
1 | import { BinaryToTextEncoding, createHash } from 'crypto' | ||
2 | |||
3 | function sha256 (str: string | Buffer, encoding: BinaryToTextEncoding = 'hex') { | ||
4 | return createHash('sha256').update(str).digest(encoding) | ||
5 | } | ||
6 | |||
7 | function sha1 (str: string | Buffer, encoding: BinaryToTextEncoding = 'hex') { | ||
8 | return createHash('sha1').update(str).digest(encoding) | ||
9 | } | ||
10 | |||
11 | // high excluded | ||
12 | function randomInt (low: number, high: number) { | ||
13 | return Math.floor(Math.random() * (high - low) + low) | ||
14 | } | ||
15 | |||
16 | export { | ||
17 | randomInt, | ||
18 | sha256, | ||
19 | sha1 | ||
20 | } | ||
diff --git a/shared/extra-utils/file.ts b/shared/extra-utils/file.ts deleted file mode 100644 index 8060ab520..000000000 --- a/shared/extra-utils/file.ts +++ /dev/null | |||
@@ -1,11 +0,0 @@ | |||
1 | import { stat } from 'fs-extra' | ||
2 | |||
3 | async function getFileSize (path: string) { | ||
4 | const stats = await stat(path) | ||
5 | |||
6 | return stats.size | ||
7 | } | ||
8 | |||
9 | export { | ||
10 | getFileSize | ||
11 | } | ||
diff --git a/shared/extra-utils/index.ts b/shared/extra-utils/index.ts deleted file mode 100644 index d4cfcbec8..000000000 --- a/shared/extra-utils/index.ts +++ /dev/null | |||
@@ -1,3 +0,0 @@ | |||
1 | export * from './crypto' | ||
2 | export * from './file' | ||
3 | export * from './uuid' | ||
diff --git a/shared/extra-utils/uuid.ts b/shared/extra-utils/uuid.ts deleted file mode 100644 index f3c80e046..000000000 --- a/shared/extra-utils/uuid.ts +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | import short, { uuid } from 'short-uuid' | ||
2 | |||
3 | const translator = short() | ||
4 | |||
5 | function buildUUID () { | ||
6 | return uuid() | ||
7 | } | ||
8 | |||
9 | function uuidToShort (uuid: string) { | ||
10 | if (!uuid) return uuid | ||
11 | |||
12 | return translator.fromUUID(uuid) | ||
13 | } | ||
14 | |||
15 | function shortToUUID (shortUUID: string) { | ||
16 | if (!shortUUID) return shortUUID | ||
17 | |||
18 | return translator.toUUID(shortUUID) | ||
19 | } | ||
20 | |||
21 | function isShortUUID (value: string) { | ||
22 | if (!value) return false | ||
23 | |||
24 | return value.length === translator.maxLength | ||
25 | } | ||
26 | |||
27 | export { | ||
28 | buildUUID, | ||
29 | uuidToShort, | ||
30 | shortToUUID, | ||
31 | isShortUUID | ||
32 | } | ||