Compare commits
25 Commits
Author | SHA1 | Date | |
---|---|---|---|
6a7570de7b | |||
579e25fe5a | |||
871a22a801 | |||
aacb4a6873 | |||
0ef1af7b86 | |||
2af0329918 | |||
b65a460ef2 | |||
3f5b0ebe1e | |||
6f2cedc1dd | |||
2c29ae3bf0 | |||
b26b8ed4a6 | |||
0e6877d2d1 | |||
8a0c3fe906 | |||
ae861fa271 | |||
3e78466e5f | |||
eea19bcd89 | |||
1fc95fcf0e | |||
14ba4465d9 | |||
707e31d517 | |||
64d85e711a | |||
34a5cc9862 | |||
d43d1ba212 | |||
65e771f1ba | |||
5825a602ed | |||
5e961f7a5b |
66
.gitea/workflows/default_nottags.yaml
Normal file
66
.gitea/workflows/default_nottags.yaml
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
name: Default (not tags)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags-ignore:
|
||||||
|
- '**'
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
||||||
|
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||||
|
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||||
|
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||||
|
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
security:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Install pnpm and npmci
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @shipzone/npmci
|
||||||
|
|
||||||
|
- name: Run npm prepare
|
||||||
|
run: npmci npm prepare
|
||||||
|
|
||||||
|
- name: Audit production dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --prod
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Audit development dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --dev
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
test:
|
||||||
|
if: ${{ always() }}
|
||||||
|
needs: security
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Test stable
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm test
|
||||||
|
|
||||||
|
- name: Test build
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm build
|
124
.gitea/workflows/default_tags.yaml
Normal file
124
.gitea/workflows/default_tags.yaml
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
name: Default (tags)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
NPMCI_COMPUTED_REPOURL: https://${{gitea.repository_owner}}:${{secrets.GITEA_TOKEN}}@gitea.lossless.digital/${{gitea.repository}}.git
|
||||||
|
NPMCI_TOKEN_NPM: ${{secrets.NPMCI_TOKEN_NPM}}
|
||||||
|
NPMCI_TOKEN_NPM2: ${{secrets.NPMCI_TOKEN_NPM2}}
|
||||||
|
NPMCI_GIT_GITHUBTOKEN: ${{secrets.NPMCI_GIT_GITHUBTOKEN}}
|
||||||
|
NPMCI_URL_CLOUDLY: ${{secrets.NPMCI_URL_CLOUDLY}}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
security:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
continue-on-error: true
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @shipzone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Audit production dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --prod
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
- name: Audit development dependencies
|
||||||
|
run: |
|
||||||
|
npmci command npm config set registry https://registry.npmjs.org
|
||||||
|
npmci command pnpm audit --audit-level=high --dev
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
test:
|
||||||
|
if: ${{ always() }}
|
||||||
|
needs: security
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @shipzone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Test stable
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm test
|
||||||
|
|
||||||
|
- name: Test build
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
npmci npm build
|
||||||
|
|
||||||
|
release:
|
||||||
|
needs: test
|
||||||
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @shipzone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Release
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm publish
|
||||||
|
|
||||||
|
metadata:
|
||||||
|
needs: test
|
||||||
|
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: ${{ env.IMAGE }}
|
||||||
|
continue-on-error: true
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Prepare
|
||||||
|
run: |
|
||||||
|
pnpm install -g pnpm
|
||||||
|
pnpm install -g @shipzone/npmci
|
||||||
|
npmci npm prepare
|
||||||
|
|
||||||
|
- name: Code quality
|
||||||
|
run: |
|
||||||
|
npmci command npm install -g typescript
|
||||||
|
npmci npm install
|
||||||
|
|
||||||
|
- name: Trigger
|
||||||
|
run: npmci trigger
|
||||||
|
|
||||||
|
- name: Build docs and upload artifacts
|
||||||
|
run: |
|
||||||
|
npmci node install stable
|
||||||
|
npmci npm install
|
||||||
|
pnpm install -g @git.zone/tsdoc
|
||||||
|
npmci command tsdoc
|
||||||
|
continue-on-error: true
|
140
.gitlab-ci.yml
140
.gitlab-ci.yml
@ -1,140 +0,0 @@
|
|||||||
# gitzone ci_default
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|
||||||
|
|
||||||
cache:
|
|
||||||
paths:
|
|
||||||
- .npmci_cache/
|
|
||||||
key: '$CI_BUILD_STAGE'
|
|
||||||
|
|
||||||
stages:
|
|
||||||
- security
|
|
||||||
- test
|
|
||||||
- release
|
|
||||||
- metadata
|
|
||||||
|
|
||||||
before_script:
|
|
||||||
- npm install -g @shipzone/npmci
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# security stage
|
|
||||||
# ====================
|
|
||||||
mirror:
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci git mirror
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
auditProductionDependencies:
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci command npm install --production --ignore-scripts
|
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
|
||||||
- npmci command npm audit --audit-level=high --only=prod --production
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
auditDevDependencies:
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci command npm install --ignore-scripts
|
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
|
||||||
- npmci command npm audit --audit-level=high --only=dev
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# test stage
|
|
||||||
# ====================
|
|
||||||
|
|
||||||
testStable:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
testBuild:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command npm run build
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
release:
|
|
||||||
stage: release
|
|
||||||
script:
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm publish
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# metadata stage
|
|
||||||
# ====================
|
|
||||||
codequality:
|
|
||||||
stage: metadata
|
|
||||||
allow_failure: true
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
script:
|
|
||||||
- npmci command npm install -g typescript
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci npm install
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- priv
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npmci trigger
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
pages:
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npmci node install lts
|
|
||||||
- npmci command npm install -g @gitzone/tsdoc
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command tsdoc
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
paths:
|
|
||||||
- public
|
|
||||||
allow_failure: true
|
|
@ -11,12 +11,29 @@
|
|||||||
"gitzone": {
|
"gitzone": {
|
||||||
"projectType": "npm",
|
"projectType": "npm",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "gitlab.com",
|
"githost": "code.foss.global",
|
||||||
"gitscope": "pushrocks",
|
"gitscope": "push.rocks",
|
||||||
"gitrepo": "smartstring",
|
"gitrepo": "smartstring",
|
||||||
"description": "handle strings in smart ways. TypeScript ready.",
|
"description": "A library for handling strings in smart ways, including manipulation and encoding, with TypeScript support.",
|
||||||
"npmPackagename": "@pushrocks/smartstring",
|
"npmPackagename": "@push.rocks/smartstring",
|
||||||
"license": "MIT"
|
"license": "MIT",
|
||||||
|
"keywords": [
|
||||||
|
"string manipulation",
|
||||||
|
"encode",
|
||||||
|
"decode",
|
||||||
|
"base64",
|
||||||
|
"indentation",
|
||||||
|
"normalization",
|
||||||
|
"regex",
|
||||||
|
"random string",
|
||||||
|
"cryptographic string",
|
||||||
|
"domain parsing",
|
||||||
|
"git repository parsing",
|
||||||
|
"docker environment parsing"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"tsdoc": {
|
||||||
|
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
||||||
}
|
}
|
||||||
}
|
}
|
13336
package-lock.json
generated
13336
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
55
package.json
55
package.json
@ -1,49 +1,56 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartstring",
|
"name": "@push.rocks/smartstring",
|
||||||
"version": "4.0.4",
|
"version": "4.0.15",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "handle strings in smart ways. TypeScript ready.",
|
"description": "A library for handling strings in smart ways, including manipulation and encoding, with TypeScript support.",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
"typings": "dist_ts/index.d.ts",
|
"typings": "dist_ts/index.d.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/)",
|
"test": "(tstest test/)",
|
||||||
"build": "(tsbuild --web --allowimplicitany)"
|
"build": "(tsbuild --web --allowimplicitany)",
|
||||||
|
"buildDocs": "tsdoc"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "git+https://gitlab.com/pushrocks/smartstring.git"
|
"url": "https://code.foss.global/push.rocks/smartstring.git"
|
||||||
},
|
},
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
"string manipulation",
|
||||||
|
"encode",
|
||||||
|
"decode",
|
||||||
|
"base64",
|
||||||
|
"indentation",
|
||||||
|
"normalization",
|
||||||
"regex",
|
"regex",
|
||||||
"string"
|
"random string",
|
||||||
|
"cryptographic string",
|
||||||
|
"domain parsing",
|
||||||
|
"git repository parsing",
|
||||||
|
"docker environment parsing"
|
||||||
],
|
],
|
||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://gitlab.com/pushrocks/smartstring/issues"
|
"url": "https://gitlab.com/push.rocks/smartstring/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartstring#readme",
|
"homepage": "https://code.foss.global/push.rocks/smartstring",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.65",
|
"@git.zone/tsbuild": "^2.1.72",
|
||||||
"@gitzone/tsrun": "^1.2.37",
|
"@git.zone/tsrun": "^1.2.42",
|
||||||
"@gitzone/tstest": "^1.0.73",
|
"@git.zone/tstest": "^1.0.86",
|
||||||
"@pushrocks/tapbundle": "^5.0.4",
|
"@push.rocks/tapbundle": "^5.0.15",
|
||||||
"@types/node": "^18.7.17",
|
"@types/node": "^20.11.24"
|
||||||
"tslint": "^6.1.3",
|
|
||||||
"tslint-config-prettier": "^1.18.0"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/isounique": "^1.0.5",
|
"@push.rocks/isounique": "^1.0.5",
|
||||||
"@pushrocks/smartenv": "^5.0.3",
|
"@push.rocks/smartenv": "^5.0.12",
|
||||||
"@types/randomatic": "^3.1.3",
|
"@types/randomatic": "^3.1.5",
|
||||||
"buffer": "^6.0.3",
|
"crypto-random-string": "^5.0.0",
|
||||||
"crypto-random-string": "^4.0.0",
|
"js-base64": "^3.7.7",
|
||||||
"js-base64": "^3.7.2",
|
|
||||||
"normalize-newline": "^4.1.0",
|
|
||||||
"randomatic": "^3.1.1",
|
"randomatic": "^3.1.1",
|
||||||
"strip-indent": "^4.0.0",
|
"strip-indent": "^4.0.0",
|
||||||
"url": "^0.11.0"
|
"url": "^0.11.3"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
@ -60,4 +67,4 @@
|
|||||||
"browserslist": [
|
"browserslist": [
|
||||||
"last 1 chrome versions"
|
"last 1 chrome versions"
|
||||||
]
|
]
|
||||||
}
|
}
|
5953
pnpm-lock.yaml
generated
Normal file
5953
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
1
readme.hints.md
Normal file
1
readme.hints.md
Normal file
@ -0,0 +1 @@
|
|||||||
|
|
194
readme.md
194
readme.md
@ -1,77 +1,151 @@
|
|||||||
# @pushrocks/smartstring
|
# @push.rocks/smartstring
|
||||||
handle strings in smart ways. TypeScript ready.
|
handle strings in smart ways. TypeScript ready.
|
||||||
|
|
||||||
## Availabililty and Links
|
## Install
|
||||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartstring)
|
To install `@push.rocks/smartstring`, use the following npm command:
|
||||||
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartstring)
|
|
||||||
* [github.com (source mirror)](https://github.com/pushrocks/smartstring)
|
|
||||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartstring/)
|
|
||||||
|
|
||||||
## Status for master
|
```bash
|
||||||
|
npm install @push.rocks/smartstring --save
|
||||||
|
```
|
||||||
|
|
||||||
Status Category | Status Badge
|
This will add it to your project's dependencies.
|
||||||
-- | --
|
|
||||||
GitLab Pipelines | [](https://lossless.cloud)
|
|
||||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
|
||||||
npm | [](https://lossless.cloud)
|
|
||||||
Snyk | [](https://lossless.cloud)
|
|
||||||
TypeScript Support | [](https://lossless.cloud)
|
|
||||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
|
||||||
Code Style | [](https://lossless.cloud)
|
|
||||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
|
||||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
|
||||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
|
||||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
Use TypeScript for best in class instellisense.
|
The `@push.rocks/smartstring` package provides a powerful set of utilities to handle and manipulate strings in various ways, ready for TypeScript usage. Here's an exhaustive guide to using this package.
|
||||||
|
|
||||||
```javascript
|
### Working with Domain Strings
|
||||||
import * as smartstring from 'smartstring';
|
|
||||||
|
|
||||||
// classes
|
The `Domain` class helps in parsing and extracting information from domain URLs.
|
||||||
|
|
||||||
// smartstring.Domain class
|
```typescript
|
||||||
let myDomain = new smartstring.Domain('https://sub.main.tld');
|
import { Domain } from '@push.rocks/smartstring';
|
||||||
myDomain.level1; // "tld"
|
|
||||||
myDomain.level2; // "main"
|
|
||||||
// level3 , level 4 and so on...
|
|
||||||
myDomain.zoneName; // "main.tld"
|
|
||||||
myDOmain.protocol; // "https"
|
|
||||||
|
|
||||||
// smartstring.GitRepo class
|
// Parse a domain URL
|
||||||
let myGitRepo = new smartstring.GitRepo('git@github.com:someorg/somerepo.git'); // takes https and git and npm repo URL versions
|
const myDomain = new Domain('https://sub.example.com');
|
||||||
myGitRepo.host; // "github.com"
|
console.log(myDomain.level1); // Output: "com"
|
||||||
myGitRepo.user; // "someorg"
|
console.log(myDomain.level2); // Output: "example"
|
||||||
myGitRepo.repo; // "somerepo"
|
console.log(myDomain.zoneName); // Output: "example.com"
|
||||||
myGitRepo.accessToken; // accessToken if specified with https
|
console.log(myDomain.protocol); // Output: "https"
|
||||||
myGitRepo.sshUrl; // "git@github.com:someorg/somerepo.git" (computed also from https)
|
|
||||||
myGitRepo.httpsUrl; // "https://github.com/someorg/somerepo.git" (computed also from ssh)
|
|
||||||
|
|
||||||
//smartstring.Base64
|
|
||||||
let myBase64 = new smartstring.Base64('somestring', 'string'); // first arg is the string, second is string type (can be string, base64, base64uri)
|
|
||||||
myBase64.simpleString; // 'somestring'
|
|
||||||
myBase64.base64String; // base64 representation of 'somestring'
|
|
||||||
myBase64.base64UriString; // base64uri representation of 'sometring'
|
|
||||||
|
|
||||||
// methods
|
|
||||||
smartstring.base64.encode('somestring'); // encodes 'somestring' to base64
|
|
||||||
smartstring.base64.encodeUri('sometring'); // encodes 'somestring' to base64uri
|
|
||||||
smartstring.base64.decode(); // decodes base64 and base64uri to simple string respresentation
|
|
||||||
|
|
||||||
smartstring.indent.indent('somestringanotherstring', 4); // indents a string by 4
|
|
||||||
smartstring.indent.indent('somestringanotherstring', '>>>> '); // indents a string with a prefix
|
|
||||||
smartstring.indent.normalize(' somestring anotherstring', '>>>> '); // looks for the least amount of indention and removes superflouous space
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Contribution
|
### Handling Git Repositories
|
||||||
|
|
||||||
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
|
The `GitRepo` class is designed for extracting information from Git repository URLs.
|
||||||
|
|
||||||
For further information read the linked docs at the top of this readme.
|
```typescript
|
||||||
|
import { GitRepo } from '@push.rocks/smartstring';
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
// Parse a Git repository URL
|
||||||
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
|
const myGitRepo = new GitRepo('git@github.com:user/repo.git');
|
||||||
|
console.log(myGitRepo.host); // Output: "github.com"
|
||||||
|
console.log(myGitRepo.user); // Output: "user"
|
||||||
|
console.log(myGitRepo.repo); // Output: "repo"
|
||||||
|
console.log(myGitRepo.sshUrl); // Output: "git@github.com:user/repo.git"
|
||||||
|
console.log(myGitRepo.httpsUrl); // Output: "https://github.com/user/repo.git"
|
||||||
|
```
|
||||||
|
|
||||||
[](https://maintainedby.lossless.com)
|
### Encoding and Decoding Base64 Strings
|
||||||
|
|
||||||
|
`@push.rocks/smartstring` offers base64 encoding and decoding through the `Base64` class and utility functions.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { Base64, base64 } from '@push.rocks/smartstring';
|
||||||
|
|
||||||
|
// Using the Base64 class
|
||||||
|
const myBase64 = new Base64('hello world', 'string');
|
||||||
|
console.log(myBase64.base64String); // Encoded string
|
||||||
|
console.log(myBase64.base64UriString); // Encoded URI compatible string
|
||||||
|
|
||||||
|
// Using utility functions
|
||||||
|
const encoded = base64.encode('hello world');
|
||||||
|
const decoded = base64.decode(encoded);
|
||||||
|
console.log(encoded); // Encoded string
|
||||||
|
console.log(decoded); // "hello world"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Applying Indentation
|
||||||
|
|
||||||
|
SmartString allows you to easily indent strings or normalize indentation across a multi-line string.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { indent } from '@push.rocks/smartstring';
|
||||||
|
|
||||||
|
// Indent a string by 4 spaces
|
||||||
|
const indentedString = indent.indent('Some text\nAnother line', 4);
|
||||||
|
console.log(indentedString);
|
||||||
|
|
||||||
|
// Indent using a prefix
|
||||||
|
const prefixedString = indent.indentWithPrefix('Line 1\nLine 2', '> ');
|
||||||
|
console.log(prefixedString);
|
||||||
|
|
||||||
|
// Normalize indentation
|
||||||
|
const normalizedString = indent.normalize(' Some indented text\n Another line');
|
||||||
|
console.log(normalizedString);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Creating Random or Encrypted Strings
|
||||||
|
|
||||||
|
Create random strings based on patterns or generate cryptographically strong random strings.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { create } from '@push.rocks/smartstring';
|
||||||
|
|
||||||
|
// Create a random string
|
||||||
|
const randomString = create.createRandomString('aA0', 10);
|
||||||
|
console.log(randomString); // Example output: "a9mB8v2Dq1"
|
||||||
|
|
||||||
|
// Create a crypto-random string
|
||||||
|
const cryptoString = create.createCryptoRandomString(10);
|
||||||
|
console.log(cryptoString); // Example output: "f28Bb90aCc"
|
||||||
|
```
|
||||||
|
|
||||||
|
### Normalizing Strings
|
||||||
|
|
||||||
|
Normalize strings by removing leading/trailing whitespace, fixing indentation, and more.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { normalize } from '@push.rocks/smartstring';
|
||||||
|
|
||||||
|
// Normalize a multi-line string
|
||||||
|
const exampleString = `
|
||||||
|
This is an example.
|
||||||
|
The indentation will be fixed.
|
||||||
|
`;
|
||||||
|
const normalized = normalize.standard(exampleString);
|
||||||
|
console.log(normalized);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Working with Docker Environment Variables
|
||||||
|
|
||||||
|
Transform an array of Docker environment variables into an object for easy access.
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { docker } from '@push.rocks/smartstring';
|
||||||
|
|
||||||
|
const envVars = ['NODE_ENV=production', 'PORT=3000'];
|
||||||
|
const envObject = docker.makeEnvObject(envVars);
|
||||||
|
console.log(envObject.NODE_ENV); // Output: "production"
|
||||||
|
console.log(envObject.PORT); // Output: "3000"
|
||||||
|
```
|
||||||
|
|
||||||
|
This guide covers the primary features of `@push.rocks/smartstring`, making string manipulation and information extraction simple and efficient in your TypeScript projects.
|
||||||
|
|
||||||
|
## License and Legal Information
|
||||||
|
|
||||||
|
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
|
||||||
|
|
||||||
|
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
### Trademarks
|
||||||
|
|
||||||
|
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
||||||
|
|
||||||
|
### Company Information
|
||||||
|
|
||||||
|
Task Venture Capital GmbH
|
||||||
|
Registered at District court Bremen HRB 35230 HB, Germany
|
||||||
|
|
||||||
|
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
||||||
|
|
||||||
|
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
||||||
|
@ -1,16 +1,23 @@
|
|||||||
import * as smartstring from '../ts/index.js';
|
import * as smartstring from '../ts/index.js';
|
||||||
import { tap, expect } from '@pushrocks/tapbundle';
|
import { tap, expect } from '@push.rocks/tapbundle';
|
||||||
|
|
||||||
// Base64
|
// Base64
|
||||||
let testBase64: smartstring.Base64;
|
let testBase64: smartstring.Base64;
|
||||||
|
|
||||||
tap.test('expect create a valid instance of Base64', async () => {
|
tap.test('expect create a valid instance of Base64', async () => {
|
||||||
testBase64 = new smartstring.Base64('somestring', 'string');
|
testBase64 = new smartstring.Base64('somestring', 'string');
|
||||||
expect(testBase64).toBeInstanceOf(smartstring.Base64);
|
expect(testBase64).toBeInstanceOf(smartstring.Base64);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('expect read output a file as base64 and base64uri', async () => {
|
tap.test('expect read output a file as base64 and base64uri', async () => {
|
||||||
expect(testBase64.base64String).not.toEqual(testBase64.base64UriString);
|
expect(testBase64.base64String).not.toEqual(testBase64.base64UriString);
|
||||||
let testBase64_2 = new smartstring.Base64(testBase64.base64UriString, 'base64uri');
|
let testBase64_2 = new smartstring.Base64(testBase64.base64UriString, 'base64uri');
|
||||||
expect(testBase64_2.simpleString).toEqual(testBase64.simpleString);
|
expect(testBase64_2.simpleString).toEqual(testBase64.simpleString);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tap.test('should test for a valid base64 token', async () => {
|
||||||
|
const result = smartstring.base64.isBase64('dGVzdA==');
|
||||||
|
expect(result).toBeTrue();
|
||||||
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as smartstring from '../ts/index.js';
|
import * as smartstring from '../ts/index.js';
|
||||||
import { tap, expect } from '@pushrocks/tapbundle';
|
import { tap, expect } from '@push.rocks/tapbundle';
|
||||||
|
|
||||||
// Docker
|
// Docker
|
||||||
tap.test('expect create a Env Object', async () => {
|
tap.test('expect create a Env Object', async () => {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as smartstring from '../ts/index.js';
|
import * as smartstring from '../ts/index.js';
|
||||||
import { tap, expect } from '@pushrocks/tapbundle';
|
import { tap, expect } from '@push.rocks/tapbundle';
|
||||||
|
|
||||||
// Domain
|
// Domain
|
||||||
let testDomain: smartstring.Domain;
|
let testDomain: smartstring.Domain;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as smartstring from '../ts/index.js';
|
import * as smartstring from '../ts/index.js';
|
||||||
import { tap, expect } from '@pushrocks/tapbundle';
|
import { tap, expect } from '@push.rocks/tapbundle';
|
||||||
|
|
||||||
// git
|
// git
|
||||||
let testGit: smartstring.GitRepo;
|
let testGit: smartstring.GitRepo;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import * as smartstring from '../ts/index.js';
|
import * as smartstring from '../ts/index.js';
|
||||||
import { tap, expect } from '@pushrocks/tapbundle';
|
import { tap, expect } from '@push.rocks/tapbundle';
|
||||||
|
|
||||||
// indent
|
// indent
|
||||||
let testString = `
|
let testString = `
|
||||||
|
@ -1,16 +1,17 @@
|
|||||||
import { tap, expect } from '@pushrocks/tapbundle';
|
import { tap, expect } from '@push.rocks/tapbundle';
|
||||||
|
|
||||||
import * as smartstring from '../ts/index.js';
|
import * as smartstring from '../ts/index.js';
|
||||||
|
|
||||||
tap.test('should normalize a string', async () => {
|
tap.test('should normalize a string', async (toolsArg) => {
|
||||||
const testString = `
|
const testString = `
|
||||||
myawesome string;
|
myawesome string;
|
||||||
is indented with two spaces
|
is indented with two spaces
|
||||||
`;
|
`;
|
||||||
const normalizedString = smartstring.normalize.standard(testString);
|
const normalizedString = smartstring.normalize.standard(testString);
|
||||||
|
console.log(normalizedString);
|
||||||
|
|
||||||
expect(normalizedString).toEqual(
|
expect(normalizedString).toEqual(
|
||||||
`
|
`myawesome string;
|
||||||
myawesome string;
|
|
||||||
is indented with two spaces
|
is indented with two spaces
|
||||||
`
|
`
|
||||||
);
|
);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { tap, expect } from '@pushrocks/tapbundle';
|
import { tap, expect } from '@push.rocks/tapbundle';
|
||||||
import * as smartstring from '../ts/index.js';
|
import * as smartstring from '../ts/index.js';
|
||||||
|
|
||||||
tap.test('should state valuid utf8', async () => {
|
tap.test('should state valuid utf8', async () => {
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* autocreated commitinfo by @pushrocks/commitinfo
|
* autocreated commitinfo by @pushrocks/commitinfo
|
||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@pushrocks/smartstring',
|
name: '@push.rocks/smartstring',
|
||||||
version: '4.0.4',
|
version: '4.0.15',
|
||||||
description: 'handle strings in smart ways. TypeScript ready.'
|
description: 'handle strings in smart ways. TypeScript ready.'
|
||||||
}
|
}
|
||||||
|
@ -66,4 +66,14 @@ export let base64 = {
|
|||||||
decode: (stringArg: string) => {
|
decode: (stringArg: string) => {
|
||||||
return plugins.jsBase64.decode(stringArg);
|
return plugins.jsBase64.decode(stringArg);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param stringArg
|
||||||
|
* checks wether the string is base64 encoded
|
||||||
|
*/
|
||||||
|
isBase64: (stringArg: string) => {
|
||||||
|
const regex = /^([A-Za-z0-9+/]{4})*([A-Za-z0-9+/]{3}=|[A-Za-z0-9+/]{2}==)?$/;
|
||||||
|
return regex.test(stringArg);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
@ -26,7 +26,7 @@ export class GitRepo {
|
|||||||
* ---------------------------------------------- */
|
* ---------------------------------------------- */
|
||||||
const gitRegex = function (stringArg: string) {
|
const gitRegex = function (stringArg: string) {
|
||||||
const regexString =
|
const regexString =
|
||||||
/([a-zA-Z0-9\-\.]*)(?:\/|\:)([a-zA-Z0-9\-\.]*)(?:\/)([a-zA-Z0-9\-\.]*)(?:\.git)/;
|
/([a-zA-Z0-9\-_\.]*)(?:\/|\:)([a-zA-Z0-9\-_\.]*)(?:\/)([a-zA-Z0-9\-_\.]*)(?:\.git)/;
|
||||||
let regexMatches = regexString.exec(stringArg);
|
let regexMatches = regexString.exec(stringArg);
|
||||||
return regexMatches;
|
return regexMatches;
|
||||||
};
|
};
|
||||||
|
@ -10,13 +10,42 @@ export const replaceAll = (stringArg: string, searchPattern: string, replacement
|
|||||||
return stringArg.replace(new RegExp(searchPattern, 'g'), replacementString);
|
return stringArg.replace(new RegExp(searchPattern, 'g'), replacementString);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export interface INormalizeOptions {
|
||||||
|
stripLeadingTrailingEmptyLines?: boolean;
|
||||||
|
stripAllEmptyLines?: boolean;
|
||||||
|
stripIndent?: boolean;
|
||||||
|
normalizeNewline?: boolean;
|
||||||
|
replaceTabs?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* normalizes a string
|
* Normalizes a string
|
||||||
* @param stringArg
|
* @param stringArg
|
||||||
|
* @param options
|
||||||
*/
|
*/
|
||||||
export const standard = (stringArg: string): string => {
|
export const standard = (stringArg: string, options?: INormalizeOptions): string => {
|
||||||
let fix1 = plugins.stripIndent(stringArg); // fix indention
|
let result = stringArg;
|
||||||
let fix2 = plugins.normalizeNewline(fix1); // fix newlines
|
|
||||||
let fix3 = replaceAll(fix2, '\t/', ' '); // fix tabs
|
if (!options || options.stripIndent) {
|
||||||
return fix3;
|
result = plugins.stripIndent(result); // fix indention
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!options || options.normalizeNewline) {
|
||||||
|
result = result.replace(/\r\n/g, '\n'); // fix newlines
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!options || options.replaceTabs) {
|
||||||
|
result = replaceAll(result, '\t/', ' '); // fix tabs
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!options || options.stripLeadingTrailingEmptyLines) {
|
||||||
|
result = result.replace(/^\s*[\r\n]/gm, '').replace(/\s*[\r\n]$/gm, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!options || options.stripAllEmptyLines) {
|
||||||
|
result = result.replace(/^\s*[\r\n]/gm, '');
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
// node native
|
// node native
|
||||||
import * as smartenv from '@pushrocks/smartenv';
|
import * as smartenv from '@push.rocks/smartenv';
|
||||||
const smartenvInstance = new smartenv.Smartenv();
|
const smartenvInstance = new smartenv.Smartenv();
|
||||||
import * as isounique from '@pushrocks/isounique';
|
import * as isounique from '@push.rocks/isounique';
|
||||||
|
|
||||||
export { isounique };
|
export { isounique };
|
||||||
|
|
||||||
import { Buffer } from 'buffer';
|
|
||||||
if (smartenvInstance.isBrowser) {
|
|
||||||
globalThis.Buffer = Buffer;
|
|
||||||
}
|
|
||||||
import * as url from 'url';
|
import * as url from 'url';
|
||||||
export { url };
|
export { url };
|
||||||
|
|
||||||
@ -16,7 +12,6 @@ export { url };
|
|||||||
import { Base64 as jsBase64 } from 'js-base64';
|
import { Base64 as jsBase64 } from 'js-base64';
|
||||||
|
|
||||||
import stripIndent from 'strip-indent';
|
import stripIndent from 'strip-indent';
|
||||||
import normalizeNewline from 'normalize-newline';
|
|
||||||
import randomatic from 'randomatic';
|
import randomatic from 'randomatic';
|
||||||
|
|
||||||
export { jsBase64, stripIndent, normalizeNewline, randomatic };
|
export { jsBase64, stripIndent, randomatic };
|
||||||
|
@ -1,8 +1,12 @@
|
|||||||
import * as plugins from './smartstring.plugins.js';
|
import * as plugins from './smartstring.plugins.js';
|
||||||
import * as base64 from './smartstring.base64.js';
|
import * as base64 from './smartstring.base64.js';
|
||||||
|
|
||||||
export const isUtf8 = (stringArg: string) => {
|
export const isUtf8 = (stringArg: string): boolean => {
|
||||||
const bytes = Buffer.from(stringArg);
|
// Convert string to a Uint8Array. In browsers, this will be a bit more complex
|
||||||
|
// because we need to convert the string to a binary representation first.
|
||||||
|
const encoder = new TextEncoder();
|
||||||
|
const bytes = encoder.encode(stringArg);
|
||||||
|
|
||||||
let i = 0;
|
let i = 0;
|
||||||
while (i < bytes.length) {
|
while (i < bytes.length) {
|
||||||
if (
|
if (
|
||||||
@ -33,12 +37,14 @@ export const isUtf8 = (stringArg: string) => {
|
|||||||
0xa0 <= bytes[i + 1] &&
|
0xa0 <= bytes[i + 1] &&
|
||||||
bytes[i + 1] <= 0xbf &&
|
bytes[i + 1] <= 0xbf &&
|
||||||
0x80 <= bytes[i + 2] &&
|
0x80 <= bytes[i + 2] &&
|
||||||
bytes[i + 2] <= 0xbf) || // straight 3-byte
|
bytes[i + 2] <= 0xbf) ||
|
||||||
|
// straight 3-byte
|
||||||
(((0xe1 <= bytes[i] && bytes[i] <= 0xec) || bytes[i] === 0xee || bytes[i] === 0xef) &&
|
(((0xe1 <= bytes[i] && bytes[i] <= 0xec) || bytes[i] === 0xee || bytes[i] === 0xef) &&
|
||||||
0x80 <= bytes[i + 1] &&
|
0x80 <= bytes[i + 1] &&
|
||||||
bytes[i + 1] <= 0xbf &&
|
bytes[i + 1] <= 0xbf &&
|
||||||
0x80 <= bytes[i + 2] &&
|
0x80 <= bytes[i + 2] &&
|
||||||
bytes[i + 2] <= 0xbf) || // excluding surrogates
|
bytes[i + 2] <= 0xbf) ||
|
||||||
|
// excluding surrogates
|
||||||
(bytes[i] === 0xed &&
|
(bytes[i] === 0xed &&
|
||||||
0x80 <= bytes[i + 1] &&
|
0x80 <= bytes[i + 1] &&
|
||||||
bytes[i + 1] <= 0x9f &&
|
bytes[i + 1] <= 0x9f &&
|
||||||
@ -57,7 +63,8 @@ export const isUtf8 = (stringArg: string) => {
|
|||||||
0x80 <= bytes[i + 2] &&
|
0x80 <= bytes[i + 2] &&
|
||||||
bytes[i + 2] <= 0xbf &&
|
bytes[i + 2] <= 0xbf &&
|
||||||
0x80 <= bytes[i + 3] &&
|
0x80 <= bytes[i + 3] &&
|
||||||
bytes[i + 3] <= 0xbf) || // planes 4-15
|
bytes[i + 3] <= 0xbf) ||
|
||||||
|
// planes 4-15
|
||||||
(0xf1 <= bytes[i] &&
|
(0xf1 <= bytes[i] &&
|
||||||
bytes[i] <= 0xf3 &&
|
bytes[i] <= 0xf3 &&
|
||||||
0x80 <= bytes[i + 1] &&
|
0x80 <= bytes[i + 1] &&
|
||||||
@ -65,7 +72,8 @@ export const isUtf8 = (stringArg: string) => {
|
|||||||
0x80 <= bytes[i + 2] &&
|
0x80 <= bytes[i + 2] &&
|
||||||
bytes[i + 2] <= 0xbf &&
|
bytes[i + 2] <= 0xbf &&
|
||||||
0x80 <= bytes[i + 3] &&
|
0x80 <= bytes[i + 3] &&
|
||||||
bytes[i + 3] <= 0xbf) || // plane 16
|
bytes[i + 3] <= 0xbf) ||
|
||||||
|
// plane 16
|
||||||
(bytes[i] === 0xf4 &&
|
(bytes[i] === 0xf4 &&
|
||||||
0x80 <= bytes[i + 1] &&
|
0x80 <= bytes[i + 1] &&
|
||||||
bytes[i + 1] <= 0x8f &&
|
bytes[i + 1] <= 0x8f &&
|
||||||
@ -84,6 +92,7 @@ export const isUtf8 = (stringArg: string) => {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const isBase64 = (stringArg: string) => {
|
export const isBase64 = (stringArg: string) => {
|
||||||
const notBase64 = /[^A-Z0-9+\/=]/i;
|
const notBase64 = /[^A-Z0-9+\/=]/i;
|
||||||
const len = stringArg.length;
|
const len = stringArg.length;
|
||||||
|
@ -1,7 +1,14 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
"target": "ES2022",
|
"target": "ES2022",
|
||||||
"module": "ES2022",
|
"module": "NodeNext",
|
||||||
"moduleResolution": "nodenext"
|
"moduleResolution": "NodeNext",
|
||||||
}
|
"esModuleInterop": true,
|
||||||
|
"verbatimModuleSyntax": true
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"dist_*/**/*.d.ts"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user