aboutsummaryrefslogtreecommitdiffhomepage
path: root/shared/extra-utils
diff options
context:
space:
mode:
Diffstat (limited to 'shared/extra-utils')
-rw-r--r--shared/extra-utils/crypto.ts20
-rw-r--r--shared/extra-utils/file.ts11
-rw-r--r--shared/extra-utils/index.ts3
-rw-r--r--shared/extra-utils/uuid.ts32
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 @@
1import { BinaryToTextEncoding, createHash } from 'crypto'
2
3function sha256 (str: string | Buffer, encoding: BinaryToTextEncoding = 'hex') {
4 return createHash('sha256').update(str).digest(encoding)
5}
6
7function sha1 (str: string | Buffer, encoding: BinaryToTextEncoding = 'hex') {
8 return createHash('sha1').update(str).digest(encoding)
9}
10
11// high excluded
12function randomInt (low: number, high: number) {
13 return Math.floor(Math.random() * (high - low) + low)
14}
15
16export {
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 @@
1import { stat } from 'fs-extra'
2
3async function getFileSize (path: string) {
4 const stats = await stat(path)
5
6 return stats.size
7}
8
9export {
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 @@
1export * from './crypto'
2export * from './file'
3export * 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 @@
1import short, { uuid } from 'short-uuid'
2
3const translator = short()
4
5function buildUUID () {
6 return uuid()
7}
8
9function uuidToShort (uuid: string) {
10 if (!uuid) return uuid
11
12 return translator.fromUUID(uuid)
13}
14
15function shortToUUID (shortUUID: string) {
16 if (!shortUUID) return shortUUID
17
18 return translator.toUUID(shortUUID)
19}
20
21function isShortUUID (value: string) {
22 if (!value) return false
23
24 return value.length === translator.maxLength
25}
26
27export {
28 buildUUID,
29 uuidToShort,
30 shortToUUID,
31 isShortUUID
32}