Compare commits
47 Commits
Author | SHA1 | Date | |
---|---|---|---|
0a775f919b | |||
7063b80bdd | |||
f3049160b6 | |||
e21273ddb2 | |||
8d3b427c1b | |||
87857a01c5 | |||
535e579b43 | |||
2934f86530 | |||
0693397164 | |||
2a878b7962 | |||
7b2d4ba119 | |||
1a4e732fd5 | |||
3a039c935f | |||
ac5b0b8b41 | |||
3f85c9cf7d | |||
1eff60e7dd | |||
1d9ad2ef63 | |||
973a884b3e | |||
6f60f8bd94 | |||
07606cd996 | |||
3ca956e531 | |||
9350c837e5 | |||
86196c3feb | |||
0985ff145e | |||
7cd717fc7d | |||
2fe8cdb96a | |||
34c2df7a1a | |||
1d5509a078 | |||
9f57b93a9f | |||
d0e9cbcaa6 | |||
67b314b507 | |||
f5d66f0d8f | |||
18c4366866 | |||
d9844797ec | |||
9ae28849e3 | |||
7324e89ad8 | |||
65f8414a5c | |||
86d2d34615 | |||
be8c297c47 | |||
85fc5f3017 | |||
c8ccc19996 | |||
77e6a40261 | |||
3deb536323 | |||
f6b0e63751 | |||
d52f9cfdc3 | |||
0ffe3d6b13 | |||
d4bd054953 |
63
.github/workflows/build.yaml
vendored
63
.github/workflows/build.yaml
vendored
@ -9,39 +9,28 @@ jobs:
|
|||||||
build:
|
build:
|
||||||
name: Build NPM Project
|
name: Build NPM Project
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container: node:20-alpine
|
||||||
image: node
|
|
||||||
volumes:
|
|
||||||
- '/mnt/swarm/gitea/runner/cache:/cache'
|
|
||||||
steps:
|
steps:
|
||||||
- name: Clone Repository
|
- name: Clone Repository
|
||||||
uses: ztimson/actions/clone@develop
|
uses: ztimson/actions/clone@develop
|
||||||
|
|
||||||
- name: Restore node_modules
|
- name: Install & Build
|
||||||
uses: ztimson/actions/cache/restore@develop
|
run: |
|
||||||
with:
|
npm i
|
||||||
key: node_modules
|
npm run build
|
||||||
|
|
||||||
- name: Install Dependencies
|
|
||||||
run: npm i
|
|
||||||
|
|
||||||
- name: Build Project
|
|
||||||
run: npm run build
|
|
||||||
|
|
||||||
- name: Test
|
- name: Test
|
||||||
run: npm run test:coverage
|
run: npm run test:coverage
|
||||||
|
|
||||||
- name: Cache node_modules
|
- name: Upload to Registry
|
||||||
uses: ztimson/actions/cache@develop
|
uses: ztimson/actions/npm/publish@develop
|
||||||
with:
|
|
||||||
key: node_modules
|
|
||||||
pattern: node_modules
|
|
||||||
|
|
||||||
- name: Cache Artifacts
|
- name: Upload to NPM
|
||||||
uses: ztimson/actions/cache@develop
|
uses: ztimson/actions/npm/publish@develop
|
||||||
with:
|
with:
|
||||||
key: dist
|
owner: ztimson
|
||||||
pattern: dist
|
registry: https://registry.npmjs.org/
|
||||||
|
token: ${{secrets.NPM_TOKEN}}
|
||||||
tag:
|
tag:
|
||||||
name: Tag Version
|
name: Tag Version
|
||||||
needs: build
|
needs: build
|
||||||
@ -59,31 +48,3 @@ jobs:
|
|||||||
uses: ztimson/actions/tag@develop
|
uses: ztimson/actions/tag@develop
|
||||||
with:
|
with:
|
||||||
tag: ${{env.VERSION}}
|
tag: ${{env.VERSION}}
|
||||||
|
|
||||||
publish:
|
|
||||||
name: Publish
|
|
||||||
needs: build
|
|
||||||
if: ${{github.ref_name}} == 'release'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
container:
|
|
||||||
image: node
|
|
||||||
volumes:
|
|
||||||
- '/mnt/swarm/gitea/runner/cache:/cache'
|
|
||||||
steps:
|
|
||||||
- name: Clone Repository
|
|
||||||
uses: ztimson/actions/clone@develop
|
|
||||||
|
|
||||||
- name: Restore Artifacts
|
|
||||||
uses: ztimson/actions/cache/restore@develop
|
|
||||||
with:
|
|
||||||
key: dist
|
|
||||||
|
|
||||||
- name: Upload to Registry
|
|
||||||
uses: ztimson/actions/npm/publish@develop
|
|
||||||
|
|
||||||
- name: Upload to NPM
|
|
||||||
uses: ztimson/actions/npm/publish@develop
|
|
||||||
with:
|
|
||||||
owner: ztimson
|
|
||||||
registry: https://registry.npmjs.org/
|
|
||||||
token: ${{secrets.NPM_TOKEN}}
|
|
||||||
|
363
package-lock.json
generated
363
package-lock.json
generated
@ -1,16 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "@ztimson/js-utilities",
|
"name": "@ztimson/utils",
|
||||||
"version": "0.2.1",
|
"version": "0.10.4",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@ztimson/js-utilities",
|
"name": "@ztimson/utils",
|
||||||
"version": "0.2.1",
|
"version": "0.10.4",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^29.5.12",
|
"@types/jest": "^29.5.12",
|
||||||
"@types/node": "^18.14.0",
|
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
"jest-junit": "^16.0.0",
|
"jest-junit": "^16.0.0",
|
||||||
"ts-jest": "^29.1.2",
|
"ts-jest": "^29.1.2",
|
||||||
@ -688,9 +687,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/aix-ppc64": {
|
"node_modules/@esbuild/aix-ppc64": {
|
||||||
"version": "0.19.12",
|
"version": "0.20.2",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.19.12.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.20.2.tgz",
|
||||||
"integrity": "sha512-bmoCYyWdEL3wDQIVbcyzRyeKLgk2WtWLTWz1ZIAZF/EGbNOwSA6ew3PftJ1PqMiOOGu0OyFMzG53L0zqIpPeNA==",
|
"integrity": "sha512-D+EBOJHXdNZcLJRBkhENNG8Wji2kgc9AZ9KiPr1JuZjsNtyHzrsfLRrY0tk2H2aoFu6RANO1y1iPPUCDYWkb5g==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"ppc64"
|
"ppc64"
|
||||||
],
|
],
|
||||||
@ -704,9 +703,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/android-arm": {
|
"node_modules/@esbuild/android-arm": {
|
||||||
"version": "0.19.12",
|
"version": "0.20.2",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.19.12.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.20.2.tgz",
|
||||||
"integrity": "sha512-qg/Lj1mu3CdQlDEEiWrlC4eaPZ1KztwGJ9B6J+/6G+/4ewxJg7gqj8eVYWvao1bXrqGiW2rsBZFSX3q2lcW05w==",
|
"integrity": "sha512-t98Ra6pw2VaDhqNWO2Oph2LXbz/EJcnLmKLGBJwEwXX/JAN83Fym1rU8l0JUWK6HkIbWONCSSatf4sf2NBRx/w==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm"
|
"arm"
|
||||||
],
|
],
|
||||||
@ -720,9 +719,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/android-arm64": {
|
"node_modules/@esbuild/android-arm64": {
|
||||||
"version": "0.19.12",
|
"version": "0.20.2",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.19.12.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.20.2.tgz",
|
||||||
"integrity": "sha512-P0UVNGIienjZv3f5zq0DP3Nt2IE/3plFzuaS96vihvD0Hd6H/q4WXUGpCxD/E8YrSXfNyRPbpTq+T8ZQioSuPA==",
|
"integrity": "sha512-mRzjLacRtl/tWU0SvD8lUEwb61yP9cqQo6noDZP/O8VkwafSYwZ4yWy24kan8jE/IMERpYncRt2dw438LP3Xmg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@ -736,9 +735,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/android-x64": {
|
"node_modules/@esbuild/android-x64": {
|
||||||
"version": "0.19.12",
|
"version": "0.20.2",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.19.12.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.20.2.tgz",
|
||||||
"integrity": "sha512-3k7ZoUW6Q6YqhdhIaq/WZ7HwBpnFBlW905Fa4s4qWJyiNOgT1dOqDiVAQFwBH7gBRZr17gLrlFCRzF6jFh7Kew==",
|
"integrity": "sha512-btzExgV+/lMGDDa194CcUQm53ncxzeBrWJcncOBxuC6ndBkKxnHdFJn86mCIgTELsooUmwUm9FkhSp5HYu00Rg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@ -752,9 +751,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/darwin-arm64": {
|
"node_modules/@esbuild/darwin-arm64": {
|
||||||
"version": "0.19.12",
|
"version": "0.20.2",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.19.12.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.20.2.tgz",
|
||||||
"integrity": "sha512-B6IeSgZgtEzGC42jsI+YYu9Z3HKRxp8ZT3cqhvliEHovq8HSX2YX8lNocDn79gCKJXOSaEot9MVYky7AKjCs8g==",
|
"integrity": "sha512-4J6IRT+10J3aJH3l1yzEg9y3wkTDgDk7TSDFX+wKFiWjqWp/iCfLIYzGyasx9l0SAFPT1HwSCR+0w/h1ES/MjA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@ -768,9 +767,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/darwin-x64": {
|
"node_modules/@esbuild/darwin-x64": {
|
||||||
"version": "0.19.12",
|
"version": "0.20.2",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.19.12.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.20.2.tgz",
|
||||||
"integrity": "sha512-hKoVkKzFiToTgn+41qGhsUJXFlIjxI/jSYeZf3ugemDYZldIXIxhvwN6erJGlX4t5h417iFuheZ7l+YVn05N3A==",
|
"integrity": "sha512-tBcXp9KNphnNH0dfhv8KYkZhjc+H3XBkF5DKtswJblV7KlT9EI2+jeA8DgBjp908WEuYll6pF+UStUCfEpdysA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@ -784,9 +783,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/freebsd-arm64": {
|
"node_modules/@esbuild/freebsd-arm64": {
|
||||||
"version": "0.19.12",
|
"version": "0.20.2",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.19.12.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.20.2.tgz",
|
||||||
"integrity": "sha512-4aRvFIXmwAcDBw9AueDQ2YnGmz5L6obe5kmPT8Vd+/+x/JMVKCgdcRwH6APrbpNXsPz+K653Qg8HB/oXvXVukA==",
|
"integrity": "sha512-d3qI41G4SuLiCGCFGUrKsSeTXyWG6yem1KcGZVS+3FYlYhtNoNgYrWcvkOoaqMhwXSMrZRl69ArHsGJ9mYdbbw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@ -800,9 +799,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/freebsd-x64": {
|
"node_modules/@esbuild/freebsd-x64": {
|
||||||
"version": "0.19.12",
|
"version": "0.20.2",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.19.12.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.20.2.tgz",
|
||||||
"integrity": "sha512-EYoXZ4d8xtBoVN7CEwWY2IN4ho76xjYXqSXMNccFSx2lgqOG/1TBPW0yPx1bJZk94qu3tX0fycJeeQsKovA8gg==",
|
"integrity": "sha512-d+DipyvHRuqEeM5zDivKV1KuXn9WeRX6vqSqIDgwIfPQtwMP4jaDsQsDncjTDDsExT4lR/91OLjRo8bmC1e+Cw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@ -816,9 +815,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/linux-arm": {
|
"node_modules/@esbuild/linux-arm": {
|
||||||
"version": "0.19.12",
|
"version": "0.20.2",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.19.12.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.20.2.tgz",
|
||||||
"integrity": "sha512-J5jPms//KhSNv+LO1S1TX1UWp1ucM6N6XuL6ITdKWElCu8wXP72l9MM0zDTzzeikVyqFE6U8YAV9/tFyj0ti+w==",
|
"integrity": "sha512-VhLPeR8HTMPccbuWWcEUD1Az68TqaTYyj6nfE4QByZIQEQVWBB8vup8PpR7y1QHL3CpcF6xd5WVBU/+SBEvGTg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm"
|
"arm"
|
||||||
],
|
],
|
||||||
@ -832,9 +831,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/linux-arm64": {
|
"node_modules/@esbuild/linux-arm64": {
|
||||||
"version": "0.19.12",
|
"version": "0.20.2",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.19.12.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.20.2.tgz",
|
||||||
"integrity": "sha512-EoTjyYyLuVPfdPLsGVVVC8a0p1BFFvtpQDB/YLEhaXyf/5bczaGeN15QkR+O4S5LeJ92Tqotve7i1jn35qwvdA==",
|
"integrity": "sha512-9pb6rBjGvTFNira2FLIWqDk/uaf42sSyLE8j1rnUpuzsODBq7FvpwHYZxQ/It/8b+QOS1RYfqgGFNLRI+qlq2A==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@ -848,9 +847,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/linux-ia32": {
|
"node_modules/@esbuild/linux-ia32": {
|
||||||
"version": "0.19.12",
|
"version": "0.20.2",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.19.12.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.20.2.tgz",
|
||||||
"integrity": "sha512-Thsa42rrP1+UIGaWz47uydHSBOgTUnwBwNq59khgIwktK6x60Hivfbux9iNR0eHCHzOLjLMLfUMLCypBkZXMHA==",
|
"integrity": "sha512-o10utieEkNPFDZFQm9CoP7Tvb33UutoJqg3qKf1PWVeeJhJw0Q347PxMvBgVVFgouYLGIhFYG0UGdBumROyiig==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"ia32"
|
"ia32"
|
||||||
],
|
],
|
||||||
@ -864,9 +863,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/linux-loong64": {
|
"node_modules/@esbuild/linux-loong64": {
|
||||||
"version": "0.19.12",
|
"version": "0.20.2",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.19.12.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.20.2.tgz",
|
||||||
"integrity": "sha512-LiXdXA0s3IqRRjm6rV6XaWATScKAXjI4R4LoDlvO7+yQqFdlr1Bax62sRwkVvRIrwXxvtYEHHI4dm50jAXkuAA==",
|
"integrity": "sha512-PR7sp6R/UC4CFVomVINKJ80pMFlfDfMQMYynX7t1tNTeivQ6XdX5r2XovMmha/VjR1YN/HgHWsVcTRIMkymrgQ==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"loong64"
|
"loong64"
|
||||||
],
|
],
|
||||||
@ -880,9 +879,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/linux-mips64el": {
|
"node_modules/@esbuild/linux-mips64el": {
|
||||||
"version": "0.19.12",
|
"version": "0.20.2",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.19.12.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.20.2.tgz",
|
||||||
"integrity": "sha512-fEnAuj5VGTanfJ07ff0gOA6IPsvrVHLVb6Lyd1g2/ed67oU1eFzL0r9WL7ZzscD+/N6i3dWumGE1Un4f7Amf+w==",
|
"integrity": "sha512-4BlTqeutE/KnOiTG5Y6Sb/Hw6hsBOZapOVF6njAESHInhlQAghVVZL1ZpIctBOoTFbQyGW+LsVYZ8lSSB3wkjA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"mips64el"
|
"mips64el"
|
||||||
],
|
],
|
||||||
@ -896,9 +895,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/linux-ppc64": {
|
"node_modules/@esbuild/linux-ppc64": {
|
||||||
"version": "0.19.12",
|
"version": "0.20.2",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.19.12.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.20.2.tgz",
|
||||||
"integrity": "sha512-nYJA2/QPimDQOh1rKWedNOe3Gfc8PabU7HT3iXWtNUbRzXS9+vgB0Fjaqr//XNbd82mCxHzik2qotuI89cfixg==",
|
"integrity": "sha512-rD3KsaDprDcfajSKdn25ooz5J5/fWBylaaXkuotBDGnMnDP1Uv5DLAN/45qfnf3JDYyJv/ytGHQaziHUdyzaAg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"ppc64"
|
"ppc64"
|
||||||
],
|
],
|
||||||
@ -912,9 +911,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/linux-riscv64": {
|
"node_modules/@esbuild/linux-riscv64": {
|
||||||
"version": "0.19.12",
|
"version": "0.20.2",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.19.12.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.20.2.tgz",
|
||||||
"integrity": "sha512-2MueBrlPQCw5dVJJpQdUYgeqIzDQgw3QtiAHUC4RBz9FXPrskyyU3VI1hw7C0BSKB9OduwSJ79FTCqtGMWqJHg==",
|
"integrity": "sha512-snwmBKacKmwTMmhLlz/3aH1Q9T8v45bKYGE3j26TsaOVtjIag4wLfWSiZykXzXuE1kbCE+zJRmwp+ZbIHinnVg==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"riscv64"
|
"riscv64"
|
||||||
],
|
],
|
||||||
@ -928,9 +927,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/linux-s390x": {
|
"node_modules/@esbuild/linux-s390x": {
|
||||||
"version": "0.19.12",
|
"version": "0.20.2",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.19.12.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.20.2.tgz",
|
||||||
"integrity": "sha512-+Pil1Nv3Umes4m3AZKqA2anfhJiVmNCYkPchwFJNEJN5QxmTs1uzyy4TvmDrCRNT2ApwSari7ZIgrPeUx4UZDg==",
|
"integrity": "sha512-wcWISOobRWNm3cezm5HOZcYz1sKoHLd8VL1dl309DiixxVFoFe/o8HnwuIwn6sXre88Nwj+VwZUvJf4AFxkyrQ==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"s390x"
|
"s390x"
|
||||||
],
|
],
|
||||||
@ -944,9 +943,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/linux-x64": {
|
"node_modules/@esbuild/linux-x64": {
|
||||||
"version": "0.19.12",
|
"version": "0.20.2",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.19.12.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.20.2.tgz",
|
||||||
"integrity": "sha512-B71g1QpxfwBvNrfyJdVDexenDIt1CiDN1TIXLbhOw0KhJzE78KIFGX6OJ9MrtC0oOqMWf+0xop4qEU8JrJTwCg==",
|
"integrity": "sha512-1MdwI6OOTsfQfek8sLwgyjOXAu+wKhLEoaOLTjbijk6E2WONYpH9ZU2mNtR+lZ2B4uwr+usqGuVfFT9tMtGvGw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@ -960,9 +959,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/netbsd-x64": {
|
"node_modules/@esbuild/netbsd-x64": {
|
||||||
"version": "0.19.12",
|
"version": "0.20.2",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.19.12.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.20.2.tgz",
|
||||||
"integrity": "sha512-3ltjQ7n1owJgFbuC61Oj++XhtzmymoCihNFgT84UAmJnxJfm4sYCiSLTXZtE00VWYpPMYc+ZQmB6xbSdVh0JWA==",
|
"integrity": "sha512-K8/DhBxcVQkzYc43yJXDSyjlFeHQJBiowJ0uVL6Tor3jGQfSGHNNJcWxNbOI8v5k82prYqzPuwkzHt3J1T1iZQ==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@ -976,9 +975,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/openbsd-x64": {
|
"node_modules/@esbuild/openbsd-x64": {
|
||||||
"version": "0.19.12",
|
"version": "0.20.2",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.19.12.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.20.2.tgz",
|
||||||
"integrity": "sha512-RbrfTB9SWsr0kWmb9srfF+L933uMDdu9BIzdA7os2t0TXhCRjrQyCeOt6wVxr79CKD4c+p+YhCj31HBkYcXebw==",
|
"integrity": "sha512-eMpKlV0SThJmmJgiVyN9jTPJ2VBPquf6Kt/nAoo6DgHAoN57K15ZghiHaMvqjCye/uU4X5u3YSMgVBI1h3vKrQ==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@ -992,9 +991,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/sunos-x64": {
|
"node_modules/@esbuild/sunos-x64": {
|
||||||
"version": "0.19.12",
|
"version": "0.20.2",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.19.12.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.20.2.tgz",
|
||||||
"integrity": "sha512-HKjJwRrW8uWtCQnQOz9qcU3mUZhTUQvi56Q8DPTLLB+DawoiQdjsYq+j+D3s9I8VFtDr+F9CjgXKKC4ss89IeA==",
|
"integrity": "sha512-2UyFtRC6cXLyejf/YEld4Hajo7UHILetzE1vsRcGL3earZEW77JxrFjH4Ez2qaTiEfMgAXxfAZCm1fvM/G/o8w==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@ -1008,9 +1007,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/win32-arm64": {
|
"node_modules/@esbuild/win32-arm64": {
|
||||||
"version": "0.19.12",
|
"version": "0.20.2",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.19.12.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.20.2.tgz",
|
||||||
"integrity": "sha512-URgtR1dJnmGvX864pn1B2YUYNzjmXkuJOIqG2HdU62MVS4EHpU2946OZoTMnRUHklGtJdJZ33QfzdjGACXhn1A==",
|
"integrity": "sha512-GRibxoawM9ZCnDxnP3usoUDO9vUkpAxIIZ6GQI+IlVmr5kP3zUq+l17xELTHMWTWzjxa2guPNyrpq1GWmPvcGQ==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@ -1024,9 +1023,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/win32-ia32": {
|
"node_modules/@esbuild/win32-ia32": {
|
||||||
"version": "0.19.12",
|
"version": "0.20.2",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.19.12.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.20.2.tgz",
|
||||||
"integrity": "sha512-+ZOE6pUkMOJfmxmBZElNOx72NKpIa/HFOMGzu8fqzQJ5kgf6aTGrcJaFsNiVMH4JKpMipyK+7k0n2UXN7a8YKQ==",
|
"integrity": "sha512-HfLOfn9YWmkSKRQqovpnITazdtquEW8/SoHW7pWpuEeguaZI4QnCRW6b+oZTztdBnZOS2hqJ6im/D5cPzBTTlQ==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"ia32"
|
"ia32"
|
||||||
],
|
],
|
||||||
@ -1040,9 +1039,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@esbuild/win32-x64": {
|
"node_modules/@esbuild/win32-x64": {
|
||||||
"version": "0.19.12",
|
"version": "0.20.2",
|
||||||
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.19.12.tgz",
|
"resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.20.2.tgz",
|
||||||
"integrity": "sha512-T1QyPSDCyMXaO3pzBkF96E8xMkiRYbUEZADd29SyPGabqxMViNoii+NcK7eWJAEoU6RZyEm5lVSIjTmcdoB9HA==",
|
"integrity": "sha512-N49X4lJX27+l9jbLKSqZ6bKNjzQvHaT8IIFUy+YIqmXQdjYCToGWwOItDrfby14c78aDd5NHQl29xingXfCdLQ==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@ -1494,9 +1493,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-android-arm-eabi": {
|
"node_modules/@rollup/rollup-android-arm-eabi": {
|
||||||
"version": "4.9.6",
|
"version": "4.14.2",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.9.6.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.14.2.tgz",
|
||||||
"integrity": "sha512-MVNXSSYN6QXOulbHpLMKYi60ppyO13W9my1qogeiAqtjb2yR4LSmfU2+POvDkLzhjYLXz9Rf9+9a3zFHW1Lecg==",
|
"integrity": "sha512-ahxSgCkAEk+P/AVO0vYr7DxOD3CwAQrT0Go9BJyGQ9Ef0QxVOfjDZMiF4Y2s3mLyPrjonchIMH/tbWHucJMykQ==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm"
|
"arm"
|
||||||
],
|
],
|
||||||
@ -1507,9 +1506,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-android-arm64": {
|
"node_modules/@rollup/rollup-android-arm64": {
|
||||||
"version": "4.9.6",
|
"version": "4.14.2",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.9.6.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.14.2.tgz",
|
||||||
"integrity": "sha512-T14aNLpqJ5wzKNf5jEDpv5zgyIqcpn1MlwCrUXLrwoADr2RkWA0vOWP4XxbO9aiO3dvMCQICZdKeDrFl7UMClw==",
|
"integrity": "sha512-lAarIdxZWbFSHFSDao9+I/F5jDaKyCqAPMq5HqnfpBw8dKDiCaaqM0lq5h1pQTLeIqueeay4PieGR5jGZMWprw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@ -1520,9 +1519,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-darwin-arm64": {
|
"node_modules/@rollup/rollup-darwin-arm64": {
|
||||||
"version": "4.9.6",
|
"version": "4.14.2",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.9.6.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.14.2.tgz",
|
||||||
"integrity": "sha512-CqNNAyhRkTbo8VVZ5R85X73H3R5NX9ONnKbXuHisGWC0qRbTTxnF1U4V9NafzJbgGM0sHZpdO83pLPzq8uOZFw==",
|
"integrity": "sha512-SWsr8zEUk82KSqquIMgZEg2GE5mCSfr9sE/thDROkX6pb3QQWPp8Vw8zOq2GyxZ2t0XoSIUlvHDkrf5Gmf7x3Q==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@ -1533,9 +1532,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-darwin-x64": {
|
"node_modules/@rollup/rollup-darwin-x64": {
|
||||||
"version": "4.9.6",
|
"version": "4.14.2",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.9.6.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.14.2.tgz",
|
||||||
"integrity": "sha512-zRDtdJuRvA1dc9Mp6BWYqAsU5oeLixdfUvkTHuiYOHwqYuQ4YgSmi6+/lPvSsqc/I0Omw3DdICx4Tfacdzmhog==",
|
"integrity": "sha512-o/HAIrQq0jIxJAhgtIvV5FWviYK4WB0WwV91SLUnsliw1lSAoLsmgEEgRWzDguAFeUEUUoIWXiJrPqU7vGiVkA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@ -1546,9 +1545,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-linux-arm-gnueabihf": {
|
"node_modules/@rollup/rollup-linux-arm-gnueabihf": {
|
||||||
"version": "4.9.6",
|
"version": "4.14.2",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.9.6.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.14.2.tgz",
|
||||||
"integrity": "sha512-oNk8YXDDnNyG4qlNb6is1ojTOGL/tRhbbKeE/YuccItzerEZT68Z9gHrY3ROh7axDc974+zYAPxK5SH0j/G+QQ==",
|
"integrity": "sha512-nwlJ65UY9eGq91cBi6VyDfArUJSKOYt5dJQBq8xyLhvS23qO+4Nr/RreibFHjP6t+5ap2ohZrUJcHv5zk5ju/g==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm"
|
"arm"
|
||||||
],
|
],
|
||||||
@ -1559,9 +1558,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-linux-arm64-gnu": {
|
"node_modules/@rollup/rollup-linux-arm64-gnu": {
|
||||||
"version": "4.9.6",
|
"version": "4.14.2",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.9.6.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.14.2.tgz",
|
||||||
"integrity": "sha512-Z3O60yxPtuCYobrtzjo0wlmvDdx2qZfeAWTyfOjEDqd08kthDKexLpV97KfAeUXPosENKd8uyJMRDfFMxcYkDQ==",
|
"integrity": "sha512-Pg5TxxO2IVlMj79+c/9G0LREC9SY3HM+pfAwX7zj5/cAuwrbfj2Wv9JbMHIdPCfQpYsI4g9mE+2Bw/3aeSs2rQ==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@ -1572,9 +1571,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-linux-arm64-musl": {
|
"node_modules/@rollup/rollup-linux-arm64-musl": {
|
||||||
"version": "4.9.6",
|
"version": "4.14.2",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.9.6.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.14.2.tgz",
|
||||||
"integrity": "sha512-gpiG0qQJNdYEVad+1iAsGAbgAnZ8j07FapmnIAQgODKcOTjLEWM9sRb+MbQyVsYCnA0Im6M6QIq6ax7liws6eQ==",
|
"integrity": "sha512-cAOTjGNm84gc6tS02D1EXtG7tDRsVSDTBVXOLbj31DkwfZwgTPYZ6aafSU7rD/4R2a34JOwlF9fQayuTSkoclA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@ -1584,10 +1583,23 @@
|
|||||||
"linux"
|
"linux"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"node_modules/@rollup/rollup-linux-powerpc64le-gnu": {
|
||||||
|
"version": "4.14.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.14.2.tgz",
|
||||||
|
"integrity": "sha512-4RyT6v1kXb7C0fn6zV33rvaX05P0zHoNzaXI/5oFHklfKm602j+N4mn2YvoezQViRLPnxP8M1NaY4s/5kXO5cw==",
|
||||||
|
"cpu": [
|
||||||
|
"ppc64"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
"node_modules/@rollup/rollup-linux-riscv64-gnu": {
|
"node_modules/@rollup/rollup-linux-riscv64-gnu": {
|
||||||
"version": "4.9.6",
|
"version": "4.14.2",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.9.6.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.14.2.tgz",
|
||||||
"integrity": "sha512-+uCOcvVmFUYvVDr27aiyun9WgZk0tXe7ThuzoUTAukZJOwS5MrGbmSlNOhx1j80GdpqbOty05XqSl5w4dQvcOA==",
|
"integrity": "sha512-KNUH6jC/vRGAKSorySTyc/yRYlCwN/5pnMjXylfBniwtJx5O7X17KG/0efj8XM3TZU7raYRXJFFReOzNmL1n1w==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"riscv64"
|
"riscv64"
|
||||||
],
|
],
|
||||||
@ -1597,10 +1609,23 @@
|
|||||||
"linux"
|
"linux"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"node_modules/@rollup/rollup-linux-s390x-gnu": {
|
||||||
|
"version": "4.14.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.14.2.tgz",
|
||||||
|
"integrity": "sha512-xPV4y73IBEXToNPa3h5lbgXOi/v0NcvKxU0xejiFw6DtIYQqOTMhZ2DN18/HrrP0PmiL3rGtRG9gz1QE8vFKXQ==",
|
||||||
|
"cpu": [
|
||||||
|
"s390x"
|
||||||
|
],
|
||||||
|
"dev": true,
|
||||||
|
"optional": true,
|
||||||
|
"os": [
|
||||||
|
"linux"
|
||||||
|
]
|
||||||
|
},
|
||||||
"node_modules/@rollup/rollup-linux-x64-gnu": {
|
"node_modules/@rollup/rollup-linux-x64-gnu": {
|
||||||
"version": "4.9.6",
|
"version": "4.14.2",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.9.6.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.14.2.tgz",
|
||||||
"integrity": "sha512-HUNqM32dGzfBKuaDUBqFB7tP6VMN74eLZ33Q9Y1TBqRDn+qDonkAUyKWwF9BR9unV7QUzffLnz9GrnKvMqC/fw==",
|
"integrity": "sha512-QBhtr07iFGmF9egrPOWyO5wciwgtzKkYPNLVCFZTmr4TWmY0oY2Dm/bmhHjKRwZoGiaKdNcKhFtUMBKvlchH+Q==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@ -1611,9 +1636,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-linux-x64-musl": {
|
"node_modules/@rollup/rollup-linux-x64-musl": {
|
||||||
"version": "4.9.6",
|
"version": "4.14.2",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.9.6.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.14.2.tgz",
|
||||||
"integrity": "sha512-ch7M+9Tr5R4FK40FHQk8VnML0Szi2KRujUgHXd/HjuH9ifH72GUmw6lStZBo3c3GB82vHa0ZoUfjfcM7JiiMrQ==",
|
"integrity": "sha512-8zfsQRQGH23O6qazZSFY5jP5gt4cFvRuKTpuBsC1ZnSWxV8ZKQpPqOZIUtdfMOugCcBvFGRa1pDC/tkf19EgBw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@ -1624,9 +1649,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-win32-arm64-msvc": {
|
"node_modules/@rollup/rollup-win32-arm64-msvc": {
|
||||||
"version": "4.9.6",
|
"version": "4.14.2",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.9.6.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.14.2.tgz",
|
||||||
"integrity": "sha512-VD6qnR99dhmTQ1mJhIzXsRcTBvTjbfbGGwKAHcu+52cVl15AC/kplkhxzW/uT0Xl62Y/meBKDZvoJSJN+vTeGA==",
|
"integrity": "sha512-H4s8UjgkPnlChl6JF5empNvFHp77Jx+Wfy2EtmYPe9G22XV+PMuCinZVHurNe8ggtwoaohxARJZbaH/3xjB/FA==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"arm64"
|
"arm64"
|
||||||
],
|
],
|
||||||
@ -1637,9 +1662,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-win32-ia32-msvc": {
|
"node_modules/@rollup/rollup-win32-ia32-msvc": {
|
||||||
"version": "4.9.6",
|
"version": "4.14.2",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.9.6.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.14.2.tgz",
|
||||||
"integrity": "sha512-J9AFDq/xiRI58eR2NIDfyVmTYGyIZmRcvcAoJ48oDld/NTR8wyiPUu2X/v1navJ+N/FGg68LEbX3Ejd6l8B7MQ==",
|
"integrity": "sha512-djqpAjm/i8erWYF0K6UY4kRO3X5+T4TypIqw60Q8MTqSBaQNpNXDhxdjpZ3ikgb+wn99svA7jxcXpiyg9MUsdw==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"ia32"
|
"ia32"
|
||||||
],
|
],
|
||||||
@ -1650,9 +1675,9 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"node_modules/@rollup/rollup-win32-x64-msvc": {
|
"node_modules/@rollup/rollup-win32-x64-msvc": {
|
||||||
"version": "4.9.6",
|
"version": "4.14.2",
|
||||||
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.9.6.tgz",
|
"resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.14.2.tgz",
|
||||||
"integrity": "sha512-jqzNLhNDvIZOrt69Ce4UjGRpXJBzhUBzawMwnaDAwyHriki3XollsewxWzOzz+4yOFDkuJHtTsZFwMxhYJWmLQ==",
|
"integrity": "sha512-teAqzLT0yTYZa8ZP7zhFKEx4cotS8Tkk5XiqNMJhD4CpaWB1BHARE4Qy+RzwnXvSAYv+Q3jAqCVBS+PS+Yee8Q==",
|
||||||
"cpu": [
|
"cpu": [
|
||||||
"x64"
|
"x64"
|
||||||
],
|
],
|
||||||
@ -2532,9 +2557,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/esbuild": {
|
"node_modules/esbuild": {
|
||||||
"version": "0.19.12",
|
"version": "0.20.2",
|
||||||
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.19.12.tgz",
|
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.20.2.tgz",
|
||||||
"integrity": "sha512-aARqgq8roFBj054KvQr5f1sFu0D65G+miZRCuJyJ0G13Zwx7vRar5Zhn2tkQNzIXcBrNVsv/8stehpj+GAjgbg==",
|
"integrity": "sha512-WdOOppmUNU+IbZ0PaDiTst80zjnrOkyJNHoKupIcVyU8Lvla3Ugx94VzkQ32Ijqd7UhHJy75gNWDMUekcrSJ6g==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
@ -2544,29 +2569,29 @@
|
|||||||
"node": ">=12"
|
"node": ">=12"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@esbuild/aix-ppc64": "0.19.12",
|
"@esbuild/aix-ppc64": "0.20.2",
|
||||||
"@esbuild/android-arm": "0.19.12",
|
"@esbuild/android-arm": "0.20.2",
|
||||||
"@esbuild/android-arm64": "0.19.12",
|
"@esbuild/android-arm64": "0.20.2",
|
||||||
"@esbuild/android-x64": "0.19.12",
|
"@esbuild/android-x64": "0.20.2",
|
||||||
"@esbuild/darwin-arm64": "0.19.12",
|
"@esbuild/darwin-arm64": "0.20.2",
|
||||||
"@esbuild/darwin-x64": "0.19.12",
|
"@esbuild/darwin-x64": "0.20.2",
|
||||||
"@esbuild/freebsd-arm64": "0.19.12",
|
"@esbuild/freebsd-arm64": "0.20.2",
|
||||||
"@esbuild/freebsd-x64": "0.19.12",
|
"@esbuild/freebsd-x64": "0.20.2",
|
||||||
"@esbuild/linux-arm": "0.19.12",
|
"@esbuild/linux-arm": "0.20.2",
|
||||||
"@esbuild/linux-arm64": "0.19.12",
|
"@esbuild/linux-arm64": "0.20.2",
|
||||||
"@esbuild/linux-ia32": "0.19.12",
|
"@esbuild/linux-ia32": "0.20.2",
|
||||||
"@esbuild/linux-loong64": "0.19.12",
|
"@esbuild/linux-loong64": "0.20.2",
|
||||||
"@esbuild/linux-mips64el": "0.19.12",
|
"@esbuild/linux-mips64el": "0.20.2",
|
||||||
"@esbuild/linux-ppc64": "0.19.12",
|
"@esbuild/linux-ppc64": "0.20.2",
|
||||||
"@esbuild/linux-riscv64": "0.19.12",
|
"@esbuild/linux-riscv64": "0.20.2",
|
||||||
"@esbuild/linux-s390x": "0.19.12",
|
"@esbuild/linux-s390x": "0.20.2",
|
||||||
"@esbuild/linux-x64": "0.19.12",
|
"@esbuild/linux-x64": "0.20.2",
|
||||||
"@esbuild/netbsd-x64": "0.19.12",
|
"@esbuild/netbsd-x64": "0.20.2",
|
||||||
"@esbuild/openbsd-x64": "0.19.12",
|
"@esbuild/openbsd-x64": "0.20.2",
|
||||||
"@esbuild/sunos-x64": "0.19.12",
|
"@esbuild/sunos-x64": "0.20.2",
|
||||||
"@esbuild/win32-arm64": "0.19.12",
|
"@esbuild/win32-arm64": "0.20.2",
|
||||||
"@esbuild/win32-ia32": "0.19.12",
|
"@esbuild/win32-ia32": "0.20.2",
|
||||||
"@esbuild/win32-x64": "0.19.12"
|
"@esbuild/win32-x64": "0.20.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/escalade": {
|
"node_modules/escalade": {
|
||||||
@ -4110,9 +4135,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/postcss": {
|
"node_modules/postcss": {
|
||||||
"version": "8.4.34",
|
"version": "8.4.38",
|
||||||
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.34.tgz",
|
"resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.38.tgz",
|
||||||
"integrity": "sha512-4eLTO36woPSocqZ1zIrFD2K1v6wH7pY1uBh0JIM2KKfrVtGvPFiAku6aNOP0W1Wr9qwnaCsF0Z+CrVnryB2A8Q==",
|
"integrity": "sha512-Wglpdk03BSfXkHoQa3b/oulrotAkwrlLDRSOb9D0bN86FdRyE9lppSp33aHNPgBa0JKCoB+drFLZkQoRRYae5A==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"funding": [
|
"funding": [
|
||||||
{
|
{
|
||||||
@ -4131,7 +4156,7 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"nanoid": "^3.3.7",
|
"nanoid": "^3.3.7",
|
||||||
"picocolors": "^1.0.0",
|
"picocolors": "^1.0.0",
|
||||||
"source-map-js": "^1.0.2"
|
"source-map-js": "^1.2.0"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^10 || ^12 || >=14"
|
"node": "^10 || ^12 || >=14"
|
||||||
@ -4264,9 +4289,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/rollup": {
|
"node_modules/rollup": {
|
||||||
"version": "4.9.6",
|
"version": "4.14.2",
|
||||||
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.9.6.tgz",
|
"resolved": "https://registry.npmjs.org/rollup/-/rollup-4.14.2.tgz",
|
||||||
"integrity": "sha512-05lzkCS2uASX0CiLFybYfVkwNbKZG5NFQ6Go0VWyogFTXXbR039UVsegViTntkk4OglHBdF54ccApXRRuXRbsg==",
|
"integrity": "sha512-WkeoTWvuBoFjFAhsEOHKRoZ3r9GfTyhh7Vff1zwebEFLEFjT1lG3784xEgKiTa7E+e70vsC81roVL2MP4tgEEQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/estree": "1.0.5"
|
"@types/estree": "1.0.5"
|
||||||
@ -4279,19 +4304,21 @@
|
|||||||
"npm": ">=8.0.0"
|
"npm": ">=8.0.0"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"@rollup/rollup-android-arm-eabi": "4.9.6",
|
"@rollup/rollup-android-arm-eabi": "4.14.2",
|
||||||
"@rollup/rollup-android-arm64": "4.9.6",
|
"@rollup/rollup-android-arm64": "4.14.2",
|
||||||
"@rollup/rollup-darwin-arm64": "4.9.6",
|
"@rollup/rollup-darwin-arm64": "4.14.2",
|
||||||
"@rollup/rollup-darwin-x64": "4.9.6",
|
"@rollup/rollup-darwin-x64": "4.14.2",
|
||||||
"@rollup/rollup-linux-arm-gnueabihf": "4.9.6",
|
"@rollup/rollup-linux-arm-gnueabihf": "4.14.2",
|
||||||
"@rollup/rollup-linux-arm64-gnu": "4.9.6",
|
"@rollup/rollup-linux-arm64-gnu": "4.14.2",
|
||||||
"@rollup/rollup-linux-arm64-musl": "4.9.6",
|
"@rollup/rollup-linux-arm64-musl": "4.14.2",
|
||||||
"@rollup/rollup-linux-riscv64-gnu": "4.9.6",
|
"@rollup/rollup-linux-powerpc64le-gnu": "4.14.2",
|
||||||
"@rollup/rollup-linux-x64-gnu": "4.9.6",
|
"@rollup/rollup-linux-riscv64-gnu": "4.14.2",
|
||||||
"@rollup/rollup-linux-x64-musl": "4.9.6",
|
"@rollup/rollup-linux-s390x-gnu": "4.14.2",
|
||||||
"@rollup/rollup-win32-arm64-msvc": "4.9.6",
|
"@rollup/rollup-linux-x64-gnu": "4.14.2",
|
||||||
"@rollup/rollup-win32-ia32-msvc": "4.9.6",
|
"@rollup/rollup-linux-x64-musl": "4.14.2",
|
||||||
"@rollup/rollup-win32-x64-msvc": "4.9.6",
|
"@rollup/rollup-win32-arm64-msvc": "4.14.2",
|
||||||
|
"@rollup/rollup-win32-ia32-msvc": "4.14.2",
|
||||||
|
"@rollup/rollup-win32-x64-msvc": "4.14.2",
|
||||||
"fsevents": "~2.3.2"
|
"fsevents": "~2.3.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -4362,9 +4389,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/source-map-js": {
|
"node_modules/source-map-js": {
|
||||||
"version": "1.0.2",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.0.tgz",
|
||||||
"integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==",
|
"integrity": "sha512-itJW8lvSA0TXEphiRoawsCksnlf8SyvmFzIhltqAHluXd88pkCd+cXJVHTDwdCr0IzwptSm035IHQktUu1QUMg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.10.0"
|
"node": ">=0.10.0"
|
||||||
@ -4727,14 +4754,14 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/vite": {
|
"node_modules/vite": {
|
||||||
"version": "5.0.12",
|
"version": "5.2.8",
|
||||||
"resolved": "https://registry.npmjs.org/vite/-/vite-5.0.12.tgz",
|
"resolved": "https://registry.npmjs.org/vite/-/vite-5.2.8.tgz",
|
||||||
"integrity": "sha512-4hsnEkG3q0N4Tzf1+t6NdN9dg/L3BM+q8SWgbSPnJvrgH2kgdyzfVJwbR1ic69/4uMJJ/3dqDZZE5/WwqW8U1w==",
|
"integrity": "sha512-OyZR+c1CE8yeHw5V5t59aXsUPPVTHMDjEZz8MgguLL/Q7NblxhZUlTu9xSPqlsUO/y+X7dlU05jdhvyycD55DA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"esbuild": "^0.19.3",
|
"esbuild": "^0.20.1",
|
||||||
"postcss": "^8.4.32",
|
"postcss": "^8.4.38",
|
||||||
"rollup": "^4.2.0"
|
"rollup": "^4.13.0"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"vite": "bin/vite.js"
|
"vite": "bin/vite.js"
|
||||||
|
28
package.json
28
package.json
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@ztimson/js-utilities",
|
"name": "@ztimson/utils",
|
||||||
"version": "0.3.3",
|
"version": "0.14.0",
|
||||||
"description": "JavaScript Utility library",
|
"description": "Utility library",
|
||||||
"author": "Zak Timson",
|
"author": "Zak Timson",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"private": false,
|
"private": false,
|
||||||
@ -9,18 +9,24 @@
|
|||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://git.zakscode.com/ztimson/js-utilities"
|
"url": "https://git.zakscode.com/ztimson/js-utilities"
|
||||||
},
|
},
|
||||||
"main": "./dist/js-utilities.js",
|
"main": "./dist/utils.cjs",
|
||||||
"module": "./dist/js-utilities.mjs",
|
"module": "./dist/utils.mjs",
|
||||||
"types": "./dist/src/index.d.ts",
|
"types": "./dist/index.d.ts",
|
||||||
|
"exports": {
|
||||||
|
".": {
|
||||||
|
"import": "./dist/utils.mjs",
|
||||||
|
"require": "./dist/utils.cjs",
|
||||||
|
"types": "./dist/index.d.ts"
|
||||||
|
}
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "npx vite build",
|
"build": "npx tsc && npx vite build",
|
||||||
"test": "npx jest",
|
"test": "npx jest",
|
||||||
"test:coverage": "npx jest --coverage",
|
"test:coverage": "npx jest --coverage",
|
||||||
"watch": "npx vite build --watch"
|
"watch": "npx vite build --watch"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^29.5.12",
|
"@types/jest": "^29.5.12",
|
||||||
"@types/node": "^18.14.0",
|
|
||||||
"jest": "^29.7.0",
|
"jest": "^29.7.0",
|
||||||
"jest-junit": "^16.0.0",
|
"jest-junit": "^16.0.0",
|
||||||
"ts-jest": "^29.1.2",
|
"ts-jest": "^29.1.2",
|
||||||
@ -28,12 +34,6 @@
|
|||||||
"vite": "^5.0.12",
|
"vite": "^5.0.12",
|
||||||
"vite-plugin-dts": "^3.7.2"
|
"vite-plugin-dts": "^3.7.2"
|
||||||
},
|
},
|
||||||
"exports": {
|
|
||||||
".": {
|
|
||||||
"import": "./dist/js-utilities.mjs",
|
|
||||||
"require": "./dist/js-utilities.js"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"files": [
|
"files": [
|
||||||
"dist"
|
"dist"
|
||||||
]
|
]
|
||||||
|
58
src/aset.ts
Normal file
58
src/aset.ts
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
export class ASet<T> extends Array {
|
||||||
|
get size() {
|
||||||
|
return this.length;
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(elements: T[] = []) {
|
||||||
|
super();
|
||||||
|
if(!!elements?.['forEach'])
|
||||||
|
elements.forEach(el => this.add(el));
|
||||||
|
}
|
||||||
|
|
||||||
|
add(el: T) {
|
||||||
|
if(!this.has(el)) this.push(el);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete(el: T) {
|
||||||
|
const index = this.indexOf(el);
|
||||||
|
if(index != -1) this.slice(index, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
difference(set: ASet<T>) {
|
||||||
|
return new ASet<T>(this.reduce((acc, el) => {
|
||||||
|
if(!set.has(el)) acc.push(el);
|
||||||
|
return acc;
|
||||||
|
}, []));
|
||||||
|
}
|
||||||
|
|
||||||
|
has(el: T) {
|
||||||
|
return this.indexOf(el) != -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
intersection(set: ASet<T>) {
|
||||||
|
return new ASet<T>(this.reduce((acc, el) => {
|
||||||
|
if(set.has(el)) acc.push(el);
|
||||||
|
return acc;
|
||||||
|
}, []));
|
||||||
|
}
|
||||||
|
|
||||||
|
isDisjointFrom(set: ASet<T>) {
|
||||||
|
return this.intersection(set).size == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
isSubsetOf(set: ASet<T>) {
|
||||||
|
return this.findIndex(el => !set.has(el)) == -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
isSuperset(set: ASet<T>) {
|
||||||
|
return set.findIndex(el => !this.has(el)) == -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
symmetricDifference(set: ASet<T>) {
|
||||||
|
return new ASet([...this.difference(set), ...set.difference(this)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
union(set: ASet<T> | Array<T>) {
|
||||||
|
return new ASet([...this, ...set]);
|
||||||
|
}
|
||||||
|
}
|
@ -1,15 +1,3 @@
|
|||||||
import {XHR} from './xhr';
|
|
||||||
|
|
||||||
XHR.addInterceptor((resp: Response, next: () => {}) => {
|
|
||||||
if(resp.status == 200) return next();
|
|
||||||
if(resp.status == 400) throw new BadRequestError(resp.statusText);
|
|
||||||
if(resp.status == 401) throw new UnauthorizedError(resp.statusText);
|
|
||||||
if(resp.status == 403) throw new ForbiddenError(resp.statusText);
|
|
||||||
if(resp.status == 404) throw new NotFoundError(resp.statusText);
|
|
||||||
if(resp.status == 500) throw new InternalServerError(resp.statusText);
|
|
||||||
throw new CustomError(resp.statusText, resp.status);
|
|
||||||
});
|
|
||||||
|
|
||||||
export class CustomError extends Error {
|
export class CustomError extends Error {
|
||||||
static code = 500;
|
static code = 500;
|
||||||
|
|
||||||
|
54
src/files.ts
Normal file
54
src/files.ts
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
import {PromiseProgress} from './promise-progress.ts';
|
||||||
|
|
||||||
|
export function download(href: any, name: string) {
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.href = href;
|
||||||
|
a.download = name;
|
||||||
|
document.body.appendChild(a);
|
||||||
|
a.click();
|
||||||
|
document.body.removeChild(a);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function downloadBlob(blob: Blob, name: string) {
|
||||||
|
const url = URL.createObjectURL(blob);
|
||||||
|
download(url, name);
|
||||||
|
URL.revokeObjectURL(url);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function fileBrowser(options: {accept?: string, multiple?: boolean} = {}): Promise<File[]> {
|
||||||
|
return new Promise(res => {
|
||||||
|
const input = document.createElement('input');
|
||||||
|
input.type = 'file';
|
||||||
|
input.accept = options.accept || '*';
|
||||||
|
input.style.display='none';
|
||||||
|
input.multiple = !!options.multiple;
|
||||||
|
input.onblur = input.onchange = async () => {
|
||||||
|
res(Array.from(<any>input.files));
|
||||||
|
input.remove();
|
||||||
|
}
|
||||||
|
document.body.appendChild(input);
|
||||||
|
input.click();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function uploadWithProgress(options: {
|
||||||
|
url: string;
|
||||||
|
file: File;
|
||||||
|
headers?: {[key: string]: string};
|
||||||
|
withCredentials?: boolean;
|
||||||
|
}) {
|
||||||
|
return new PromiseProgress((res, rej, prog) => {
|
||||||
|
const xhr = new XMLHttpRequest();
|
||||||
|
const formData = new FormData();
|
||||||
|
formData.append('file', options.file);
|
||||||
|
|
||||||
|
xhr.withCredentials = !!options.withCredentials
|
||||||
|
Object.entries(options.headers || {}).forEach(([key, value]) => xhr.setRequestHeader(key, value));
|
||||||
|
xhr.upload.addEventListener('progress', (event) => event.lengthComputable ? prog(event.loaded / event.total) : null);
|
||||||
|
xhr.upload.addEventListener('load', (resp) => res(resp));
|
||||||
|
xhr.upload.addEventListener('error', (err) => rej(err));
|
||||||
|
|
||||||
|
xhr.open('POST', options.url);
|
||||||
|
xhr.send(formData);
|
||||||
|
});
|
||||||
|
}
|
122
src/http.ts
Normal file
122
src/http.ts
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
import {clean} from './objects';
|
||||||
|
import {PromiseProgress} from './promise-progress';
|
||||||
|
|
||||||
|
export type DecodedResponse<T> = Response & {data?: T}
|
||||||
|
|
||||||
|
export type HttpInterceptor = (response: Response, next: () => void) => void;
|
||||||
|
|
||||||
|
export type HttpRequestOptions = {
|
||||||
|
url?: string;
|
||||||
|
fragment?: string;
|
||||||
|
query?: {key: string, value: string}[] | {[key: string]: string};
|
||||||
|
method?: 'GET' | 'POST' | 'PATCH' | 'DELETE';
|
||||||
|
body?: any;
|
||||||
|
headers?: {[key: string | symbol]: string | null | undefined};
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type HttpDefaults = {
|
||||||
|
headers?: {[key: string | symbol]: string | null | undefined};
|
||||||
|
interceptors?: HttpInterceptor[];
|
||||||
|
url?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export class Http {
|
||||||
|
private static interceptors: {[key: string]: HttpInterceptor} = {};
|
||||||
|
|
||||||
|
static headers: {[key: string]: string | null | undefined} = {};
|
||||||
|
|
||||||
|
private interceptors: {[key: string]: HttpInterceptor} = {}
|
||||||
|
|
||||||
|
headers: {[key: string]: string | null | undefined} = {}
|
||||||
|
url!: string | null;
|
||||||
|
|
||||||
|
constructor(defaults: HttpDefaults = {}) {
|
||||||
|
this.url = defaults.url ?? null;
|
||||||
|
this.headers = defaults.headers || {};
|
||||||
|
if(defaults.interceptors) {
|
||||||
|
defaults.interceptors.forEach(i => Http.addInterceptor(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static addInterceptor(fn: HttpInterceptor): () => void {
|
||||||
|
const key = Object.keys(Http.interceptors).length.toString();
|
||||||
|
Http.interceptors[key] = fn;
|
||||||
|
return () => { Http.interceptors[key] = <any>null; }
|
||||||
|
}
|
||||||
|
|
||||||
|
addInterceptor(fn: HttpInterceptor): () => void {
|
||||||
|
const key = Object.keys(this.interceptors).length.toString();
|
||||||
|
this.interceptors[key] = fn;
|
||||||
|
return () => { this.interceptors[key] = <any>null; }
|
||||||
|
}
|
||||||
|
|
||||||
|
request<T>(opts: HttpRequestOptions = {}): PromiseProgress<DecodedResponse<T>> {
|
||||||
|
if(!this.url && !opts.url) throw new Error('URL needs to be set');
|
||||||
|
let url = (opts.url?.startsWith('http') ? opts.url : (this.url || '') + (opts.url || '')).replace(/([^:]\/)\/+/g, '$1');
|
||||||
|
if(opts.fragment) url.includes('#') ? url.replace(/#.*(\?|\n)/g, (match, arg1) => `#${opts.fragment}${arg1}`) : url += '#' + opts.fragment;
|
||||||
|
if(opts.query) {
|
||||||
|
const q = Array.isArray(opts.query) ? opts.query :
|
||||||
|
Object.keys(opts.query).map(k => ({key: k, value: (<any>opts.query)[k]}))
|
||||||
|
url += (url.includes('?') ? '&' : '?') + q.map(q => `${q.key}=${q.value}`).join('&');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prep headers
|
||||||
|
const headers = <any>clean({
|
||||||
|
'Content-Type': !opts.body ? undefined : (opts.body instanceof FormData ? 'multipart/form-data' : 'application/json'),
|
||||||
|
...Http.headers,
|
||||||
|
...this.headers,
|
||||||
|
...opts.headers
|
||||||
|
});
|
||||||
|
|
||||||
|
if(typeof opts.body == 'object' && opts.body != null && headers['Content-Type'] == 'application/json')
|
||||||
|
opts.body = JSON.stringify(opts.json);
|
||||||
|
|
||||||
|
// Send request
|
||||||
|
return new PromiseProgress((res, rej, prog) => {
|
||||||
|
fetch(url, {
|
||||||
|
headers,
|
||||||
|
method: opts.method || (opts.body ? 'POST' : 'GET'),
|
||||||
|
body: opts.body
|
||||||
|
}).then(async (resp: DecodedResponse<T>) => {
|
||||||
|
console.log('done!');
|
||||||
|
for(let fn of [...Object.values(Http.interceptors), ...Object.values(this.interceptors)]) {
|
||||||
|
await new Promise<void>(res => fn(resp, () => res()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!resp.ok) rej(resp);
|
||||||
|
|
||||||
|
const contentLength = resp.headers.get('Content-Length');
|
||||||
|
const total = contentLength ? parseInt(contentLength, 10) : 0;
|
||||||
|
let loaded = 0;
|
||||||
|
|
||||||
|
const reader = resp.body?.getReader();
|
||||||
|
const stream = new ReadableStream({
|
||||||
|
start(controller) {
|
||||||
|
function push() {
|
||||||
|
reader?.read().then(({done, value}) => {
|
||||||
|
if(done) return controller.close();
|
||||||
|
loaded += value.byteLength;
|
||||||
|
prog(loaded / total);
|
||||||
|
controller.enqueue(value);
|
||||||
|
push();
|
||||||
|
}).catch(error => {
|
||||||
|
controller.error(error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
push();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const data = new Response(stream);
|
||||||
|
|
||||||
|
const content = resp.headers.get('Content-Type')?.toLowerCase();
|
||||||
|
if(content?.includes('json')) resp.data = <T>await data.json();
|
||||||
|
else if(content?.includes('text')) resp.data = <T>await data.text();
|
||||||
|
else if(content?.includes('form')) resp.data = <T>await data.formData();
|
||||||
|
else if(content?.includes('application')) resp.data = <T>await data.blob();
|
||||||
|
res(resp);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -1,10 +1,13 @@
|
|||||||
export * from './array';
|
export * from './array';
|
||||||
|
export * from './aset';
|
||||||
|
export * from './files';
|
||||||
export * from './emitter';
|
export * from './emitter';
|
||||||
export * from './errors';
|
export * from './errors';
|
||||||
|
export * from './http';
|
||||||
export * from './logger';
|
export * from './logger';
|
||||||
|
export * from './math';
|
||||||
export * from './misc';
|
export * from './misc';
|
||||||
export * from './objects';
|
export * from './objects';
|
||||||
// export * from './redis';
|
export * from './promise-progress';
|
||||||
export * from './string';
|
export * from './string';
|
||||||
export * from './time';
|
export * from './time';
|
||||||
export * from './xhr';
|
|
||||||
|
@ -42,21 +42,23 @@ export const CliBackground = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export enum LOG_LEVEL {
|
export enum LOG_LEVEL {
|
||||||
VERBOSE,
|
ERROR = 0,
|
||||||
INFO,
|
WARN = 1,
|
||||||
WARN,
|
INFO = 2,
|
||||||
ERROR
|
LOG = 3,
|
||||||
|
DEBUG = 4,
|
||||||
}
|
}
|
||||||
|
|
||||||
export type LoggerEvents = TypedEvents & {
|
export type LoggerEvents = TypedEvents & {
|
||||||
'VERBOSE': (...args: any[]) => any;
|
|
||||||
'INFO': (...args: any[]) => any;
|
|
||||||
'WARN': (...args: any[]) => any;
|
|
||||||
'ERROR': (...args: any[]) => any;
|
'ERROR': (...args: any[]) => any;
|
||||||
|
'WARN': (...args: any[]) => any;
|
||||||
|
'INFO': (...args: any[]) => any;
|
||||||
|
'LOG': (...args: any[]) => any;
|
||||||
|
'DEBUG': (...args: any[]) => any;
|
||||||
};
|
};
|
||||||
|
|
||||||
export class Logger extends TypedEmitter<LoggerEvents> {
|
export class Logger extends TypedEmitter<LoggerEvents> {
|
||||||
static LOG_LEVEL: LOG_LEVEL = LOG_LEVEL.INFO;
|
static LOG_LEVEL: LOG_LEVEL = LOG_LEVEL.DEBUG;
|
||||||
|
|
||||||
constructor(public readonly namespace?: string) {
|
constructor(public readonly namespace?: string) {
|
||||||
super();
|
super();
|
||||||
@ -70,7 +72,6 @@ export class Logger extends TypedEmitter<LoggerEvents> {
|
|||||||
return !end ? padding + t : t + padding;
|
return !end ? padding + t : t + padding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private format(...text: string[]): string {
|
private format(...text: string[]): string {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const timestamp = `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()} ${this.pad(now.getHours().toString(), 2, '0')}:${this.pad(now.getMinutes().toString(), 2, '0')}:${this.pad(now.getSeconds().toString(), 2, '0')}.${this.pad(now.getMilliseconds().toString(), 3, '0', true)}`;
|
const timestamp = `${now.getFullYear()}-${now.getMonth() + 1}-${now.getDate()} ${this.pad(now.getHours().toString(), 2, '0')}:${this.pad(now.getMinutes().toString(), 2, '0')}:${this.pad(now.getSeconds().toString(), 2, '0')}.${this.pad(now.getMilliseconds().toString(), 3, '0', true)}`;
|
||||||
@ -78,42 +79,37 @@ export class Logger extends TypedEmitter<LoggerEvents> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
debug(...args: string[]) {
|
debug(...args: string[]) {
|
||||||
if(LOG_LEVEL.VERBOSE >= Logger.LOG_LEVEL) {
|
if(Logger.LOG_LEVEL < LOG_LEVEL.DEBUG) return;
|
||||||
const str = this.format(...args);
|
const str = this.format(...args);
|
||||||
Logger.emit(LOG_LEVEL.VERBOSE, str);
|
Logger.emit(LOG_LEVEL.DEBUG, str);
|
||||||
console.debug(CliForeground.LIGHT_GREY + str + CliEffects.CLEAR);
|
console.debug(CliForeground.LIGHT_GREY + str + CliEffects.CLEAR);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
error(...args: string[]) {
|
log(...args: string[]) {
|
||||||
if(LOG_LEVEL.ERROR >= Logger.LOG_LEVEL) {
|
if(Logger.LOG_LEVEL < LOG_LEVEL.LOG) return;
|
||||||
const str = this.format(...args);
|
const str = this.format(...args);
|
||||||
Logger.emit(LOG_LEVEL.ERROR, str);
|
Logger.emit(LOG_LEVEL.LOG, str);
|
||||||
console.error(CliForeground.RED + str + CliEffects.CLEAR);
|
console.log(CliEffects.CLEAR + str);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
info(...args: string[]) {
|
info(...args: string[]) {
|
||||||
if(LOG_LEVEL.INFO >= Logger.LOG_LEVEL) {
|
if(Logger.LOG_LEVEL < LOG_LEVEL.INFO) return;
|
||||||
const str = this.format(...args);
|
const str = this.format(...args);
|
||||||
Logger.emit(LOG_LEVEL.INFO, str);
|
Logger.emit(LOG_LEVEL.INFO, str);
|
||||||
console.info(CliForeground.BLUE + str + CliEffects.CLEAR);
|
console.info(CliForeground.BLUE + str + CliEffects.CLEAR);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
log(...args: string[]) {
|
|
||||||
if(LOG_LEVEL.INFO >= Logger.LOG_LEVEL) {
|
|
||||||
const str = this.format(...args);
|
|
||||||
Logger.emit(LOG_LEVEL.INFO, str);
|
|
||||||
console.log(CliEffects.CLEAR + str);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
warn(...args: string[]) {
|
warn(...args: string[]) {
|
||||||
if(LOG_LEVEL.WARN >= Logger.LOG_LEVEL) {
|
if(Logger.LOG_LEVEL < LOG_LEVEL.WARN) return;
|
||||||
const str = this.format(...args);
|
const str = this.format(...args);
|
||||||
Logger.emit(LOG_LEVEL.WARN, str);
|
Logger.emit(LOG_LEVEL.WARN, str);
|
||||||
console.warn(CliForeground.YELLOW + str + CliEffects.CLEAR);
|
console.warn(CliForeground.YELLOW + str + CliEffects.CLEAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
error(...args: string[]) {
|
||||||
|
if(Logger.LOG_LEVEL < LOG_LEVEL.ERROR) return;
|
||||||
|
const str = this.format(...args);
|
||||||
|
Logger.emit(LOG_LEVEL.ERROR, str);
|
||||||
|
console.error(CliForeground.RED + str + CliEffects.CLEAR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
45
src/math.ts
Normal file
45
src/math.ts
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
/**
|
||||||
|
* Convert decimal number to fraction
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```js
|
||||||
|
* dec2Frac(1.25) // Outputs: "1 1/4"
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @param {number} num Number to convert
|
||||||
|
* @return {string} Fraction with remainder
|
||||||
|
*/
|
||||||
|
export function dec2Frac(num: number) {
|
||||||
|
const gcd = (a: number, b: number): number => {
|
||||||
|
if (b < 0.0000001) return a;
|
||||||
|
return gcd(b, ~~(a % b));
|
||||||
|
};
|
||||||
|
|
||||||
|
const len = num.toString().length - 2;
|
||||||
|
let denominator = Math.pow(10, len);
|
||||||
|
let numerator = num * denominator;
|
||||||
|
const divisor = gcd(numerator, denominator);
|
||||||
|
numerator = ~~(numerator / divisor);
|
||||||
|
denominator = ~~(denominator / divisor)
|
||||||
|
const remainder = ~~(numerator / denominator);
|
||||||
|
numerator -= remainder * denominator;
|
||||||
|
return `${remainder ? remainder + ' ' : ''}${~~(numerator)}/${~~(denominator)}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert fraction to decimal number
|
||||||
|
*
|
||||||
|
* @example
|
||||||
|
* ```js
|
||||||
|
* fracToDec('1 1/4') // Outputs: 1.25
|
||||||
|
* ```
|
||||||
|
*
|
||||||
|
* @param {string} frac Fraction to convert
|
||||||
|
* @return {number} Faction as a decimal
|
||||||
|
*/
|
||||||
|
export function fracToDec(frac: string) {
|
||||||
|
let split = frac.split(' ');
|
||||||
|
const whole = split.length == 2 ? Number(split[0]) : 0;
|
||||||
|
split = (<string>split.pop()).split('/');
|
||||||
|
return whole + (Number(split[0]) / Number(split[1]));
|
||||||
|
}
|
@ -16,11 +16,12 @@ export function formEncode(data: any): string {
|
|||||||
* Get profile image from Gravatar
|
* Get profile image from Gravatar
|
||||||
*
|
*
|
||||||
* @param {string} email Account email address
|
* @param {string} email Account email address
|
||||||
|
* @param {string} def Default image, can be a link or '404', see: https://docs.gravatar.com/general/images/
|
||||||
* @returns {string} Gravatar URL
|
* @returns {string} Gravatar URL
|
||||||
*/
|
*/
|
||||||
export function gravatar(email: string) {
|
export function gravatar(email: string, def='mp') {
|
||||||
if(!email) return '';
|
if(!email) return '';
|
||||||
return `https://www.gravatar.com/avatar/${md5(email)}`;
|
return `https://www.gravatar.com/avatar/${md5(email)}?d=${def}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Parts of a URL */
|
/** Parts of a URL */
|
||||||
|
@ -35,6 +35,27 @@ export function deepCopy<T>(value: T): T {
|
|||||||
return JSON.parse(JSON.stringify(value));
|
return JSON.parse(JSON.stringify(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merge any number of objects into the target
|
||||||
|
*
|
||||||
|
* @param target Destination of all properties
|
||||||
|
* @param sources Objects that will copied into target
|
||||||
|
* @return {any} The des
|
||||||
|
*/
|
||||||
|
export function deepMerge<T>(target: any, ...sources: any[]): T {
|
||||||
|
sources.forEach(s => {
|
||||||
|
for(const key in s) {
|
||||||
|
if(s[key] && typeof s[key] == 'object' && !Array.isArray(s[key])) {
|
||||||
|
if(!target[key]) target[key] = {};
|
||||||
|
deepMerge(target[key], s[key]);
|
||||||
|
} else {
|
||||||
|
target[key] = s[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get/set a property of an object using dot notation
|
* Get/set a property of an object using dot notation
|
||||||
*
|
*
|
||||||
@ -115,7 +136,7 @@ export function flattenObj(obj: any, parent?: any, result: any = {}) {
|
|||||||
*/
|
*/
|
||||||
export function includes(target: any, values: any, allowMissing = false): boolean {
|
export function includes(target: any, values: any, allowMissing = false): boolean {
|
||||||
if(target == undefined) return allowMissing;
|
if(target == undefined) return allowMissing;
|
||||||
if(Array.isArray(values)) return values.findIndex((e, i) => !includes(target[i], values[i], allowMissing)) == -1;
|
if(Array.isArray(values)) return values.findIndex((e: any, i: number) => !includes(target[i], values[i], allowMissing)) == -1;
|
||||||
const type = typeof values;
|
const type = typeof values;
|
||||||
if(type != typeof target) return false;
|
if(type != typeof target) return false;
|
||||||
if(type == 'object') {
|
if(type == 'object') {
|
||||||
@ -140,3 +161,27 @@ export function isEqual(a: any, b: any): boolean {
|
|||||||
if(keys.length != Object.keys(b).length) return false;
|
if(keys.length != Object.keys(b).length) return false;
|
||||||
return Object.keys(a).every(key => isEqual(a[key], b[key]));
|
return Object.keys(a).every(key => isEqual(a[key], b[key]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function mixin(target: any, constructors: any[]) {
|
||||||
|
constructors.forEach(c => {
|
||||||
|
Object.getOwnPropertyNames(c.prototype).forEach((name) => {
|
||||||
|
Object.defineProperty(
|
||||||
|
target.prototype,
|
||||||
|
name,
|
||||||
|
Object.getOwnPropertyDescriptor(c.prototype, name) ||
|
||||||
|
Object.create(null)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function sanitizedJSON(obj: any, space?: number) {
|
||||||
|
let cache: any[] = [];
|
||||||
|
return JSON.parse(JSON.stringify(obj, (key, value) => {
|
||||||
|
if (typeof value === 'object' && value !== null) {
|
||||||
|
if (cache.includes(value)) return;
|
||||||
|
cache.push(value);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}, space));
|
||||||
|
}
|
||||||
|
52
src/promise-progress.ts
Normal file
52
src/promise-progress.ts
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
export type ProgressCallback = (progress: number) => any;
|
||||||
|
|
||||||
|
export class PromiseProgress<T> extends Promise<T> {
|
||||||
|
private listeners: ProgressCallback[] = [];
|
||||||
|
|
||||||
|
private _progress = 0;
|
||||||
|
get progress() { return this._progress; }
|
||||||
|
set progress(p: number) {
|
||||||
|
if(p == this._progress) return;
|
||||||
|
this._progress = p;
|
||||||
|
this.listeners.forEach(l => l(p));
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(executor: (resolve: (value: T) => any, reject: (reason: any) => void, progress: (progress: number) => any) => void) {
|
||||||
|
super((resolve, reject) => executor(
|
||||||
|
(value: T) => resolve(value),
|
||||||
|
(reason: any) => reject(reason),
|
||||||
|
(progress: number) => this.progress = progress,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
static from<T>(promise: Promise<T>): PromiseProgress<T> {
|
||||||
|
if(promise instanceof PromiseProgress) return promise;
|
||||||
|
return new PromiseProgress<T>((res, rej) => promise
|
||||||
|
.then((...args) => res(...args))
|
||||||
|
.catch((...args) => rej(...args)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private from(promise: Promise<T>): PromiseProgress<T> {
|
||||||
|
const newPromise = PromiseProgress.from(promise);
|
||||||
|
this.onProgress(p => newPromise.progress = p);
|
||||||
|
return newPromise;
|
||||||
|
}
|
||||||
|
|
||||||
|
onProgress(callback: ProgressCallback) {
|
||||||
|
this.listeners.push(callback);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
then(res?: (v: T) => any, rej?: (err: any) => any): PromiseProgress<any> {
|
||||||
|
const resp = super.then(res, rej);
|
||||||
|
return this.from(resp);
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(rej?: (err: any) => any): PromiseProgress<any> {
|
||||||
|
return this.from(super.catch(rej));
|
||||||
|
}
|
||||||
|
|
||||||
|
finally(res?: () => any): PromiseProgress<any> {
|
||||||
|
return this.from(super.finally(res));
|
||||||
|
}
|
||||||
|
}
|
72
src/redis.ts
72
src/redis.ts
@ -1,72 +0,0 @@
|
|||||||
// import {createClient, RedisClientType} from 'redis';
|
|
||||||
// import {environment} from '../environments/environment';
|
|
||||||
//
|
|
||||||
// export type RedisKey = string | string[];
|
|
||||||
//
|
|
||||||
// export let Redis!: RedisClientType & {
|
|
||||||
// // get/set shimmed for JSON
|
|
||||||
// jGet: (redisKey: string) => Promise<any>,
|
|
||||||
// jSet: (redisKey: string, obj: any, opts?: any) => Promise<void>,
|
|
||||||
// // hGet/hSet shimmed for objects
|
|
||||||
// oGet: (redisKey: string) => Promise<any>;
|
|
||||||
// oSet: (redisKey: string, obj: any) => Promise<void>,
|
|
||||||
// // Helpers
|
|
||||||
// findKeys: (filter: RedisKey) => Promise<string[]>,
|
|
||||||
// forEach: (filter: RedisKey, cb: (key: string) => any) => Promise<void>,
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// export async function connectRedis(retry = 3) {
|
|
||||||
// Redis = <any>createClient({
|
|
||||||
// url: `redis://host:port`
|
|
||||||
// });
|
|
||||||
// if(!Redis && retry > 0) {
|
|
||||||
// await connectRedis(retry - 1);
|
|
||||||
// } else if(!!Redis) {
|
|
||||||
// Redis.jGet = async (redisKey: string) => {
|
|
||||||
// const val = await Redis.get(redisKey);
|
|
||||||
// return val ? JSON.parse(val) || val : null;
|
|
||||||
// };
|
|
||||||
// Redis.jSet = (redisKey: string, obj: any, opts?: any) => {
|
|
||||||
// return Redis.set(redisKey, JSON.stringify(obj), opts).then(() => {});
|
|
||||||
// };
|
|
||||||
// Redis.oGet = async (redisKey: string) => {
|
|
||||||
// if(!(await Redis.hLen(redisKey))) return null;
|
|
||||||
// const val = await Redis.hGetAll(redisKey);
|
|
||||||
// Object.entries(val).forEach(([key, v]) => val[key] = JSON.parse(v));
|
|
||||||
// return val;
|
|
||||||
// };
|
|
||||||
// Redis.oSet = (redisKey: string, obj: any) => {
|
|
||||||
// const r = Redis.multi();
|
|
||||||
// Object.entries(obj).forEach(([key, val]) => {
|
|
||||||
// r.hSet(redisKey, key, JSON.stringify(val));
|
|
||||||
// });
|
|
||||||
// return r.exec().then(() => {});
|
|
||||||
// };
|
|
||||||
// Redis.findKeys = async (filter: RedisKey): Promise<string[]> => {
|
|
||||||
// const found: string[] = [];
|
|
||||||
// await Redis.forEach(filter, (key: string) => found.push(key));
|
|
||||||
// return found;
|
|
||||||
// }
|
|
||||||
// Redis.forEach = async (filter: RedisKey, cb: (key: string) => any): Promise<void> => {
|
|
||||||
// for await (const k of Redis.scanIterator({MATCH: createKey(filter)})) {
|
|
||||||
// const rtn = cb(k);
|
|
||||||
// if(rtn instanceof Promise) await rtn;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// await Redis.connect();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// export function createKey(...keys: (string | string[])[]) {
|
|
||||||
// return keys.flat().map(k => k == null ? '*' : k).join(':');
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// export function namespacedKey(namespace: string, key: RedisKey): string {
|
|
||||||
// return createKey(namespace, ...(Array.isArray(key) ? key : [key]));
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// export function nameSpacer(namespace: string) {
|
|
||||||
// return (key: RedisKey) => {
|
|
||||||
// return namespacedKey(namespace, key);
|
|
||||||
// };
|
|
||||||
// }
|
|
@ -52,11 +52,12 @@ export function insertAt(target: string, str: string, index: number): String {
|
|||||||
return `${target.slice(0, index)}${str}${target.slice(index + 1)}`;
|
return `${target.slice(0, index)}${str}${target.slice(index + 1)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function pad(text: string, length: number, char: string, start = true) {
|
export function pad(text: any, length: number, char: string, start = true) {
|
||||||
const l = length - text.length;
|
const t = text.toString();
|
||||||
if(l <= 0) return text;
|
const l = length - t.length;
|
||||||
|
if(l <= 0) return t;
|
||||||
const padding = Array(~~(l / char.length)).fill(char).join('');
|
const padding = Array(~~(l / char.length)).fill(char).join('');
|
||||||
return start ? padding + text : text + padding;
|
return start ? padding + t : t + padding;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
92
src/xhr.ts
92
src/xhr.ts
@ -1,92 +0,0 @@
|
|||||||
export type FetchInterceptor = (resp: Response, next: () => any) => any;
|
|
||||||
|
|
||||||
export class XHR<T> {
|
|
||||||
private static interceptors: {[key: number]: FetchInterceptor} = {};
|
|
||||||
static headers: Record<string, string | null> = {};
|
|
||||||
|
|
||||||
private interceptors: {[key: string]: FetchInterceptor} = {};
|
|
||||||
|
|
||||||
constructor(public readonly baseUrl: string,
|
|
||||||
public readonly headers: Record<string, string | null> = {}
|
|
||||||
) { }
|
|
||||||
|
|
||||||
static addInterceptor(fn: FetchInterceptor): () => {};
|
|
||||||
static addInterceptor(key: string, fn: FetchInterceptor): () => {};
|
|
||||||
static addInterceptor(keyOrFn: string | FetchInterceptor, fn?: FetchInterceptor): () => {} {
|
|
||||||
const func: any = fn ? fn : keyOrFn;
|
|
||||||
const key: string = typeof keyOrFn == 'string' ? keyOrFn :
|
|
||||||
`_${Object.keys(XHR.interceptors).length.toString()}`;
|
|
||||||
XHR.interceptors[<any>key] = func;
|
|
||||||
return () => delete XHR.interceptors[<any>key];
|
|
||||||
}
|
|
||||||
|
|
||||||
addInterceptor(fn: FetchInterceptor): () => {};
|
|
||||||
addInterceptor(key: string, fn: FetchInterceptor): () => {};
|
|
||||||
addInterceptor(keyOrFn: string | FetchInterceptor, fn?: FetchInterceptor): () => {} {
|
|
||||||
const func: any = fn ? fn : keyOrFn;
|
|
||||||
const key: string = typeof keyOrFn == 'string' ? keyOrFn :
|
|
||||||
`_${Object.keys(this.interceptors).length.toString()}`;
|
|
||||||
this.interceptors[<any>key] = func;
|
|
||||||
return () => delete this.interceptors[<any>key];
|
|
||||||
}
|
|
||||||
|
|
||||||
getInterceptors() {
|
|
||||||
return [...Object.values(XHR.interceptors), ...Object.values(this.interceptors)];
|
|
||||||
}
|
|
||||||
|
|
||||||
fetch<T2 = T>(href?: string, body?: any, opts: any = {}): Promise<T2> {
|
|
||||||
const headers = {
|
|
||||||
'Content-Type': (body && !(body instanceof FormData)) ? 'application/json' : undefined,
|
|
||||||
...XHR.headers,
|
|
||||||
...this.headers,
|
|
||||||
...opts.headers
|
|
||||||
};
|
|
||||||
Object.keys(headers).forEach(h => { if(!headers[h]) delete headers[h]; });
|
|
||||||
return fetch(`${this.baseUrl}${href || ''}`.replace(/([^:]\/)\/+/g, '$1'), {
|
|
||||||
headers,
|
|
||||||
method: opts.method || (body ? 'POST' : 'GET'),
|
|
||||||
body: (headers['Content-Type']?.startsWith('application/json') && body) ? JSON.stringify(body) : body
|
|
||||||
}).then(async resp => {
|
|
||||||
for(let fn of this.getInterceptors()) {
|
|
||||||
const wait = new Promise(res =>
|
|
||||||
fn(resp, () => res(null)));
|
|
||||||
await wait;
|
|
||||||
}
|
|
||||||
if(resp.headers.has('Content-Type')) {
|
|
||||||
if(resp.headers.get('Content-Type')?.startsWith('application/json')) return await resp.json();
|
|
||||||
if(resp.headers.get('Content-Type')?.startsWith('text/plain')) return await resp.text();
|
|
||||||
}
|
|
||||||
return resp;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
delete<T2 = void>(url?: string, opts?: any): Promise<T2> {
|
|
||||||
return this.fetch(url, null, {method: 'delete', ...opts});
|
|
||||||
}
|
|
||||||
|
|
||||||
get<T2 = T>(url?: string, opts?: any): Promise<T2> {
|
|
||||||
return this.fetch(url, null, {method: 'get', ...opts});
|
|
||||||
}
|
|
||||||
|
|
||||||
patch<T2 = T>(data: T2, url?: string, opts?: any): Promise<T2> {
|
|
||||||
return this.fetch(url, data, {method: 'patch', ...opts});
|
|
||||||
}
|
|
||||||
|
|
||||||
post<T2 = T>(data: T2, url?: string, opts?: any): Promise<T2> {
|
|
||||||
return this.fetch(url, data, {method: 'post', ...opts});
|
|
||||||
}
|
|
||||||
|
|
||||||
put<T2 = T>(data: Partial<T2>, url?: string, opts?: any): Promise<T2> {
|
|
||||||
return this.fetch(url, data, {method: 'put', ...opts});
|
|
||||||
}
|
|
||||||
|
|
||||||
new<T2 = T>(href: string, headers: Record<string, string | null>): XHR<T2> {
|
|
||||||
const fetch = new XHR<T2>(`${this.baseUrl}${href}`, {
|
|
||||||
...this.headers,
|
|
||||||
...headers,
|
|
||||||
});
|
|
||||||
Object.entries(this.interceptors).map(([key, value]) =>
|
|
||||||
fetch.addInterceptor(key, value));
|
|
||||||
return fetch;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,19 +1,20 @@
|
|||||||
{
|
{
|
||||||
"include": [
|
"include": ["src"],
|
||||||
"src/**/*"
|
|
||||||
],
|
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"composite": true,
|
"target": "ES2020",
|
||||||
"declaration": true,
|
"useDefineForClassFields": true,
|
||||||
"declarationMap": true,
|
"module": "ESNext",
|
||||||
"experimentalDecorators": true,
|
"lib": ["ESNext", "DOM", "DOM.Iterable"],
|
||||||
"esModuleInterop": true,
|
"skipLibCheck": true,
|
||||||
"inlineSourceMap": true,
|
|
||||||
"lib": ["ESNext", "DOM"],
|
/* Bundler mode */
|
||||||
"module": "ES6",
|
"moduleResolution": "bundler",
|
||||||
"moduleResolution": "Node",
|
"allowImportingTsExtensions": true,
|
||||||
"outDir": "./dist",
|
"resolveJsonModule": true,
|
||||||
"strict": true,
|
"isolatedModules": true,
|
||||||
"target": "ESNext"
|
"noEmit": true,
|
||||||
|
|
||||||
|
/* Linting */
|
||||||
|
"strict": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,20 @@
|
|||||||
import { resolve } from 'path';
|
import {resolve} from 'path';
|
||||||
import { defineConfig } from 'vite';
|
import {defineConfig} from 'vite';
|
||||||
import dts from 'vite-plugin-dts';
|
import dts from 'vite-plugin-dts';
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
build: {
|
build: {
|
||||||
lib: {
|
lib: {
|
||||||
entry: resolve(process.cwd(), 'src/index.ts'),
|
entry: resolve(process.cwd(), 'src/index.ts'),
|
||||||
name: 'js-utilities',
|
name: 'utils',
|
||||||
fileName: (module, entryName) => {
|
fileName: (module, entryName) => {
|
||||||
if(module == 'es') return 'js-utilities.mjs';
|
if(module == 'es') return 'utils.mjs';
|
||||||
if(module == 'umd') return 'js-utilities.js';
|
if(module == 'umd') return 'utils.cjs';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
emptyOutDir: true,
|
||||||
|
minify: true,
|
||||||
|
sourcemap: true
|
||||||
},
|
},
|
||||||
plugins: [dts()],
|
plugins: [dts()],
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user