functional
This commit is contained in:
31
examples/basic.ts
Normal file
31
examples/basic.ts
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import { setFlag, globalStorage, initGlobalCache } from '..'
|
||||||
|
|
||||||
|
function modifyStorage() {
|
||||||
|
let storage = globalStorage()
|
||||||
|
storage.set({
|
||||||
|
a: 'aaaaa',
|
||||||
|
b: 'bbbbb',
|
||||||
|
c: 'ccccc',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
//change the storage directory
|
||||||
|
setFlag('dir', './data')
|
||||||
|
|
||||||
|
//initialize global cache with data
|
||||||
|
initGlobalCache({
|
||||||
|
a: 'aaa',
|
||||||
|
b: 'bbb',
|
||||||
|
})
|
||||||
|
|
||||||
|
//get an instance of the global cache
|
||||||
|
let storage = globalStorage()
|
||||||
|
console.log(storage.get())
|
||||||
|
|
||||||
|
//modify another instance of the global cache
|
||||||
|
modifyStorage()
|
||||||
|
console.log(storage.get())
|
||||||
|
}
|
||||||
|
|
||||||
|
main()
|
||||||
236
pnpm-lock.yaml
generated
236
pnpm-lock.yaml
generated
@@ -19,9 +19,11 @@ devDependencies:
|
|||||||
typescript: 4.6.3
|
typescript: 4.6.3
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
|
|
||||||
/@discordjs/builders/0.11.0:
|
/@discordjs/builders/0.11.0:
|
||||||
resolution: {integrity: sha512-ZTB8yJdJKrKlq44dpWkNUrAtEJEq0gqpb7ASdv4vmq6/mZal5kOv312hQ56I/vxwMre+VIkoHquNUAfnTbiYtg==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-ZTB8yJdJKrKlq44dpWkNUrAtEJEq0gqpb7ASdv4vmq6/mZal5kOv312hQ56I/vxwMre+VIkoHquNUAfnTbiYtg==,
|
||||||
|
}
|
||||||
engines: { node: '>=16.0.0', npm: '>=7.0.0' }
|
engines: { node: '>=16.0.0', npm: '>=7.0.0' }
|
||||||
dependencies:
|
dependencies:
|
||||||
'@sindresorhus/is': 4.6.0
|
'@sindresorhus/is': 4.6.0
|
||||||
@@ -32,39 +34,60 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@discordjs/collection/0.4.0:
|
/@discordjs/collection/0.4.0:
|
||||||
resolution: {integrity: sha512-zmjq+l/rV35kE6zRrwe8BHqV78JvIh2ybJeZavBi5NySjWXqN3hmmAKg7kYMMXSeiWtSsMoZ/+MQi0DiQWy2lw==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-zmjq+l/rV35kE6zRrwe8BHqV78JvIh2ybJeZavBi5NySjWXqN3hmmAKg7kYMMXSeiWtSsMoZ/+MQi0DiQWy2lw==,
|
||||||
|
}
|
||||||
engines: { node: '>=16.0.0', npm: '>=7.0.0' }
|
engines: { node: '>=16.0.0', npm: '>=7.0.0' }
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@sapphire/async-queue/1.3.0:
|
/@sapphire/async-queue/1.3.0:
|
||||||
resolution: {integrity: sha512-z+CDw5X4UgIEpZL8KM+ThVx1i8V60HBg0l/oFewTNbQQeRDJHdVxHyJykv+SF1H+Rc8EkMS81VTWo95jVYgO/g==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-z+CDw5X4UgIEpZL8KM+ThVx1i8V60HBg0l/oFewTNbQQeRDJHdVxHyJykv+SF1H+Rc8EkMS81VTWo95jVYgO/g==,
|
||||||
|
}
|
||||||
engines: { node: '>=v14.0.0', npm: '>=7.0.0' }
|
engines: { node: '>=v14.0.0', npm: '>=7.0.0' }
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@sindresorhus/is/4.6.0:
|
/@sindresorhus/is/4.6.0:
|
||||||
resolution: {integrity: sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==,
|
||||||
|
}
|
||||||
engines: { node: '>=10' }
|
engines: { node: '>=10' }
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@types/fs-extra/9.0.13:
|
/@types/fs-extra/9.0.13:
|
||||||
resolution: {integrity: sha512-nEnwB++1u5lVDM2UI4c1+5R+FYaKfaAzS4OococimjVm3nQw3TuzH5UNsocrcTBbhnerblyHj4A49qXbIiZdpA==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-nEnwB++1u5lVDM2UI4c1+5R+FYaKfaAzS4OococimjVm3nQw3TuzH5UNsocrcTBbhnerblyHj4A49qXbIiZdpA==,
|
||||||
|
}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/node': 17.0.23
|
'@types/node': 17.0.23
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@types/node-fetch/2.6.1:
|
/@types/node-fetch/2.6.1:
|
||||||
resolution: {integrity: sha512-oMqjURCaxoSIsHSr1E47QHzbmzNR5rK8McHuNb11BOM9cHcIK3Avy0s/b2JlXHoQGTYS3NsvWzV1M0iK7l0wbA==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-oMqjURCaxoSIsHSr1E47QHzbmzNR5rK8McHuNb11BOM9cHcIK3Avy0s/b2JlXHoQGTYS3NsvWzV1M0iK7l0wbA==,
|
||||||
|
}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/node': 17.0.23
|
'@types/node': 17.0.23
|
||||||
form-data: 3.0.1
|
form-data: 3.0.1
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@types/node/17.0.23:
|
/@types/node/17.0.23:
|
||||||
resolution: {integrity: sha512-UxDxWn7dl97rKVeVS61vErvw086aCYhDLyvRQZ5Rk65rZKepaFdm53GeqXaKBuOhED4e9uWq34IC3TdSdJJ2Gw==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-UxDxWn7dl97rKVeVS61vErvw086aCYhDLyvRQZ5Rk65rZKepaFdm53GeqXaKBuOhED4e9uWq34IC3TdSdJJ2Gw==,
|
||||||
|
}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/@types/ws/8.5.3:
|
/@types/ws/8.5.3:
|
||||||
resolution: {integrity: sha512-6YOoWjruKj1uLf3INHH7D3qTXwFfEsg1kf3c0uDdSBJwfa/llkwIjrAGV7j7mVgGNbzTQ3HiHKKDXl6bJPD97w==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-6YOoWjruKj1uLf3INHH7D3qTXwFfEsg1kf3c0uDdSBJwfa/llkwIjrAGV7j7mVgGNbzTQ3HiHKKDXl6bJPD97w==,
|
||||||
|
}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@types/node': 17.0.23
|
'@types/node': 17.0.23
|
||||||
dev: true
|
dev: true
|
||||||
@@ -74,7 +97,10 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/combined-stream/1.0.8:
|
/combined-stream/1.0.8:
|
||||||
resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==,
|
||||||
|
}
|
||||||
engines: { node: '>= 0.8' }
|
engines: { node: '>= 0.8' }
|
||||||
dependencies:
|
dependencies:
|
||||||
delayed-stream: 1.0.0
|
delayed-stream: 1.0.0
|
||||||
@@ -86,12 +112,18 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/discord-api-types/0.26.1:
|
/discord-api-types/0.26.1:
|
||||||
resolution: {integrity: sha512-T5PdMQ+Y1MEECYMV5wmyi9VEYPagEDEi4S0amgsszpWY0VB9JJ/hEvM6BgLhbdnKky4gfmZEXtEEtojN8ZKJQQ==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-T5PdMQ+Y1MEECYMV5wmyi9VEYPagEDEi4S0amgsszpWY0VB9JJ/hEvM6BgLhbdnKky4gfmZEXtEEtojN8ZKJQQ==,
|
||||||
|
}
|
||||||
engines: { node: '>=12' }
|
engines: { node: '>=12' }
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/discord.js/13.6.0:
|
/discord.js/13.6.0:
|
||||||
resolution: {integrity: sha512-tXNR8zgsEPxPBvGk3AQjJ9ljIIC6/LOPjzKwpwz8Y1Q2X66Vi3ZqFgRHYwnHKC0jC0F+l4LzxlhmOJsBZDNg9g==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-tXNR8zgsEPxPBvGk3AQjJ9ljIIC6/LOPjzKwpwz8Y1Q2X66Vi3ZqFgRHYwnHKC0jC0F+l4LzxlhmOJsBZDNg9g==,
|
||||||
|
}
|
||||||
engines: { node: '>=16.6.0', npm: '>=7.0.0' }
|
engines: { node: '>=16.6.0', npm: '>=7.0.0' }
|
||||||
dependencies:
|
dependencies:
|
||||||
'@discordjs/builders': 0.11.0
|
'@discordjs/builders': 0.11.0
|
||||||
@@ -110,7 +142,10 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/esbuild-android-64/0.14.28:
|
/esbuild-android-64/0.14.28:
|
||||||
resolution: {integrity: sha512-A52C3zq+9tNwCqZ+4kVLBxnk/WnrYM8P2+QNvNE9B6d2OVPs214lp3g6UyO+dKDhUdefhfPCuwkP8j2A/+szNA==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-A52C3zq+9tNwCqZ+4kVLBxnk/WnrYM8P2+QNvNE9B6d2OVPs214lp3g6UyO+dKDhUdefhfPCuwkP8j2A/+szNA==,
|
||||||
|
}
|
||||||
engines: { node: '>=12' }
|
engines: { node: '>=12' }
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [android]
|
os: [android]
|
||||||
@@ -119,7 +154,10 @@ packages:
|
|||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/esbuild-android-arm64/0.14.28:
|
/esbuild-android-arm64/0.14.28:
|
||||||
resolution: {integrity: sha512-sm0fDEGElZhMC3HLZeECI2juE4aG7uPfMBMqNUhy9CeX399Pz8rC6e78OXMXInGjSdEAwQmCOHmfsP7uv3Q8rA==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-sm0fDEGElZhMC3HLZeECI2juE4aG7uPfMBMqNUhy9CeX399Pz8rC6e78OXMXInGjSdEAwQmCOHmfsP7uv3Q8rA==,
|
||||||
|
}
|
||||||
engines: { node: '>=12' }
|
engines: { node: '>=12' }
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [android]
|
os: [android]
|
||||||
@@ -128,7 +166,10 @@ packages:
|
|||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/esbuild-darwin-64/0.14.28:
|
/esbuild-darwin-64/0.14.28:
|
||||||
resolution: {integrity: sha512-nzDd7mQ44FvsFHtOafZdBgn3Li5SMsnMnoz1J2MM37xJmR3wGNTFph88KypjHgWqwbxCI7MXS1U+sN4qDeeW6Q==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-nzDd7mQ44FvsFHtOafZdBgn3Li5SMsnMnoz1J2MM37xJmR3wGNTFph88KypjHgWqwbxCI7MXS1U+sN4qDeeW6Q==,
|
||||||
|
}
|
||||||
engines: { node: '>=12' }
|
engines: { node: '>=12' }
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [darwin]
|
os: [darwin]
|
||||||
@@ -137,7 +178,10 @@ packages:
|
|||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/esbuild-darwin-arm64/0.14.28:
|
/esbuild-darwin-arm64/0.14.28:
|
||||||
resolution: {integrity: sha512-XEq/bLR/glsUl+uGrBimQzOVs/CmwI833fXUhP9xrLI3IJ+rKyrZ5IA8u+1crOEf1LoTn8tV+hInmX6rGjbScw==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-XEq/bLR/glsUl+uGrBimQzOVs/CmwI833fXUhP9xrLI3IJ+rKyrZ5IA8u+1crOEf1LoTn8tV+hInmX6rGjbScw==,
|
||||||
|
}
|
||||||
engines: { node: '>=12' }
|
engines: { node: '>=12' }
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [darwin]
|
os: [darwin]
|
||||||
@@ -146,7 +190,10 @@ packages:
|
|||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/esbuild-freebsd-64/0.14.28:
|
/esbuild-freebsd-64/0.14.28:
|
||||||
resolution: {integrity: sha512-rTKLgUj/HEcPeE5XZ7IZwWpFx7IWMfprN7QRk/TUJE1s1Ipb58esboIesUpjirJz/BwrgHq+FDG9ChAI8dZAtQ==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-rTKLgUj/HEcPeE5XZ7IZwWpFx7IWMfprN7QRk/TUJE1s1Ipb58esboIesUpjirJz/BwrgHq+FDG9ChAI8dZAtQ==,
|
||||||
|
}
|
||||||
engines: { node: '>=12' }
|
engines: { node: '>=12' }
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [freebsd]
|
os: [freebsd]
|
||||||
@@ -155,7 +202,10 @@ packages:
|
|||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/esbuild-freebsd-arm64/0.14.28:
|
/esbuild-freebsd-arm64/0.14.28:
|
||||||
resolution: {integrity: sha512-sBffxD1UMOsB7aWMoExmipycjcy3HJGwmqE4GQZUTZvdiH4GhjgUiVdtPyt7kSCdL40JqnWQJ4b1l8Y51oCF4Q==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-sBffxD1UMOsB7aWMoExmipycjcy3HJGwmqE4GQZUTZvdiH4GhjgUiVdtPyt7kSCdL40JqnWQJ4b1l8Y51oCF4Q==,
|
||||||
|
}
|
||||||
engines: { node: '>=12' }
|
engines: { node: '>=12' }
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [freebsd]
|
os: [freebsd]
|
||||||
@@ -164,7 +214,10 @@ packages:
|
|||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/esbuild-linux-32/0.14.28:
|
/esbuild-linux-32/0.14.28:
|
||||||
resolution: {integrity: sha512-+Wxidh3fBEQ9kHcCsD4etlBTMb1n6QY2uXv3rFhVn88CY/JP782MhA57/ipLMY4kOLeSKEuFGN4rtjHuhmRMig==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-+Wxidh3fBEQ9kHcCsD4etlBTMb1n6QY2uXv3rFhVn88CY/JP782MhA57/ipLMY4kOLeSKEuFGN4rtjHuhmRMig==,
|
||||||
|
}
|
||||||
engines: { node: '>=12' }
|
engines: { node: '>=12' }
|
||||||
cpu: [ia32]
|
cpu: [ia32]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
@@ -173,7 +226,10 @@ packages:
|
|||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/esbuild-linux-64/0.14.28:
|
/esbuild-linux-64/0.14.28:
|
||||||
resolution: {integrity: sha512-7+xgsC4LvR6cnzaBdiljNnPDjbkwzahogN+S9uy9AoYw7ZjPnnXc6sjQAVCbqGb7MEgrWdpa6u/Tao79i4lWxg==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-7+xgsC4LvR6cnzaBdiljNnPDjbkwzahogN+S9uy9AoYw7ZjPnnXc6sjQAVCbqGb7MEgrWdpa6u/Tao79i4lWxg==,
|
||||||
|
}
|
||||||
engines: { node: '>=12' }
|
engines: { node: '>=12' }
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
@@ -182,7 +238,10 @@ packages:
|
|||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/esbuild-linux-arm/0.14.28:
|
/esbuild-linux-arm/0.14.28:
|
||||||
resolution: {integrity: sha512-L5isjmlLbh9E0WVllXiVETbScgMbth/+XkXQii1WwgO1RvLIfaGrVFz8d2n6EH/ImtgYxPYGx+OcvIKQBc91Rg==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-L5isjmlLbh9E0WVllXiVETbScgMbth/+XkXQii1WwgO1RvLIfaGrVFz8d2n6EH/ImtgYxPYGx+OcvIKQBc91Rg==,
|
||||||
|
}
|
||||||
engines: { node: '>=12' }
|
engines: { node: '>=12' }
|
||||||
cpu: [arm]
|
cpu: [arm]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
@@ -191,7 +250,10 @@ packages:
|
|||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/esbuild-linux-arm64/0.14.28:
|
/esbuild-linux-arm64/0.14.28:
|
||||||
resolution: {integrity: sha512-EjRHgwg+kgXABzyoPGPOPg4d5wZqRnZ/ZAxBDzLY+i6DS8OUfTSlZHWIOZzU4XF7125WxRBg9ULbrFJBl+57Eg==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-EjRHgwg+kgXABzyoPGPOPg4d5wZqRnZ/ZAxBDzLY+i6DS8OUfTSlZHWIOZzU4XF7125WxRBg9ULbrFJBl+57Eg==,
|
||||||
|
}
|
||||||
engines: { node: '>=12' }
|
engines: { node: '>=12' }
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
@@ -200,7 +262,10 @@ packages:
|
|||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/esbuild-linux-mips64le/0.14.28:
|
/esbuild-linux-mips64le/0.14.28:
|
||||||
resolution: {integrity: sha512-krx9SSg7yfiUKk64EmjefOyiEF6nv2bRE4um/LiTaQ6Y/6FP4UF3/Ou/AxZVyR154uSRq63xejcAsmswXAYRsw==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-krx9SSg7yfiUKk64EmjefOyiEF6nv2bRE4um/LiTaQ6Y/6FP4UF3/Ou/AxZVyR154uSRq63xejcAsmswXAYRsw==,
|
||||||
|
}
|
||||||
engines: { node: '>=12' }
|
engines: { node: '>=12' }
|
||||||
cpu: [mips64el]
|
cpu: [mips64el]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
@@ -209,7 +274,10 @@ packages:
|
|||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/esbuild-linux-ppc64le/0.14.28:
|
/esbuild-linux-ppc64le/0.14.28:
|
||||||
resolution: {integrity: sha512-LD0Xxu9g+DNuhsEBV5QuVZ4uKVBMup0xPIruLweuAf9/mHXFnaCuNXUBF5t0DxKl7GQ5MSioKtnb92oMo+QXEw==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-LD0Xxu9g+DNuhsEBV5QuVZ4uKVBMup0xPIruLweuAf9/mHXFnaCuNXUBF5t0DxKl7GQ5MSioKtnb92oMo+QXEw==,
|
||||||
|
}
|
||||||
engines: { node: '>=12' }
|
engines: { node: '>=12' }
|
||||||
cpu: [ppc64]
|
cpu: [ppc64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
@@ -218,7 +286,10 @@ packages:
|
|||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/esbuild-linux-riscv64/0.14.28:
|
/esbuild-linux-riscv64/0.14.28:
|
||||||
resolution: {integrity: sha512-L/DWfRh2P0vxq4Y+qieSNXKGdMg+e9Qe8jkbN2/8XSGYDTPzO2OcAxSujob4qIh7iSl+cknbXV+BvH0YFR0jbg==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-L/DWfRh2P0vxq4Y+qieSNXKGdMg+e9Qe8jkbN2/8XSGYDTPzO2OcAxSujob4qIh7iSl+cknbXV+BvH0YFR0jbg==,
|
||||||
|
}
|
||||||
engines: { node: '>=12' }
|
engines: { node: '>=12' }
|
||||||
cpu: [riscv64]
|
cpu: [riscv64]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
@@ -227,7 +298,10 @@ packages:
|
|||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/esbuild-linux-s390x/0.14.28:
|
/esbuild-linux-s390x/0.14.28:
|
||||||
resolution: {integrity: sha512-rrgxmsbmL8QQknWGnAL9bGJRQYLOi2AzXy5OTwfhxnj9eqjo5mSVbJXjgiq5LPUAMQZGdPH5yaNK0obAXS81Zw==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-rrgxmsbmL8QQknWGnAL9bGJRQYLOi2AzXy5OTwfhxnj9eqjo5mSVbJXjgiq5LPUAMQZGdPH5yaNK0obAXS81Zw==,
|
||||||
|
}
|
||||||
engines: { node: '>=12' }
|
engines: { node: '>=12' }
|
||||||
cpu: [s390x]
|
cpu: [s390x]
|
||||||
os: [linux]
|
os: [linux]
|
||||||
@@ -236,7 +310,10 @@ packages:
|
|||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/esbuild-netbsd-64/0.14.28:
|
/esbuild-netbsd-64/0.14.28:
|
||||||
resolution: {integrity: sha512-h8wntIyOR8/xMVVM6TvJxxWKh4AjmLK87IPKpuVi8Pq0kyk0RMA+eo4PFGk5j2XK0D7dj8PcSF5NSlP9kN/j0A==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-h8wntIyOR8/xMVVM6TvJxxWKh4AjmLK87IPKpuVi8Pq0kyk0RMA+eo4PFGk5j2XK0D7dj8PcSF5NSlP9kN/j0A==,
|
||||||
|
}
|
||||||
engines: { node: '>=12' }
|
engines: { node: '>=12' }
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [netbsd]
|
os: [netbsd]
|
||||||
@@ -245,7 +322,10 @@ packages:
|
|||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/esbuild-openbsd-64/0.14.28:
|
/esbuild-openbsd-64/0.14.28:
|
||||||
resolution: {integrity: sha512-HBv18rVapbuDx52/fhZ/c/w6TXyaQAvRxiDDn5Hz/pBcwOs3cdd2WxeIKlWmDoqm2JMx5EVlq4IWgoaRX9mVkw==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-HBv18rVapbuDx52/fhZ/c/w6TXyaQAvRxiDDn5Hz/pBcwOs3cdd2WxeIKlWmDoqm2JMx5EVlq4IWgoaRX9mVkw==,
|
||||||
|
}
|
||||||
engines: { node: '>=12' }
|
engines: { node: '>=12' }
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [openbsd]
|
os: [openbsd]
|
||||||
@@ -254,7 +334,10 @@ packages:
|
|||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/esbuild-sunos-64/0.14.28:
|
/esbuild-sunos-64/0.14.28:
|
||||||
resolution: {integrity: sha512-zlIxePhZxKYheR2vBCgPVvTixgo/ozOfOMoP6RZj8dxzquU1NgeyhjkcRXucbLCtmoNJ+i4PtWwPZTLuDd3bGg==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-zlIxePhZxKYheR2vBCgPVvTixgo/ozOfOMoP6RZj8dxzquU1NgeyhjkcRXucbLCtmoNJ+i4PtWwPZTLuDd3bGg==,
|
||||||
|
}
|
||||||
engines: { node: '>=12' }
|
engines: { node: '>=12' }
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [sunos]
|
os: [sunos]
|
||||||
@@ -263,7 +346,10 @@ packages:
|
|||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/esbuild-windows-32/0.14.28:
|
/esbuild-windows-32/0.14.28:
|
||||||
resolution: {integrity: sha512-am9DIJxXlld1BOAY/VlvBQHMUCPL7S3gB/lnXIY3M4ys0gfuRqPf4EvMwZMzYUbFKBY+/Qb8SRgPRRGhwnJ8Kg==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-am9DIJxXlld1BOAY/VlvBQHMUCPL7S3gB/lnXIY3M4ys0gfuRqPf4EvMwZMzYUbFKBY+/Qb8SRgPRRGhwnJ8Kg==,
|
||||||
|
}
|
||||||
engines: { node: '>=12' }
|
engines: { node: '>=12' }
|
||||||
cpu: [ia32]
|
cpu: [ia32]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
@@ -272,7 +358,10 @@ packages:
|
|||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/esbuild-windows-64/0.14.28:
|
/esbuild-windows-64/0.14.28:
|
||||||
resolution: {integrity: sha512-78PhySDnmRZlsPNp/W/5Fim8iivlBQQxfhBFIqR7xwvfDmCFUSByyMKP7LCHgNtb04yNdop8nJJkJaQ8Xnwgiw==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-78PhySDnmRZlsPNp/W/5Fim8iivlBQQxfhBFIqR7xwvfDmCFUSByyMKP7LCHgNtb04yNdop8nJJkJaQ8Xnwgiw==,
|
||||||
|
}
|
||||||
engines: { node: '>=12' }
|
engines: { node: '>=12' }
|
||||||
cpu: [x64]
|
cpu: [x64]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
@@ -281,7 +370,10 @@ packages:
|
|||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/esbuild-windows-arm64/0.14.28:
|
/esbuild-windows-arm64/0.14.28:
|
||||||
resolution: {integrity: sha512-VhXGBTo6HELD8zyHXynV6+L2jWx0zkKnGx4TmEdSBK7UVFACtOyfUqpToG0EtnYyRZ0HESBhzPSVpP781ovmvA==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-VhXGBTo6HELD8zyHXynV6+L2jWx0zkKnGx4TmEdSBK7UVFACtOyfUqpToG0EtnYyRZ0HESBhzPSVpP781ovmvA==,
|
||||||
|
}
|
||||||
engines: { node: '>=12' }
|
engines: { node: '>=12' }
|
||||||
cpu: [arm64]
|
cpu: [arm64]
|
||||||
os: [win32]
|
os: [win32]
|
||||||
@@ -290,7 +382,10 @@ packages:
|
|||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
/esbuild/0.14.28:
|
/esbuild/0.14.28:
|
||||||
resolution: {integrity: sha512-YLNprkCcMVKQ5sekmCKEQ3Obu/L7s6+iij38xNKyBeSmSsTWur4Ky/9zB3XIGT8SCJITG/bZwAR2l7YOAXch4Q==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-YLNprkCcMVKQ5sekmCKEQ3Obu/L7s6+iij38xNKyBeSmSsTWur4Ky/9zB3XIGT8SCJITG/bZwAR2l7YOAXch4Q==,
|
||||||
|
}
|
||||||
engines: { node: '>=12' }
|
engines: { node: '>=12' }
|
||||||
hasBin: true
|
hasBin: true
|
||||||
requiresBuild: true
|
requiresBuild: true
|
||||||
@@ -318,7 +413,10 @@ packages:
|
|||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/form-data/3.0.1:
|
/form-data/3.0.1:
|
||||||
resolution: {integrity: sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==,
|
||||||
|
}
|
||||||
engines: { node: '>= 6' }
|
engines: { node: '>= 6' }
|
||||||
dependencies:
|
dependencies:
|
||||||
asynckit: 0.4.0
|
asynckit: 0.4.0
|
||||||
@@ -327,7 +425,10 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/form-data/4.0.0:
|
/form-data/4.0.0:
|
||||||
resolution: {integrity: sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==,
|
||||||
|
}
|
||||||
engines: { node: '>= 6' }
|
engines: { node: '>= 6' }
|
||||||
dependencies:
|
dependencies:
|
||||||
asynckit: 0.4.0
|
asynckit: 0.4.0
|
||||||
@@ -336,7 +437,10 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/fs-extra/10.1.0:
|
/fs-extra/10.1.0:
|
||||||
resolution: {integrity: sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-oRXApq54ETRj4eMiFzGnHWGy+zo5raudjuxN0b8H7s/RU2oW0Wvsx9O0ACRN/kRq9E8Vu/ReskGB5o3ji+FzHQ==,
|
||||||
|
}
|
||||||
engines: { node: '>=12' }
|
engines: { node: '>=12' }
|
||||||
dependencies:
|
dependencies:
|
||||||
graceful-fs: 4.2.10
|
graceful-fs: 4.2.10
|
||||||
@@ -345,11 +449,17 @@ packages:
|
|||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/graceful-fs/4.2.10:
|
/graceful-fs/4.2.10:
|
||||||
resolution: {integrity: sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==,
|
||||||
|
}
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/jsonfile/6.1.0:
|
/jsonfile/6.1.0:
|
||||||
resolution: {integrity: sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==,
|
||||||
|
}
|
||||||
dependencies:
|
dependencies:
|
||||||
universalify: 2.0.0
|
universalify: 2.0.0
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
@@ -357,19 +467,28 @@ packages:
|
|||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/mime-db/1.52.0:
|
/mime-db/1.52.0:
|
||||||
resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==,
|
||||||
|
}
|
||||||
engines: { node: '>= 0.6' }
|
engines: { node: '>= 0.6' }
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/mime-types/2.1.35:
|
/mime-types/2.1.35:
|
||||||
resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==,
|
||||||
|
}
|
||||||
engines: { node: '>= 0.6' }
|
engines: { node: '>= 0.6' }
|
||||||
dependencies:
|
dependencies:
|
||||||
mime-db: 1.52.0
|
mime-db: 1.52.0
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/node-fetch/2.6.7:
|
/node-fetch/2.6.7:
|
||||||
resolution: {integrity: sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==,
|
||||||
|
}
|
||||||
engines: { node: 4.x || >=6.0.0 }
|
engines: { node: 4.x || >=6.0.0 }
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
encoding: ^0.1.0
|
encoding: ^0.1.0
|
||||||
@@ -381,7 +500,10 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/prettier/2.6.2:
|
/prettier/2.6.2:
|
||||||
resolution: {integrity: sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-PkUpF+qoXTqhOeWL9fu7As8LXsIUZ1WYaJiY/a7McAQzxjk82OF0tibkFXVCDImZtWxbvojFjerkiLb0/q8mew==,
|
||||||
|
}
|
||||||
engines: { node: '>=10.13.0' }
|
engines: { node: '>=10.13.0' }
|
||||||
hasBin: true
|
hasBin: true
|
||||||
dev: true
|
dev: true
|
||||||
@@ -391,21 +513,33 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/ts-mixer/6.0.1:
|
/ts-mixer/6.0.1:
|
||||||
resolution: {integrity: sha512-hvE+ZYXuINrx6Ei6D6hz+PTim0Uf++dYbK9FFifLNwQj+RwKquhQpn868yZsCtJYiclZF1u8l6WZxxKi+vv7Rg==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-hvE+ZYXuINrx6Ei6D6hz+PTim0Uf++dYbK9FFifLNwQj+RwKquhQpn868yZsCtJYiclZF1u8l6WZxxKi+vv7Rg==,
|
||||||
|
}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/tslib/2.3.1:
|
/tslib/2.3.1:
|
||||||
resolution: {integrity: sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-77EbyPPpMz+FRFRuAFlWMtmgUWGe9UOG2Z25NqCwiIjRhOf5iKGuzSe5P2w1laq+FkRy4p+PCuVkJSGkzTEKVw==,
|
||||||
|
}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/typescript/4.6.3:
|
/typescript/4.6.3:
|
||||||
resolution: {integrity: sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-yNIatDa5iaofVozS/uQJEl3JRWLKKGJKh6Yaiv0GLGSuhpFJe7P3SbHZ8/yjAHRQwKRoA6YZqlfjXWmVzoVSMw==,
|
||||||
|
}
|
||||||
engines: { node: '>=4.2.0' }
|
engines: { node: '>=4.2.0' }
|
||||||
hasBin: true
|
hasBin: true
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/universalify/2.0.0:
|
/universalify/2.0.0:
|
||||||
resolution: {integrity: sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==,
|
||||||
|
}
|
||||||
engines: { node: '>= 10.0.0' }
|
engines: { node: '>= 10.0.0' }
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
@@ -421,7 +555,10 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/ws/8.5.0:
|
/ws/8.5.0:
|
||||||
resolution: {integrity: sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-BWX0SWVgLPzYwF8lTzEy1egjhS4S4OEAHfsO8o65WOVsrnSRGaSiUaa9e0ggGlkMTtBlmOpEXiie9RUcBO86qg==,
|
||||||
|
}
|
||||||
engines: { node: '>=10.0.0' }
|
engines: { node: '>=10.0.0' }
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
bufferutil: ^4.0.1
|
bufferutil: ^4.0.1
|
||||||
@@ -434,5 +571,8 @@ packages:
|
|||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/zod/3.14.3:
|
/zod/3.14.3:
|
||||||
resolution: {integrity: sha512-OzwRCSXB1+/8F6w6HkYHdbuWysYWnAF4fkRgKDcSFc54CE+Sv0rHXKfeNUReGCrHukm1LNpi6AYeXotznhYJbQ==}
|
resolution:
|
||||||
|
{
|
||||||
|
integrity: sha512-OzwRCSXB1+/8F6w6HkYHdbuWysYWnAF4fkRgKDcSFc54CE+Sv0rHXKfeNUReGCrHukm1LNpi6AYeXotznhYJbQ==,
|
||||||
|
}
|
||||||
dev: true
|
dev: true
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
const Flags = {
|
const Flags = {
|
||||||
dir: './storage'
|
dir: './storage',
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setFlag<T extends keyof typeof Flags>(key: T, val: typeof Flags[T]) {
|
export function setFlag<T extends keyof typeof Flags>(
|
||||||
|
key: T,
|
||||||
|
val: typeof Flags[T]
|
||||||
|
) {
|
||||||
Flags[key] = val
|
Flags[key] = val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
import { Guild } from 'discord.js'
|
import { Guild } from 'discord.js'
|
||||||
import { readFileSync, writeFileSync, ensureDirSync, ensureFileSync } from 'fs-extra'
|
import {
|
||||||
|
readFileSync,
|
||||||
|
writeFileSync,
|
||||||
|
ensureDirSync,
|
||||||
|
ensureFileSync,
|
||||||
|
} from 'fs-extra'
|
||||||
import { getFlag } from './flags'
|
import { getFlag } from './flags'
|
||||||
|
|
||||||
type storageTypes = 'global' | Guild
|
type storageTypes = 'global' | Guild
|
||||||
|
|||||||
32
src/main.ts
32
src/main.ts
@@ -1,25 +1,7 @@
|
|||||||
import { setFlag } from "./flags";
|
export { setFlag } from './flags'
|
||||||
import { globalStorage, initGlobalCache } from './storage'
|
export {
|
||||||
|
globalStorage,
|
||||||
function test2() {
|
guildStorage,
|
||||||
let storage = globalStorage()
|
initGlobalCache,
|
||||||
storage.set({
|
initGuildCache,
|
||||||
a: 'aaaaa',
|
} from './storage'
|
||||||
b: 'bbbbb',
|
|
||||||
c: 'ccccc',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function test() {
|
|
||||||
setFlag('dir', './data')
|
|
||||||
initGlobalCache({
|
|
||||||
a: 'aaa',
|
|
||||||
b: 'bbb',
|
|
||||||
})
|
|
||||||
let storage = globalStorage()
|
|
||||||
console.log(storage.get())
|
|
||||||
test2()
|
|
||||||
console.log(storage.get())
|
|
||||||
}
|
|
||||||
|
|
||||||
test()
|
|
||||||
|
|||||||
@@ -14,7 +14,10 @@ export function initGlobalCache(defaultValue?: string | JSONObject) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initGuildCache(guild: Guild, defaultValue?: string | JSONObject) {
|
export function initGuildCache(
|
||||||
|
guild: Guild,
|
||||||
|
defaultValue?: string | JSONObject
|
||||||
|
) {
|
||||||
if (!GuildCache.has(guild.id)) {
|
if (!GuildCache.has(guild.id)) {
|
||||||
let data = readFile(guild)
|
let data = readFile(guild)
|
||||||
GuildCache.set(guild.id, defaultJson(data, defaultValue))
|
GuildCache.set(guild.id, defaultJson(data, defaultValue))
|
||||||
|
|||||||
@@ -3,8 +3,10 @@ export type JSONObject<Value = JSONDataTypes, Key extends string = string> = {
|
|||||||
[key in Key]: Value
|
[key in Key]: Value
|
||||||
}
|
}
|
||||||
|
|
||||||
export function defaultJson(data: string, defaultValue: string | JSONObject = '') {
|
export function defaultJson(
|
||||||
|
data: string,
|
||||||
|
defaultValue: string | JSONObject = ''
|
||||||
|
) {
|
||||||
if (data.length === 0) {
|
if (data.length === 0) {
|
||||||
//no existing data, give the default value instead
|
//no existing data, give the default value instead
|
||||||
|
|
||||||
@@ -13,7 +15,6 @@ export function defaultJson(data: string, defaultValue: string | JSONObject = ''
|
|||||||
} else {
|
} else {
|
||||||
return JSON.stringify(defaultValue)
|
return JSON.stringify(defaultValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (typeof defaultValue !== 'string') {
|
} else if (typeof defaultValue !== 'string') {
|
||||||
//existing data should be compared
|
//existing data should be compared
|
||||||
//nothing to compare if default value is string
|
//nothing to compare if default value is string
|
||||||
@@ -36,9 +37,7 @@ export function defaultJson(data: string, defaultValue: string | JSONObject = ''
|
|||||||
//couldn't parse data
|
//couldn't parse data
|
||||||
return JSON.stringify(defaultValue)
|
return JSON.stringify(defaultValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user