Compare commits

..

153 Commits

Author SHA1 Message Date
jkunz 466eb0748b v4.1.1 2026-05-01 11:28:39 +00:00
jkunz 94f994ee6c fix(types): improve TypeScript strictness compatibility and modernize test exports 2026-05-01 11:28:39 +00:00
jkunz 0e0bd5cd6c 4.1.0 2025-09-12 18:57:32 +00:00
jkunz 1f3e170a88 feat(core): Introduce native implementations for Base64, random generation and normalization; remove runtime plugin dependencies; update tests, docs and package metadata 2025-09-12 18:57:31 +00:00
philkunz 6a7570de7b update description 2024-05-29 14:16:41 +02:00
philkunz 579e25fe5a update tsconfig 2024-04-14 18:26:18 +02:00
philkunz 871a22a801 update tsconfig 2024-04-01 21:41:29 +02:00
philkunz aacb4a6873 update npmextra.json: githost 2024-04-01 19:59:52 +02:00
philkunz 0ef1af7b86 update npmextra.json: githost 2024-03-30 21:48:52 +01:00
philkunz 2af0329918 4.0.15 2024-03-03 12:36:00 +01:00
philkunz b65a460ef2 fix(core): update 2024-03-03 12:35:59 +01:00
philkunz 3f5b0ebe1e 4.0.14 2024-03-01 23:34:44 +01:00
philkunz 6f2cedc1dd fix(core): update 2024-03-01 23:34:43 +01:00
philkunz 2c29ae3bf0 4.0.13 2024-01-08 14:41:44 +01:00
philkunz b26b8ed4a6 4.0.12 2024-01-08 14:24:22 +01:00
philkunz 0e6877d2d1 fix(core): update 2024-01-08 14:24:21 +01:00
philkunz 8a0c3fe906 4.0.11 2024-01-08 14:17:10 +01:00
philkunz ae861fa271 4.0.10 2023-12-27 21:57:45 +01:00
philkunz 3e78466e5f fix(core): update 2023-12-27 21:57:45 +01:00
philkunz eea19bcd89 4.0.9 2023-08-31 16:31:24 +02:00
philkunz 1fc95fcf0e fix(core): update 2023-08-31 16:31:23 +02:00
philkunz 14ba4465d9 4.0.8 2023-08-18 13:12:26 +02:00
philkunz 707e31d517 fix(core): update 2023-08-18 13:12:25 +02:00
philkunz 64d85e711a 4.0.7 2023-06-26 10:01:24 +02:00
philkunz 34a5cc9862 fix(core): update 2023-06-26 10:01:23 +02:00
philkunz d43d1ba212 4.0.6 2023-06-26 09:57:32 +02:00
philkunz 65e771f1ba fix(core): update 2023-06-26 09:57:32 +02:00
philkunz 5825a602ed 4.0.5 2022-09-13 19:23:11 +02:00
philkunz 5e961f7a5b fix(core): update 2022-09-13 19:23:11 +02:00
philkunz 36bcb9265a 4.0.4 2022-09-13 19:13:04 +02:00
philkunz 53bf2f3569 fix(core): update 2022-09-13 19:13:04 +02:00
philkunz 523ab7ee77 4.0.3 2022-09-13 18:47:19 +02:00
philkunz d60cc5430f fix(core): update 2022-09-13 18:47:19 +02:00
philkunz c0035bb4f3 4.0.2 2022-03-24 19:57:09 +01:00
philkunz 976f81420f fix(core): update 2022-03-24 19:57:09 +01:00
philkunz 1be144d099 4.0.1 2022-03-18 23:15:02 +01:00
philkunz 9d4b7a5292 4.0.0 2022-03-18 23:05:32 +01:00
philkunz 563d6f0ac3 3.0.26 2022-03-18 22:52:38 +01:00
philkunz 4da0aeb871 fix(core): update 2022-03-18 22:52:38 +01:00
philkunz 931defe98a 3.0.25 2022-03-18 22:50:25 +01:00
philkunz 1e6077ce34 fix(core): update 2022-03-18 22:50:24 +01:00
philkunz 8b1769d65e 3.0.24 2021-01-22 18:27:51 +00:00
philkunz 48878c0b38 fix(core): update 2021-01-22 18:27:50 +00:00
philkunz 76cfc8bec0 3.0.23 2021-01-22 14:46:04 +00:00
philkunz 7f3118c525 fix(core): update 2021-01-22 14:46:02 +00:00
philkunz 9d189d1b59 3.0.22 2020-12-31 04:42:47 +00:00
philkunz 0266afca8e fix(core): update 2020-12-31 04:42:46 +00:00
philkunz bef836fc83 3.0.21 2020-12-31 04:25:31 +00:00
philkunz 2bd1741893 fix(core): update 2020-12-31 04:25:31 +00:00
philkunz bd20512b10 3.0.20 2020-12-31 04:11:34 +00:00
philkunz 25d0ba8036 fix(core): update 2020-12-31 04:11:33 +00:00
philkunz c517652122 3.0.19 2020-12-31 03:56:41 +00:00
philkunz bf3e640307 fix(core): update 2020-12-31 03:56:40 +00:00
philkunz 08cb2392fa 3.0.18 2020-01-23 17:14:58 +00:00
philkunz 4e1fa4efab fix(core): update 2020-01-23 17:14:57 +00:00
philkunz 26d00bb9d3 3.0.17 2019-11-24 11:44:33 +00:00
philkunz fd27ed1a56 fix(core): update 2019-11-24 11:44:32 +00:00
philkunz 1f31fe9dc5 3.0.16 2019-11-24 11:44:21 +00:00
philkunz bd7888f7ce fix(core): update 2019-11-24 11:44:21 +00:00
philkunz 201812e182 3.0.15 2019-11-24 11:43:32 +00:00
philkunz 8dfa3f8965 fix(core): update 2019-11-24 11:43:32 +00:00
philkunz 43d50b746b 3.0.14 2019-10-10 18:24:04 +02:00
philkunz a1ee8f37d6 fix(core): update 2019-10-10 18:24:03 +02:00
philkunz 8d9c75e113 3.0.13 2019-10-10 18:14:08 +02:00
philkunz 8ff2a9d64a fix(core): update 2019-10-10 18:14:07 +02:00
philkunz 8665464416 3.0.12 2019-10-10 18:03:05 +02:00
philkunz e773644256 fix(core): update 2019-10-10 18:03:04 +02:00
philkunz 71fd0e614c 3.0.11 2019-10-10 17:28:24 +02:00
philkunz 55a5948a51 fix(core): update 2019-10-10 17:28:23 +02:00
philkunz 979375f08d 3.0.10 2019-04-16 08:55:37 +02:00
philkunz 95d5c6ceee fix(core): update 2019-04-16 08:55:37 +02:00
philkunz c92ece79ff 3.0.9 2019-04-16 08:54:27 +02:00
philkunz 7c625c4390 fix(core): update 2019-04-16 08:54:27 +02:00
philkunz 65fc64f6aa 3.0.8 2019-01-12 20:41:02 +01:00
philkunz 8cda8c55c0 fix(core): update 2019-01-12 20:41:01 +01:00
philkunz ec0b82de00 3.0.7 2019-01-12 20:19:17 +01:00
philkunz 5e69664f59 fix(core): update 2019-01-12 20:19:16 +01:00
philkunz f5838f6d6a 3.0.6 2019-01-12 20:12:59 +01:00
philkunz fb4a03ad37 fix(core): update 2019-01-12 20:12:58 +01:00
philkunz ceb6962a1c 3.0.5 2018-11-28 21:01:13 +01:00
philkunz ffe757d820 fix(dependencies and structure): update 2018-11-28 21:01:13 +01:00
philkunz 60eb4b6b6e 3.0.4 2018-08-14 00:21:55 +02:00
philkunz f73d394d35 fix(ci): reduce build dependencies 2018-08-14 00:21:55 +02:00
philkunz 212f41e00b 3.0.3 2018-08-14 00:19:32 +02:00
philkunz 59847dd287 fix(ci): fix build step 2018-08-14 00:19:32 +02:00
philkunz 7fa2fb1e74 3.0.2 2018-08-14 00:17:37 +02:00
philkunz 355f7442ca fix(dependencies): update test framework 2018-08-14 00:17:37 +02:00
philkunz 88af0ab9aa 3.0.1 2018-08-13 22:27:22 +02:00
philkunz 5b5bcd804f fix(dependencies): fix obsolete dependency on typings-global 2018-08-13 22:27:21 +02:00
philkunz 8c894ea1c1 3.0.0 2018-07-21 14:37:39 +02:00
philkunz 62336aa2cf BREAKING CHANGE(scope): change scope to @pushrocks 2018-07-21 14:37:39 +02:00
philkunz e9899e5451 2.0.28 2017-10-26 15:24:13 +02:00
philkunz 235f380139 refactor to const 2017-10-26 15:24:10 +02:00
philkunz 4a94ce3038 2.0.27 2017-10-11 15:18:30 +02:00
philkunz 7c4c787539 add npmextra.json 2017-10-11 15:18:26 +02:00
philkunz 714e3a162c 2.0.26 2017-10-11 14:52:24 +02:00
philkunz 099bf9b270 add create module 2017-10-11 14:52:22 +02:00
philkunz 83279a9c19 2.0.25 2017-10-05 15:56:03 +02:00
philkunz 55d679e5ee update normalize of smartstring 2017-10-05 15:55:59 +02:00
philkunz 974bf90703 2.0.24 2017-02-19 14:34:04 +01:00
philkunz 93029d1aae update README 2017-02-19 14:33:00 +01:00
philkunz 3a7740024c 2.0.23 2017-02-19 14:30:51 +01:00
philkunz a412285862 update dependencies and allow dots in git user and repo names 2017-02-19 14:09:39 +01:00
philkunz a57bd446d0 2.0.22 2016-11-02 23:02:00 +01:00
philkunz afe8d5bc1b improve README 2016-11-02 23:01:56 +01:00
philkunz 576e81588d 2.0.21 2016-11-02 22:55:20 +01:00
philkunz 76c590b045 improve README 2016-11-02 22:55:17 +01:00
philkunz bb7caa36ea 2.0.20 2016-11-01 19:00:35 +01:00
philkunz a3a51bf0ca small export fix 2016-11-01 19:00:32 +01:00
philkunz 1684eae1e8 expose base64 functions seperate from class 2016-11-01 18:59:43 +01:00
philkunz 39ce541532 2.0.19 2016-11-01 00:37:47 +01:00
philkunz c2a4f05b33 2.0.18 2016-11-01 00:22:52 +01:00
philkunz 3858127968 add Base64 handling 2016-11-01 00:22:38 +01:00
philkunz 68d0124c24 2.0.17 2016-08-03 15:42:39 +02:00
philkunz 16f41a7d63 Merge branch 'master' of gitlab.com:pushrocks/smartstring 2016-08-03 15:42:24 +02:00
philkunz d13dfc9e76 2.0.16 2016-08-03 15:41:54 +02:00
philkunz 942f6b37cf fix docker env null problem 2016-08-03 15:41:36 +02:00
Phil Kunz 211c7c3308 Update .gitlab-ci.yml 2016-07-22 22:34:51 +00:00
Phil Kunz a55d6d2221 Update README.md 2016-07-21 22:17:56 +00:00
philkunz 98ca73d0c7 2.0.15 2016-07-17 17:30:35 +02:00
philkunz ffedc7f601 switched to ES6 2016-07-17 17:30:26 +02:00
LosslessBot 8344fdf7b1 2.0.14 2016-07-08 01:49:41 +02:00
LosslessBot 543dc98961 ignore empty lines for indent.normalize() 2016-07-08 01:49:32 +02:00
LosslessBot 9c60105685 2.0.13 2016-07-08 00:57:27 +02:00
LosslessBot bdccf2c3a1 now has working indent module 2016-07-08 00:57:11 +02:00
philkunz 34d6df0923 write some tests 2016-07-07 23:35:15 +02:00
philkunz 3d3b07b7cb implement deindent 2016-07-07 19:53:14 +02:00
LosslessBot 00004f70d6 2.0.12 2016-07-06 10:06:44 +02:00
LosslessBot 2d263244c7 recompile 2016-07-06 10:06:39 +02:00
LosslessBot 8cb1405d99 2.0.11 2016-07-06 10:06:15 +02:00
LosslessBot d357d6e52d merged 2016-07-06 10:06:10 +02:00
LosslessBot c124f90a91 prepare indent functionality 2016-07-06 10:04:25 +02:00
philkunz 4bcf9f941e 2.0.10 2016-06-22 12:55:32 +02:00
philkunz afb204325b fix Domain Regex to include - and _ 2016-06-22 12:55:29 +02:00
philkunz cefbb6eecd 2.0.9 2016-06-21 18:59:08 +02:00
philkunz c6a1a45812 fix Domain.fullName 2016-06-21 18:59:05 +02:00
philkunz 00a892ee82 2.0.8 2016-06-21 17:11:50 +02:00
philkunz 0eb6d13be9 testing legacy 2016-06-21 17:11:19 +02:00
philkunz c34f9611f9 2.0.7 2016-06-21 17:09:26 +02:00
philkunz 820360a220 now evealuating Domains that have no protocol specified 2016-06-21 17:09:17 +02:00
philkunz 3893985bb2 2.0.6 2016-06-05 09:35:56 +02:00
philkunz 33e19c54d9 fix gitlab.yml 2016-06-05 09:35:42 +02:00
philkunz 074996433e 2.0.5 2016-06-05 09:31:14 +02:00
philkunz 6a803f1db9 fix git regex 2016-06-05 09:31:10 +02:00
philkunz 927262d6d4 update yml 2016-05-30 05:50:30 +02:00
philkunz df39887de9 update deps 2016-05-29 21:45:22 +02:00
philkunz 2b52b76ac6 add gitlab ci 2016-05-29 21:37:49 +02:00
Philipp Kunz 136a06ff68 2.0.4 2016-05-25 09:10:54 +02:00
Philipp Kunz 44bb4fa9ae update README 2016-05-25 09:10:43 +02:00
Philipp Kunz 93d5fc3070 2.0.3 2016-05-25 09:05:13 +02:00
Philipp Kunz 08cd48b7bc Add authors note 2016-05-25 09:05:04 +02:00
Philipp Kunz bb17908ef5 2.0.2 2016-05-25 09:02:45 +02:00
Philipp Kunz 3b8e31c8b0 improve README and add app veyor 2016-05-25 09:02:24 +02:00
52 changed files with 10265 additions and 494 deletions
+66
View 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
View 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
+19 -6
View File
@@ -1,7 +1,20 @@
.idea/
.nogit/
# artifacts
coverage/
docs/
node_modules
ts/**/*.js
ts/**/*.js.map
ts/typings/
public/
pages/
# installs
node_modules/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_*/
# custom
+41
View File
@@ -0,0 +1,41 @@
{
"@git.zone/cli": {
"projectType": "npm",
"module": {
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "smartstring",
"description": "A library for handling strings in smart ways, including manipulation and encoding, with TypeScript support.",
"npmPackagename": "@push.rocks/smartstring",
"license": "MIT",
"keywords": [
"string manipulation",
"encode",
"decode",
"base64",
"indentation",
"normalization",
"regex",
"random string",
"cryptographic string",
"domain parsing",
"git repository parsing",
"docker environment parsing"
]
},
"release": {
"registries": [
"https://verdaccio.lossless.digital",
"https://registry.npmjs.org"
],
"accessLevel": "public"
}
},
"@git.zone/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"
},
"@ship.zone/szci": {
"npmGlobalTools": [],
"npmRegistryUrl": "registry.npmjs.org"
}
}
-12
View File
@@ -1,12 +0,0 @@
language: node_js
node_js:
- '4.3.0'
- 'stable'
deploy:
provider: npm
email: npm@lossless.digital
api_key:
secure: oKx1gdYYBnaoUcpxn3WM4SdZdInIYaa3ZgbXLSh88K+PjbcSw3NNbYEnAtWFV1eAQQchDjOHId4D1Ne68DtJb5umahvhYoejtZzawjPaa6Uyi46VPk31wXYzZJyadiyefuwOhLLMM4i3yzYwEC2BeTpbU8Tvaj6B42DoySKNGUnSF9+K2wsFNp13mRje6PLe+fjo+9H4CEKLwf74alwvAWd/PLzv47KKdCZ4/9zX7TxevrIBNie+n6VxjqXm/dTv9k7J3dCunojehBr9X9sn1sd8mR+FexjcgfCA2dz8ViP8qZCslzZixGVuasmjpQH9OabrlOfQ6e+Hs4puv+U7s53SVa9nWntiYHloT29UKCPG6ofuDFq5Nd+1PCNvPfrh99F87IKTOw9DQ9Lx7Q//To4LrbnsC85/uHgkWHhbr/ZGax7wuX9og1rem1MSjYr7gQ1sx9edtDSQe3Yjhi22xDREL5/uCbnThmrd1P44CtAU7UG4TQvnHADFqi4Oogf/VBQvsC+aUJPSfZuoxX31yCYuNToH65j1Vblj9tYuPdHSriPj2OdxbuWh68lpgsh7K64Imb++3oKjh3fKZEzeJsByI+QytyUwO/Qu1c6whlkyv8yMyoaD0WARufU+zcG4P7j4rFlAO/CoezSd6l5HBUiXJNe7XniIi6KZjA1zkZc=
on:
tags: true
repo: pushrocks/smartstring
+11
View File
@@ -0,0 +1,11 @@
{
"version": "0.2.0",
"configurations": [
{
"command": "npm test",
"name": "Run npm test",
"request": "launch",
"type": "node-terminal"
}
]
}
+26
View File
@@ -0,0 +1,26 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone",
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}
}
}
}
]
}
-11
View File
@@ -1,11 +0,0 @@
# smartstring
handle strings in smart ways.
## Status
[![Build Status](https://travis-ci.org/pushrocks/smartstring.svg?branch=master)](https://travis-ci.org/pushrocks/smartstring)
[![Dependency Status](https://david-dm.org/pushrocks/smartstring.svg)](https://david-dm.org/pushrocks/smartstring)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/smartstring/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/smartstring/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/smartstring/badges/code.svg)](https://www.bithound.io/github/pushrocks/smartstring)
## Usage
### Git
+104
View File
@@ -0,0 +1,104 @@
# Changelog
## 2026-05-01 - 4.1.1 - fix(types)
improve TypeScript strictness compatibility and modernize test exports
- enable stricter TypeScript compilation with explicit typings and safer null handling across base64, docker, domain, git, create, and indent modules
- update test files to export tap.start() for compatibility with the newer test tooling
- refresh build and test scripts and upgrade @git.zone tooling and Node type dependencies
- align project metadata and package contents with smartconfig-based release configuration
## 2025-09-12 - 4.1.0 - feat(core)
Introduce native implementations for Base64, random generation and normalization; remove runtime plugin dependencies; update tests, docs and package metadata
- Implemented a cross-platform universal Base64 encoder/decoder and replaced usage of external js-base64 with the internal implementation
- Added a custom, cross-platform random string generator (uses crypto.getRandomValues when available) and removed dependency on randomatic / crypto-random-string
- Replaced strip-indent usage with an internal stripIndent implementation in normalize utilities
- Switched domain parsing to use the standard URL class instead of external url.parse
- Simplified ts/smartstring.plugins.ts to only export @push.rocks/isounique and removed several plugin re-exports (js-base64, strip-indent, randomatic, url, smartenv)
- Updated test imports to use @git.zone/tstest/tapbundle
- Expanded and updated README with full usage, examples and API reference
- Updated package.json: trimmed dependencies, bumped @git.zone/tstest version, added packageManager (pnpm) entry and adjusted files/browserslist
- Added .claude/settings.local.json
## 2024-05-29 - 4.0.15 - maintenance
Package metadata and TypeScript configuration updates.
- Updated package description.
- TypeScript configuration (tsconfig) adjustments.
- npmextra.json updated (githost entries).
## 2024-03-03 - 4.0.14 → 4.0.1 - maintenance & core fixes
Routine core fixes, small updates and version bumps across the 4.0.x series.
- Multiple "fix(core): update" commits addressing internal/core issues.
- Several version-only releases (patch bumps and releases with minimal change notes).
## 2022-03-18 - 4.0.2 → 3.0.26 - release consolidation
Consolidated releases and small fixes spanning late 2020early 2022.
- Several patch releases with minor fixes and version bumps.
- Routine maintenance and stability improvements.
## 2018-11-28 - 3.0.4 → 3.0.0 - CI & dependency fixes
Improvements to build/CI and dependency cleanups for the 3.0.x line.
- fix(dependencies and structure): updated dependencies and project structure (3.0.4).
- fix(ci): reduced build dependencies and fixed build steps (3.0.3, 3.0.2).
- fix(dependencies): updated test framework and removed obsolete dependency on typings-global (3.0.1, 3.0.0).
- Numerous small fixes and version bump releases across 3.0.x.
## 2018-07-21 - 2.0.28 - BREAKING CHANGE: package scope
Breaking change: package scope changed.
- Changed package scope to @pushrocks (BREAKING CHANGE).
## 2017-10-26 - 2.0.27 → 2.0.25 - code quality & npm metadata
Small refactors and npm metadata additions.
- Refactor to use const (2.0.27).
- Added npmextra.json (2.0.26).
- Added create module (2.0.25).
## 2016-10-31 - 2.0.19 → 2.0.17 - Base64 & exports
Added Base64 handling and improved exports.
- Added Base64 handling and exposed base64 functions separate from class (2.0.172.0.19).
- Small export fixes.
## 2016-07-17 - 2.0.14 → 2.0.12 - ES6, indent/deindent, tests
Feature enhancements around string indentation and ES6 migration.
- Switched codebase to ES6 (2.0.14).
- Implemented deindent and working indent module; added tests (2.0.12).
- Prep work for indent functionality and recompiled builds (2.0.11, 2.0.10).
## 2016-06-21 - 2.0.9 → 2.0.6 - domain handling improvements
Domain parsing and regex improvements.
- Fixed Domain regex to include '-' and '_' and improved fullName handling (2.0.9, 2.0.8).
- Now evaluates Domains without protocol specified (2.0.6).
## 2016-05-25 - 2.0.4 → 2.0.0 - core features & CI/docs
Major 2.0.0 work and related improvements.
- Now computes zoneName and detects protocol (2.0.0).
- Added authors note, improved README and CI (AppVeyor, GitLab CI) across several commits.
- Multiple small fixes, dependency updates and YML/CI tweaks (2.0.4, 2.0.3, 2.0.2, 2.0.1).
## 2016-05-16 - 1.0.3 → 1.0.1 - parser & typings fixes
Parser improvements and TypeScript declaration fixes.
- Correctly parsing a Domain and structure updates (1.0.3).
- Fixes for typings and declaration issues (1.0.2, 1.0.1).
## 2016-04-15 - 1.0.0 → 0.0.3 - initial stable release
Initial stable release artifacts.
- Added TypeScript regex section and performed first 1.0.0 release (1.0.0).
- Prior 0.0.x preparatory releases.
## 2016-02-23 - 0.0.0 → initial - project initialization
Project initialization and first commits.
- Initial commit and early CI/travis updates.
-7
View File
@@ -1,7 +0,0 @@
import "typings-global";
import SmartstringDocker = require("./smartstring.docker");
import SmartstringTypescript = require("./smartstring.typescript");
export { Domain } from "./smartstring.domain";
export { GitRepo } from "./smartstring.git";
export declare let docker: typeof SmartstringDocker;
export declare let typescript: typeof SmartstringTypescript;
-12
View File
@@ -1,12 +0,0 @@
"use strict";
require("typings-global");
var SmartstringDocker = require("./smartstring.docker");
var SmartstringTypescript = require("./smartstring.typescript");
var smartstring_domain_1 = require("./smartstring.domain");
exports.Domain = smartstring_domain_1.Domain;
var smartstring_git_1 = require("./smartstring.git");
exports.GitRepo = smartstring_git_1.GitRepo;
exports.docker = SmartstringDocker;
exports.typescript = SmartstringTypescript;
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImluZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQSxRQUFPLGdCQUNQLENBQUMsQ0FEc0I7QUFDdkIsSUFBTyxpQkFBaUIsV0FBVyxzQkFBc0IsQ0FBQyxDQUFDO0FBQzNELElBQU8scUJBQXFCLFdBQVcsMEJBQTBCLENBQUMsQ0FBQztBQUVuRSxtQ0FBcUIsc0JBQXNCLENBQUM7QUFBcEMsNkNBQW9DO0FBQzVDLGdDQUFzQixtQkFBbUIsQ0FBQztBQUFsQyw0Q0FBa0M7QUFDL0IsY0FBTSxHQUFHLGlCQUFpQixDQUFDO0FBQzNCLGtCQUFVLEdBQUcscUJBQXFCLENBQUMiLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgXCJ0eXBpbmdzLWdsb2JhbFwiXHJcbmltcG9ydCBTbWFydHN0cmluZ0RvY2tlciA9IHJlcXVpcmUoXCIuL3NtYXJ0c3RyaW5nLmRvY2tlclwiKTtcclxuaW1wb3J0IFNtYXJ0c3RyaW5nVHlwZXNjcmlwdCA9IHJlcXVpcmUoXCIuL3NtYXJ0c3RyaW5nLnR5cGVzY3JpcHRcIik7XHJcblxyXG5leHBvcnQge0RvbWFpbn0gZnJvbSBcIi4vc21hcnRzdHJpbmcuZG9tYWluXCI7XHJcbmV4cG9ydCB7R2l0UmVwb30gZnJvbSBcIi4vc21hcnRzdHJpbmcuZ2l0XCI7XHJcbmV4cG9ydCBsZXQgZG9ja2VyID0gU21hcnRzdHJpbmdEb2NrZXI7XHJcbmV4cG9ydCBsZXQgdHlwZXNjcmlwdCA9IFNtYXJ0c3RyaW5nVHlwZXNjcmlwdDsiXX0=
-7
View File
@@ -1,7 +0,0 @@
import "typings-global";
/**
* converts an erray of env strings from docker remote api to an usable object.
* @param envArrayArg
* @returns {}
*/
export declare let makeEnvObject: (envArrayArg: string[]) => {};
-19
View File
@@ -1,19 +0,0 @@
"use strict";
require("typings-global");
/**
* converts an erray of env strings from docker remote api to an usable object.
* @param envArrayArg
* @returns {}
*/
exports.makeEnvObject = function (envArrayArg) {
var returnObject = {};
var regexString = /(.*)=(.*)/;
for (var envKey in envArrayArg) {
var regexMatches = regexString.exec(envArrayArg[envKey]);
returnObject[regexMatches[1]] = regexMatches[2];
}
;
return returnObject;
};
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3RyaW5nLmRvY2tlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFDUCxDQUFDLENBRHNCO0FBR3ZCOzs7O0dBSUc7QUFDUSxxQkFBYSxHQUFHLFVBQVMsV0FBb0I7SUFDcEQsSUFBSSxZQUFZLEdBQUcsRUFBRSxDQUFDO0lBQ3RCLElBQUksV0FBVyxHQUFHLFdBQVcsQ0FBQztJQUM5QixHQUFHLENBQUEsQ0FBQyxJQUFJLE1BQU0sSUFBSSxXQUFXLENBQUMsQ0FBQSxDQUFDO1FBQzNCLElBQUksWUFBWSxHQUFHLFdBQVcsQ0FBQyxJQUFJLENBQUMsV0FBVyxDQUFDLE1BQU0sQ0FBQyxDQUFDLENBQUM7UUFDekQsWUFBWSxDQUFDLFlBQVksQ0FBQyxDQUFDLENBQUMsQ0FBQyxHQUFHLFlBQVksQ0FBQyxDQUFDLENBQUMsQ0FBQztJQUNwRCxDQUFDO0lBQUEsQ0FBQztJQUNGLE1BQU0sQ0FBQyxZQUFZLENBQUM7QUFDeEIsQ0FBQyxDQUFDIiwiZmlsZSI6InNtYXJ0c3RyaW5nLmRvY2tlci5qcyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBcInR5cGluZ3MtZ2xvYmFsXCJcclxuaW1wb3J0IHBsdWdpbnMgPSByZXF1aXJlKFwiLi9zbWFydHN0cmluZy5wbHVnaW5zXCIpO1xyXG5cclxuLyoqXHJcbiAqIGNvbnZlcnRzIGFuIGVycmF5IG9mIGVudiBzdHJpbmdzIGZyb20gZG9ja2VyIHJlbW90ZSBhcGkgdG8gYW4gdXNhYmxlIG9iamVjdC5cclxuICogQHBhcmFtIGVudkFycmF5QXJnXHJcbiAqIEByZXR1cm5zIHt9XHJcbiAqL1xyXG5leHBvcnQgbGV0IG1ha2VFbnZPYmplY3QgPSBmdW5jdGlvbihlbnZBcnJheUFyZzpzdHJpbmdbXSl7XHJcbiAgICBsZXQgcmV0dXJuT2JqZWN0ID0ge307XHJcbiAgICBsZXQgcmVnZXhTdHJpbmcgPSAvKC4qKT0oLiopLztcclxuICAgIGZvcihsZXQgZW52S2V5IGluIGVudkFycmF5QXJnKXtcclxuICAgICAgICBsZXQgcmVnZXhNYXRjaGVzID0gcmVnZXhTdHJpbmcuZXhlYyhlbnZBcnJheUFyZ1tlbnZLZXldKTtcclxuICAgICAgICByZXR1cm5PYmplY3RbcmVnZXhNYXRjaGVzWzFdXSA9IHJlZ2V4TWF0Y2hlc1syXTtcclxuICAgIH07XHJcbiAgICByZXR1cm4gcmV0dXJuT2JqZWN0O1xyXG59OyJdfQ==
-15
View File
@@ -1,15 +0,0 @@
import "typings-global";
export declare class Domain {
fullName: string;
level1: string;
level2: string;
level3: string;
level4: string;
level5: string;
protocol: string;
zoneName: string;
topLevel: string;
domainName: any;
subDomain: any;
constructor(domainStringArg: string);
}
-38
View File
@@ -1,38 +0,0 @@
"use strict";
require("typings-global");
var Domain = (function () {
function Domain(domainStringArg) {
this.fullName = domainStringArg;
var regexMatches = domainRegex(domainStringArg);
this.level1 = regexMatches[0];
this.level2 = regexMatches[1];
this.level3 = regexMatches[2];
this.level4 = regexMatches[3];
this.level5 = regexMatches[4];
this.protocol = protocolRegex(domainStringArg)[1];
this.zoneName = this.level2 + "." + this.level1;
// aliases
this.topLevel = this.level1;
this.domainName = this.level2;
this.subDomain = this.level3;
}
return Domain;
}());
exports.Domain = Domain;
var domainRegex = function (stringArg) {
var regexString = /([a-zA-Z0-9]*)\.{0,1}([a-zA-Z0-9]*)\.{0,1}([a-zA-Z0-9]*)\.{0,1}([a-zA-Z0-9]*)\.{0,1}([a-zA-Z0-9]*)\.{0,1}$/;
var regexMatches = regexString.exec(stringArg);
regexMatches.reverse();
var regexMatchesFiltered = regexMatches.filter(function (stringArg) {
return (stringArg != "");
});
return regexMatchesFiltered;
};
var protocolRegex = function (stringArg) {
var regexString = /^([a-zA-Z0-9]*):\/\//;
var regexMatches = regexString.exec(stringArg);
console.log(regexMatches);
return regexMatches;
};
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3RyaW5nLmRvbWFpbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsUUFBTyxnQkFDUCxDQUFDLENBRHNCO0FBR3ZCO0lBYUksZ0JBQVksZUFBc0I7UUFDOUIsSUFBSSxDQUFDLFFBQVEsR0FBRyxlQUFlLENBQUM7UUFDaEMsSUFBSSxZQUFZLEdBQUcsV0FBVyxDQUFDLGVBQWUsQ0FBQyxDQUFDO1FBQ2hELElBQUksQ0FBQyxNQUFNLEdBQUcsWUFBWSxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBQzlCLElBQUksQ0FBQyxNQUFNLEdBQUcsWUFBWSxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBQzlCLElBQUksQ0FBQyxNQUFNLEdBQUcsWUFBWSxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBQzlCLElBQUksQ0FBQyxNQUFNLEdBQUcsWUFBWSxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBQzlCLElBQUksQ0FBQyxNQUFNLEdBQUcsWUFBWSxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBQzlCLElBQUksQ0FBQyxRQUFRLEdBQUcsYUFBYSxDQUFDLGVBQWUsQ0FBQyxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBQ2xELElBQUksQ0FBQyxRQUFRLEdBQUcsSUFBSSxDQUFDLE1BQU0sR0FBRyxHQUFHLEdBQUcsSUFBSSxDQUFDLE1BQU0sQ0FBQztRQUVoRCxVQUFVO1FBQ1YsSUFBSSxDQUFDLFFBQVEsR0FBRyxJQUFJLENBQUMsTUFBTSxDQUFDO1FBQzVCLElBQUksQ0FBQyxVQUFVLEdBQUcsSUFBSSxDQUFDLE1BQU0sQ0FBQztRQUM5QixJQUFJLENBQUMsU0FBUyxHQUFHLElBQUksQ0FBQyxNQUFNLENBQUM7SUFDakMsQ0FBQztJQUNMLGFBQUM7QUFBRCxDQTdCQSxBQTZCQyxJQUFBO0FBN0JZLGNBQU0sU0E2QmxCLENBQUE7QUFHRCxJQUFJLFdBQVcsR0FBRyxVQUFTLFNBQWdCO0lBQ3ZDLElBQUksV0FBVyxHQUFHLDRHQUE0RyxDQUFDO0lBQy9ILElBQUksWUFBWSxHQUFHLFdBQVcsQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFDLENBQUM7SUFDL0MsWUFBWSxDQUFDLE9BQU8sRUFBRSxDQUFDO0lBQ3ZCLElBQUksb0JBQW9CLEdBQUcsWUFBWSxDQUFDLE1BQU0sQ0FBQyxVQUFTLFNBQWdCO1FBQ3BFLE1BQU0sQ0FBQSxDQUFDLFNBQVMsSUFBSSxFQUFFLENBQUMsQ0FBQztJQUM1QixDQUFDLENBQUMsQ0FBQztJQUNILE1BQU0sQ0FBQyxvQkFBb0IsQ0FBQztBQUNoQyxDQUFDLENBQUM7QUFFRixJQUFJLGFBQWEsR0FBRyxVQUFTLFNBQWdCO0lBQ3pDLElBQUksV0FBVyxHQUFHLHNCQUFzQixDQUFDO0lBQ3pDLElBQUksWUFBWSxHQUFHLFdBQVcsQ0FBQyxJQUFJLENBQUMsU0FBUyxDQUFDLENBQUM7SUFDL0MsT0FBTyxDQUFDLEdBQUcsQ0FBQyxZQUFZLENBQUMsQ0FBQztJQUMxQixNQUFNLENBQUMsWUFBWSxDQUFDO0FBQ3hCLENBQUMsQ0FBQSIsImZpbGUiOiJzbWFydHN0cmluZy5kb21haW4uanMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgXCJ0eXBpbmdzLWdsb2JhbFwiXHJcbmltcG9ydCBwbHVnaW5zID0gcmVxdWlyZShcIi4vc21hcnRzdHJpbmcucGx1Z2luc1wiKTtcclxuXHJcbmV4cG9ydCBjbGFzcyBEb21haW4ge1xyXG4gICAgZnVsbE5hbWU6c3RyaW5nO1xyXG4gICAgbGV2ZWwxOnN0cmluZztcclxuICAgIGxldmVsMjpzdHJpbmc7XHJcbiAgICBsZXZlbDM6c3RyaW5nO1xyXG4gICAgbGV2ZWw0OnN0cmluZztcclxuICAgIGxldmVsNTpzdHJpbmc7XHJcbiAgICBwcm90b2NvbDpzdHJpbmc7XHJcbiAgICB6b25lTmFtZTpzdHJpbmc7XHJcbiAgICAvL2FsaWFzZXNcclxuICAgIHRvcExldmVsOnN0cmluZztcclxuICAgIGRvbWFpbk5hbWU7XHJcbiAgICBzdWJEb21haW47XHJcbiAgICBjb25zdHJ1Y3Rvcihkb21haW5TdHJpbmdBcmc6c3RyaW5nKXtcclxuICAgICAgICB0aGlzLmZ1bGxOYW1lID0gZG9tYWluU3RyaW5nQXJnO1xyXG4gICAgICAgIGxldCByZWdleE1hdGNoZXMgPSBkb21haW5SZWdleChkb21haW5TdHJpbmdBcmcpO1xyXG4gICAgICAgIHRoaXMubGV2ZWwxID0gcmVnZXhNYXRjaGVzWzBdO1xyXG4gICAgICAgIHRoaXMubGV2ZWwyID0gcmVnZXhNYXRjaGVzWzFdO1xyXG4gICAgICAgIHRoaXMubGV2ZWwzID0gcmVnZXhNYXRjaGVzWzJdO1xyXG4gICAgICAgIHRoaXMubGV2ZWw0ID0gcmVnZXhNYXRjaGVzWzNdO1xyXG4gICAgICAgIHRoaXMubGV2ZWw1ID0gcmVnZXhNYXRjaGVzWzRdO1xyXG4gICAgICAgIHRoaXMucHJvdG9jb2wgPSBwcm90b2NvbFJlZ2V4KGRvbWFpblN0cmluZ0FyZylbMV07XHJcbiAgICAgICAgdGhpcy56b25lTmFtZSA9IHRoaXMubGV2ZWwyICsgXCIuXCIgKyB0aGlzLmxldmVsMTsgXHJcbiAgICAgICAgXHJcbiAgICAgICAgLy8gYWxpYXNlc1xyXG4gICAgICAgIHRoaXMudG9wTGV2ZWwgPSB0aGlzLmxldmVsMTtcclxuICAgICAgICB0aGlzLmRvbWFpbk5hbWUgPSB0aGlzLmxldmVsMjtcclxuICAgICAgICB0aGlzLnN1YkRvbWFpbiA9IHRoaXMubGV2ZWwzO1xyXG4gICAgfVxyXG59XHJcblxyXG5cclxubGV0IGRvbWFpblJlZ2V4ID0gZnVuY3Rpb24oc3RyaW5nQXJnOnN0cmluZyl7XHJcbiAgICBsZXQgcmVnZXhTdHJpbmcgPSAvKFthLXpBLVowLTldKilcXC57MCwxfShbYS16QS1aMC05XSopXFwuezAsMX0oW2EtekEtWjAtOV0qKVxcLnswLDF9KFthLXpBLVowLTldKilcXC57MCwxfShbYS16QS1aMC05XSopXFwuezAsMX0kLztcclxuICAgIGxldCByZWdleE1hdGNoZXMgPSByZWdleFN0cmluZy5leGVjKHN0cmluZ0FyZyk7XHJcbiAgICByZWdleE1hdGNoZXMucmV2ZXJzZSgpO1xyXG4gICAgbGV0IHJlZ2V4TWF0Y2hlc0ZpbHRlcmVkID0gcmVnZXhNYXRjaGVzLmZpbHRlcihmdW5jdGlvbihzdHJpbmdBcmc6c3RyaW5nKXtcclxuICAgICAgICByZXR1cm4oc3RyaW5nQXJnICE9IFwiXCIpO1xyXG4gICAgfSk7XHJcbiAgICByZXR1cm4gcmVnZXhNYXRjaGVzRmlsdGVyZWQ7XHJcbn07XHJcblxyXG5sZXQgcHJvdG9jb2xSZWdleCA9IGZ1bmN0aW9uKHN0cmluZ0FyZzpzdHJpbmcpe1xyXG4gICAgbGV0IHJlZ2V4U3RyaW5nID0gL14oW2EtekEtWjAtOV0qKTpcXC9cXC8vO1xyXG4gICAgbGV0IHJlZ2V4TWF0Y2hlcyA9IHJlZ2V4U3RyaW5nLmV4ZWMoc3RyaW5nQXJnKTtcclxuICAgIGNvbnNvbGUubG9nKHJlZ2V4TWF0Y2hlcyk7XHJcbiAgICByZXR1cm4gcmVnZXhNYXRjaGVzO1xyXG59Il19
-10
View File
@@ -1,10 +0,0 @@
import "typings-global";
export declare class GitRepo {
host: string;
user: string;
repo: string;
accessToken: string;
sshUrl: string;
httpsUrl: string;
constructor(stringArg: string, tokenArg?: string);
}
-51
View File
File diff suppressed because one or more lines are too long
-2
View File
@@ -1,2 +0,0 @@
import "typings-global";
export import beautylog = require("beautylog");
-5
View File
@@ -1,5 +0,0 @@
"use strict";
require("typings-global");
exports.beautylog = require("beautylog");
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3RyaW5nLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBRVAsQ0FBQyxDQUZzQjtBQUVULGlCQUFTLFdBQVcsV0FBVyxDQUFDLENBQUMiLCJmaWxlIjoic21hcnRzdHJpbmcucGx1Z2lucy5qcyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBcInR5cGluZ3MtZ2xvYmFsXCJcclxuXHJcbmV4cG9ydCBpbXBvcnQgYmVhdXR5bG9nID0gcmVxdWlyZShcImJlYXV0eWxvZ1wiKTsiXX0=
-2
View File
@@ -1,2 +0,0 @@
import "typings-global";
export declare let regexReferencePath: RegExp;
-5
View File
@@ -1,5 +0,0 @@
"use strict";
require("typings-global");
exports.regexReferencePath = /\/\/\/\s*<reference\s+path\s*=\s*["|'].*["|']\s*\/>\s*[\\n]?/;
//# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNtYXJ0c3RyaW5nLnR5cGVzY3JpcHQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLFFBQU8sZ0JBQ1AsQ0FBQyxDQURzQjtBQUdaLDBCQUFrQixHQUFHLDhEQUE4RCxDQUFBIiwiZmlsZSI6InNtYXJ0c3RyaW5nLnR5cGVzY3JpcHQuanMiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgXCJ0eXBpbmdzLWdsb2JhbFwiXHJcbmltcG9ydCBwbHVnaW5zID0gcmVxdWlyZShcIi4vc21hcnRzdHJpbmcucGx1Z2luc1wiKTtcclxuXHJcbmV4cG9ydCBsZXQgcmVnZXhSZWZlcmVuY2VQYXRoID0gL1xcL1xcL1xcL1xccyo8cmVmZXJlbmNlXFxzK3BhdGhcXHMqPVxccypbXCJ8J10uKltcInwnXVxccypcXC8+XFxzKltcXFxcbl0/LyJdfQ==
+1 -1
View File
@@ -1,6 +1,6 @@
The MIT License (MIT)
Copyright (c) 2016 Push.Rocks
Copyright (c) 2026 Task Venture Capital GmbH
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+41
View File
@@ -0,0 +1,41 @@
{
"@git.zone/cli": {
"projectType": "npm",
"module": {
"githost": "code.foss.global",
"gitscope": "push.rocks",
"gitrepo": "smartstring",
"description": "A library for handling strings in smart ways, including manipulation and encoding, with TypeScript support.",
"npmPackagename": "@push.rocks/smartstring",
"license": "MIT",
"keywords": [
"string manipulation",
"encode",
"decode",
"base64",
"indentation",
"normalization",
"regex",
"random string",
"cryptographic string",
"domain parsing",
"git repository parsing",
"docker environment parsing"
]
},
"release": {
"registries": [
"https://verdaccio.lossless.digital",
"https://registry.npmjs.org"
],
"accessLevel": "public"
}
},
"@git.zone/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"
},
"@ship.zone/szci": {
"npmGlobalTools": [],
"npmRegistryUrl": "registry.npmjs.org"
}
}
+50 -17
View File
@@ -1,33 +1,66 @@
{
"name": "smartstring",
"version": "2.0.1",
"description": "bundles a bunch of (regex) matching and altering methods.",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"name": "@push.rocks/smartstring",
"version": "4.1.1",
"private": false,
"description": "A library for handling strings in smart ways, including manipulation and encoding, with TypeScript support.",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"type": "module",
"scripts": {
"test": "(npmts)"
"test": "tstest test/ --verbose",
"build": "tsbuild --web",
"format": "gitzone format",
"buildDocs": "tsdoc"
},
"repository": {
"type": "git",
"url": "git+https://github.com/pushrocks/smartstring.git"
"url": "https://code.foss.global/push.rocks/smartstring.git"
},
"keywords": [
"string manipulation",
"encode",
"decode",
"base64",
"indentation",
"normalization",
"regex",
"string"
"random string",
"cryptographic string",
"domain parsing",
"git repository parsing",
"docker environment parsing"
],
"author": "Lossless GmbH",
"author": "Task Venture Capital GmbH <hello@task.vc>",
"license": "MIT",
"bugs": {
"url": "https://github.com/pushrocks/smartstring/issues"
"url": "https://gitlab.com/push.rocks/smartstring/issues"
},
"homepage": "https://github.com/pushrocks/smartstring#readme",
"homepage": "https://code.foss.global/push.rocks/smartstring",
"devDependencies": {
"npmts": "^5.1.13",
"should": "^8.4.0",
"typings-test": "^1.0.1"
"@git.zone/tsbuild": "^4.4.0",
"@git.zone/tsrun": "^2.0.3",
"@git.zone/tstest": "^3.6.3",
"@types/node": "^25.6.0"
},
"dependencies": {
"beautylog": "^5.0.6",
"typings-global": "^1.0.3"
}
"@push.rocks/isounique": "^1.0.5"
},
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
".smartconfig.json",
"license",
"npmextra.json",
"readme.md"
],
"browserslist": [
"last 1 chrome versions"
],
"packageManager": "pnpm@10.28.2"
}
+8547
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -0,0 +1 @@
+379
View File
@@ -0,0 +1,379 @@
# @push.rocks/smartstring
🎯 **Smart string manipulation for TypeScript** - Your comprehensive toolkit for handling strings, domains, Git URLs, and encodings with elegance and precision.
## Why smartstring?
When working with strings in modern JavaScript/TypeScript applications, you often need more than just basic manipulation. You need to:
- Parse and validate domains and URLs
- Handle Git repository URLs across different formats
- Encode/decode Base64 for data transmission
- Normalize indentation in code generators
- Create cryptographically secure random strings
- Validate string encodings
- Parse Docker environment variables
**smartstring** unifies all these capabilities in a single, tree-shakeable, TypeScript-native package with zero setup overhead.
## Install
```bash
npm install @push.rocks/smartstring --save
```
Or using pnpm (recommended):
```bash
pnpm add @push.rocks/smartstring
```
## Features at a Glance
**Domain parsing** - Extract protocols, subdomains, domains, and TLDs
**Git URL handling** - Parse and convert between SSH and HTTPS formats
**Base64 encoding** - Standard and URL-safe Base64 operations
**Smart indentation** - Indent, outdent, and normalize multi-line strings
**Random strings** - Pattern-based and cryptographically secure generation
**String normalization** - Clean and standardize whitespace
**Type checking** - Validate UTF-8 and Base64 encodings
**Docker env parsing** - Transform Docker environment arrays to objects
## Usage
### 🌐 Domain Parsing
Extract detailed information from any URL or domain string:
```typescript
import { Domain } from '@push.rocks/smartstring';
const domain = new Domain('https://subdomain.example.com:3000/path');
console.log(domain.protocol); // 'https'
console.log(domain.hostname); // 'subdomain.example.com'
console.log(domain.port); // '3000'
console.log(domain.pathname); // '/path'
console.log(domain.fullUrl); // 'https://subdomain.example.com:3000/path'
// Domain level extraction
console.log(domain.level1); // 'com' - TLD
console.log(domain.level2); // 'example' - Domain
console.log(domain.level3); // 'subdomain' - Subdomain
console.log(domain.zoneName); // 'example.com' - Full domain without subdomain
console.log(domain.subdomain); // 'subdomain'
```
### 🔧 Git Repository URLs
Parse and convert Git repository URLs between SSH and HTTPS formats:
```typescript
import { GitRepo } from '@push.rocks/smartstring';
// Parse SSH format
const repo = new GitRepo('git@github.com:user/awesome-project.git');
console.log(repo.host); // 'github.com'
console.log(repo.user); // 'user'
console.log(repo.repo); // 'awesome-project'
console.log(repo.httpsUrl); // 'https://github.com/user/awesome-project.git'
// Parse HTTPS format
const httpsRepo = new GitRepo('https://gitlab.com/team/project.git');
console.log(httpsRepo.sshUrl); // 'git@gitlab.com:team/project.git'
console.log(httpsRepo.httpsUrl); // 'https://gitlab.com/team/project.git'
```
### 🔐 Base64 Encoding
Handle Base64 encoding with both standard and URL-safe variants:
```typescript
import { Base64, base64 } from '@push.rocks/smartstring';
// Using the Base64 class
const encoded = new Base64('Hello World! 👋', 'string');
console.log(encoded.base64String); // Standard Base64
console.log(encoded.base64UriString); // URL-safe Base64
console.log(encoded.simpleString); // Decoded string
// Using utility functions
const quickEncode = base64.encode('Secret message');
const quickDecode = base64.decode(quickEncode);
// Validate Base64 strings
console.log(base64.isBase64('SGVsbG8=')); // true
console.log(base64.isBase64('Not Base64!')); // false
// URL-safe Base64 operations
const urlSafeEncoded = base64.encodeUri('https://example.com/path?param=value');
const urlSafeDecoded = base64.decodeUri(urlSafeEncoded);
```
### 📐 Smart Indentation
Manage indentation in multi-line strings with precision:
```typescript
import { indent } from '@push.rocks/smartstring';
// Indent with spaces
const indented = indent.indent('Line 1\nLine 2\nLine 3', 4);
// Result:
// Line 1
// Line 2
// Line 3
// Indent with custom prefix
const prefixed = indent.indentWithPrefix('Item 1\nItem 2', '> ');
// Result:
// > Item 1
// > Item 2
// Add prefix to first line only
const firstLinePrefixed = indent.addPrefix('Chapter\nContent here', '# ');
// Result:
// # Chapter
// Content here
// Normalize irregular indentation
const messy = `
function hello() {
console.log('Hi');
return true;
}
`;
const clean = indent.normalize(messy);
// Result: Properly aligned with minimum indentation preserved
```
### 🎲 Random String Generation
Create random strings with specific patterns or cryptographic security:
```typescript
import { create } from '@push.rocks/smartstring';
// Pattern-based random strings
// A = uppercase, a = lowercase, 0 = number, ! = special, * = any
const password = create.createRandomString('Aa0!', 16);
// Example: "Kg7$Lp2@Qm9#Xn4!"
const alphanumeric = create.createRandomString('Aa0', 10);
// Example: "K7gLp2Qm9X"
const numbers = create.createRandomString('0', 6);
// Example: "472819"
// Cryptographically secure random strings
const cryptoId = create.createCryptoRandomString();
// Example: "f7b2d8e0-3c4a-4b9c-8d2e-1f0a7b9c8d7e"
```
### 🧹 String Normalization
Clean and standardize strings for consistent formatting:
```typescript
import { normalize } from '@push.rocks/smartstring';
const messyString = `
This text has
inconsistent indentation
and too much whitespace
between lines...
`;
const cleaned = normalize.standard(messyString);
// Result: Properly formatted with consistent spacing
// Custom normalization
const customNormalized = normalize.normal(messyString);
```
### 🔍 String Type Validation
Check string encodings and types:
```typescript
import { type } from '@push.rocks/smartstring';
// Check if string is valid UTF-8
const isValidUtf8 = type.isUtf8('Hello 世界');
console.log(isValidUtf8); // true
// Check if string is Base64
const isBase64String = type.isBase64('SGVsbG8gV29ybGQ=');
console.log(isBase64String); // true
```
### 🐳 Docker Environment Variables
Parse Docker-style environment variable arrays:
```typescript
import { docker } from '@push.rocks/smartstring';
const envArray = [
'NODE_ENV=production',
'PORT=3000',
'DATABASE_URL=postgresql://localhost:5432/mydb',
'API_KEY=secret123'
];
const envObject = docker.makeEnvObject(envArray);
console.log(envObject.NODE_ENV); // 'production'
console.log(envObject.PORT); // '3000'
console.log(envObject.DATABASE_URL); // 'postgresql://localhost:5432/mydb'
console.log(envObject.API_KEY); // 'secret123'
// Use in Docker-related configurations
// Perfect for parsing process.env or Docker Compose outputs
```
## API Reference
### Classes
- **`Domain`** - URL/domain parser with component extraction
- **`GitRepo`** - Git repository URL parser and converter
- **`Base64`** - Base64 encoder/decoder with multiple formats
### Modules
- **`create`** - Random string generation
- `createRandomString(pattern, length, options)` - Pattern-based generation
- `createCryptoRandomString()` - Cryptographically secure strings
- **`indent`** - Indentation management
- `indent(text, spaces)` - Add spaces to each line
- `indentWithPrefix(text, prefix)` - Add custom prefix to each line
- `normalize(text)` - Fix inconsistent indentation
- `addPrefix(text, prefix)` - Add prefix to first line only
- **`normalize`** - String normalization
- `standard(text)` - Apply standard normalization
- `normal(text)` - Basic normalization
- **`type`** - String type checking
- `isUtf8(text)` - Validate UTF-8 encoding
- `isBase64(text)` - Validate Base64 format
- **`base64`** - Base64 utilities
- `encode(text)` - Standard Base64 encoding
- `decode(text)` - Standard Base64 decoding
- `encodeUri(text)` - URL-safe Base64 encoding
- `decodeUri(text)` - URL-safe Base64 decoding
- `isBase64(text)` - Check if string is valid Base64
- **`docker`** - Docker utilities
- `makeEnvObject(envArray)` - Convert env array to object
## Real-World Examples
### Building a URL Shortener
```typescript
import { Domain, create, base64 } from '@push.rocks/smartstring';
function createShortUrl(longUrl: string): string {
const domain = new Domain(longUrl);
const shortCode = create.createRandomString('Aa0', 6);
const encoded = base64.encodeUri(`${domain.hostname}${domain.pathname}`);
return `short.ly/${shortCode}`;
}
```
### Processing Code Templates
```typescript
import { indent, normalize } from '@push.rocks/smartstring';
function generateComponent(name: string, props: string[]): string {
const propsSection = props
.map(prop => `${prop}: string;`)
.join('\n');
const template = `
export interface ${name}Props {
${indent.indent(propsSection, 2)}
}
export function ${name}(props: ${name}Props) {
${indent.indent('// Component implementation', 2)}
}
`;
return normalize.standard(template);
}
```
### Git Repository Manager
```typescript
import { GitRepo } from '@push.rocks/smartstring';
class RepoManager {
repos: Map<string, GitRepo> = new Map();
addRepo(url: string): void {
const repo = new GitRepo(url);
this.repos.set(repo.repo, repo);
}
getCloneCommand(name: string, useSSH = false): string {
const repo = this.repos.get(name);
if (!repo) throw new Error('Repository not found');
const url = useSSH ? repo.sshUrl : repo.httpsUrl;
return `git clone ${url}`;
}
}
```
## Browser Support
This package is built for modern environments and includes:
- ✅ Full ES Module support
- ✅ Tree-shaking ready
- ✅ TypeScript definitions
- ✅ Browser-compatible (via bundlers)
- ✅ Node.js 14+ support
## Development
```bash
# Clone the repository
git clone https://code.foss.global/push.rocks/smartstring.git
# Install dependencies
pnpm install
# Run tests
pnpm test
# Build the project
pnpm build
```
## 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.
+23
View File
@@ -0,0 +1,23 @@
import * as smartstring from '../ts/index.js';
import { tap, expect } from '@git.zone/tstest/tapbundle';
// Base64
let testBase64: smartstring.Base64;
tap.test('expect create a valid instance of Base64', async () => {
testBase64 = new smartstring.Base64('somestring', 'string');
expect(testBase64).toBeInstanceOf(smartstring.Base64);
});
tap.test('expect read output a file as base64 and base64uri', async () => {
expect(testBase64.base64String).not.toEqual(testBase64.base64UriString);
let testBase64_2 = new smartstring.Base64(testBase64.base64UriString, 'base64uri');
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();
});
export default tap.start();
-1
View File
@@ -1 +0,0 @@
import "typings-test";
+12
View File
@@ -0,0 +1,12 @@
import * as smartstring from '../ts/index.js';
import { tap, expect } from '@git.zone/tstest/tapbundle';
// Docker
tap.test('expect create a Env Object', async () => {
let envStringArray = ['VIRTUAL_HOST=sub.domain.tld', 'DEFAULT_HOST=some.domain.com'];
let envObject: any = smartstring.docker.makeEnvObject(envStringArray);
expect(envObject.VIRTUAL_HOST).toEqual('sub.domain.tld');
expect(envObject.DEFAULT_HOST).toEqual('some.domain.com');
});
export default tap.start();
+37
View File
@@ -0,0 +1,37 @@
import * as smartstring from '../ts/index.js';
import { tap, expect } from '@git.zone/tstest/tapbundle';
// Domain
let testDomain: smartstring.Domain;
let testDomain2: smartstring.Domain;
tap.test('expect create a new Domain object', async () => {
testDomain = new smartstring.Domain('https://level3D.level2D.level1D');
expect(testDomain).toBeInstanceOf(smartstring.Domain);
console.log(testDomain);
});
tap.test('expect have a .topLevel', async () => {
expect(testDomain.topLevel).toEqual('level1D');
});
tap.test('expect have a .level2', async () => {
expect(testDomain.level2).toEqual('level2D');
});
tap.test('expect have a .level3', async () => {
expect(testDomain.level3).toEqual('level3D');
});
tap.test('expect have the correct dns zone name', async () => {
expect(testDomain.zoneName).toEqual('level2D.level1D');
});
tap.test('expect have the correct protocol', async () => {
expect(testDomain.protocol).toEqual('https');
});
tap.test('testDomain2 expect be a basic domain', async () => {
testDomain2 = new smartstring.Domain('testing.bleu.de');
console.log(testDomain2);
});
tap.test('should parse complex domains', async () => {
testDomain2 = new smartstring.Domain('https://sub1.sub2.lossless.com/some/path:5431');
console.log(testDomain2);
});
export default tap.start();
+26
View File
@@ -0,0 +1,26 @@
import * as smartstring from '../ts/index.js';
import { tap, expect } from '@git.zone/tstest/tapbundle';
// git
let testGit: smartstring.GitRepo;
tap.test('expect create a new Git class GitRepo', async () => {
testGit = new smartstring.GitRepo('git+https://github.com/pushrocks/smartstring.git');
expect(testGit).toBeInstanceOf(smartstring.GitRepo);
});
tap.test('expect return a .host', async () => {
expect(testGit.host).toEqual('github.com');
});
tap.test('expect return a .user', async () => {
expect(testGit.user).toEqual('pushrocks');
});
tap.test('expect return a .repo', async () => {
expect(testGit.repo).toEqual('smartstring');
});
tap.test('expect return a .httpsUrl', async () => {
expect(testGit.httpsUrl).toEqual('https://github.com/pushrocks/smartstring.git');
});
tap.test('expect return a .sshUrl', async () => {
expect(testGit.sshUrl).toEqual('git@github.com:pushrocks/smartstring.git');
});
export default tap.start();
+28
View File
@@ -0,0 +1,28 @@
import * as smartstring from '../ts/index.js';
import { tap, expect } from '@git.zone/tstest/tapbundle';
// indent
let testString = `
base
expect be indented
some more
base
indented
`;
// normalize
tap.test('expect normalize a string', async () => {
testString = smartstring.indent.normalize(testString);
console.log(testString);
let zoneNameArg = 'test1';
let destinationIpArg = '111';
});
// indent with prefix
tap.test('expect indent', async () => {
testString = smartstring.indent.indentWithPrefix(testString, '>> ');
console.log(testString);
});
export default tap.start();
-79
View File
File diff suppressed because one or more lines are too long
-1
View File
@@ -1 +0,0 @@
{"version":3,"file":"test.js","sourceRoot":"","sources":["test.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAChD,IAAI,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAC9C,IAAI,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAE/B,QAAQ,CAAC,aAAa,EAAC;IACnB,QAAQ,CAAC,QAAQ,EAAC;QACd,IAAI,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC,kDAAkD,CAAC,CAAC;QAClF,EAAE,CAAC,uBAAuB,EAAC;YACvB,OAAO,CAAC,IAAI;iBACP,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,uBAAuB,EAAC;YACvB,OAAO,CAAC,IAAI;iBACP,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,uBAAuB,EAAC;YACvB,OAAO,CAAC,IAAI;iBACP,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,2BAA2B,EAAC;YAC3B,OAAO,CAAC,QAAQ;iBACX,MAAM,CAAC,KAAK,CAAC,8CAA8C,CAAC,CAAC;QACtE,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,yBAAyB,EAAC;YACzB,OAAO,CAAC,MAAM;iBACT,MAAM,CAAC,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAClE,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAA;IACF,QAAQ,CAAC,SAAS,EAAC;QACf,QAAQ,CAAC,gBAAgB,EAAC;YACtB,EAAE,CAAC,4BAA4B,EAAC;gBAC5B,IAAI,cAAc,GAAG,CAAC,6BAA6B,EAAC,8BAA8B,CAAC,CAAC;gBACpF,IAAI,SAAS,GAAG,WAAW,CAAC,MAAM,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;gBACjE,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;gBACtD,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAC;YAC3D,CAAC,CAAC,CAAA;QACN,CAAC,CAAC,CAAA;IACN,CAAC,CAAC,CAAA;AACN,CAAC,CAAC,CAAC"}
+20
View File
@@ -0,0 +1,20 @@
import { tap, expect } from '@git.zone/tstest/tapbundle';
import * as smartstring from '../ts/index.js';
tap.test('should normalize a string', async (toolsArg) => {
const testString = `
myawesome string;
is indented with two spaces
`;
const normalizedString = smartstring.normalize.standard(testString);
console.log(normalizedString);
expect(normalizedString).toEqual(
`myawesome string;
is indented with two spaces
`
);
});
export default tap.start();
-77
View File
@@ -1,77 +0,0 @@
import "typings-test"
import * as smartstring from "../dist/index";
let should = require("should");
describe("smartstring",function(){
describe(".Domain class",function(){
let testDomain:smartstring.Domain;
it("should create a new Domain object",function(){
testDomain = new smartstring.Domain("https://level3D.level2D.level1D");
testDomain.should.be.instanceof(smartstring.Domain);
});
it("should have a .topLevel",function(){
testDomain.topLevel.should.equal("level1D");
});
it("should have a .level2",function(){
testDomain.level2.should.equal("level2D");
});
it("should have a .level3",function(){
testDomain.level3.should.equal("level3D");
});
it("should have the correct dns zone name",function(){
testDomain.zoneName.should.equal("level2D.level1D");
})
it ("should have the correct protocol",function(){
testDomain.protocol.should.equal("https");
})
})
describe(".Git class",function(){
let testGit:smartstring.GitRepo;
it("should create a new Git class GitRepo",function(){
testGit = new smartstring.GitRepo("git+https://github.com/pushrocks/smartstring.git");
testGit.should.be.instanceof(smartstring.GitRepo);
})
it("should return a .host",function(){
testGit.host
.should.equal("github.com");
});
it("should return a .user",function(){
testGit.user
.should.equal("pushrocks");
});
it("should return a .repo",function(){
testGit.repo
.should.equal("smartstring");
});
it("should return a .httpsUrl",function(){
testGit.httpsUrl
.should.equal("https://github.com/pushrocks/smartstring.git");
});
it("should return a .sshUrl",function(){
testGit.sshUrl
.should.equal("git@github.com:pushrocks/smartstring.git");
});
})
describe(".docker",function(){
describe(".makeEnvObject",function(){
it("should create a Env Object",function(){
let envStringArray = ["VIRTUAL_HOST=sub.domain.tld","DEFAULT_HOST=some.domain.com"];
let envObject = smartstring.docker.makeEnvObject(envStringArray);
envObject.VIRTUAL_HOST.should.equal("sub.domain.tld");
envObject.DEFAULT_HOST.should.equal("some.domain.com");
})
})
})
describe(".typescript",function(){
describe(".referenceRegex",function(){
it("should match reference paths",function(){
smartstring.typescript.regexReferencePath.test("/// <reference path=\"\" />")
.should.be.true();
smartstring.typescript.regexReferencePath.test("/// <reference path='' />")
.should.be.true();
smartstring.typescript.regexReferencePath.test("/// <referencepath=\"\" />")
.should.be.false();
})
})
})
});
+14
View File
@@ -0,0 +1,14 @@
import { tap, expect } from '@git.zone/tstest/tapbundle';
import * as smartstring from '../ts/index.js';
tap.test('should state valuid utf8', async () => {
expect(smartstring.type.isUtf8('hithere')).toBeTrue();
});
tap.test('should state wether base64 string is valid', async () => {
const base64String = smartstring.base64.encode('hi there');
expect(smartstring.type.isBase64(base64String)).toBeTrue();
expect(smartstring.type.isBase64('hi there')).toBeFalse();
});
export default tap.start();
+8
View File
@@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @push.rocks/commitinfo
*/
export const commitinfo = {
name: '@push.rocks/smartstring',
version: '4.1.1',
description: 'A library for handling strings in smart ways, including manipulation and encoding, with TypeScript support.'
}
+10 -7
View File
@@ -1,8 +1,11 @@
import "typings-global"
import SmartstringDocker = require("./smartstring.docker");
import SmartstringTypescript = require("./smartstring.typescript");
import * as create from './smartstring.create.js';
import * as docker from './smartstring.docker.js';
import * as indent from './smartstring.indent.js';
import * as normalize from './smartstring.normalize.js';
import * as type from './smartstring.type.js';
export {Domain} from "./smartstring.domain";
export {GitRepo} from "./smartstring.git";
export let docker = SmartstringDocker;
export let typescript = SmartstringTypescript;
export { create, docker, normalize, indent, type };
export { Base64, base64 } from './smartstring.base64.js';
export { Domain } from './smartstring.domain.js';
export { GitRepo } from './smartstring.git.js';
+161
View File
@@ -0,0 +1,161 @@
/**
* the type for base 64
*/
export type TStringInputType = 'string' | 'base64' | 'base64uri';
/**
* Cross-platform base64 implementation
* Works in both Node.js and browser environments
*/
const universalBase64 = {
encode: (str: string): string => {
if (typeof Buffer !== 'undefined') {
// Node.js environment
return Buffer.from(str, 'utf8').toString('base64');
} else if (typeof btoa !== 'undefined') {
// Browser environment
// Handle Unicode properly
const utf8Bytes = new TextEncoder().encode(str);
const binaryString = Array.from(utf8Bytes, byte => String.fromCharCode(byte)).join('');
return btoa(binaryString);
} else {
// Fallback pure JS implementation
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
const bytes = new TextEncoder().encode(str);
let result = '';
let i = 0;
while (i < bytes.length) {
const a = bytes[i++];
const b = i < bytes.length ? bytes[i++] : 0;
const c = i < bytes.length ? bytes[i++] : 0;
const bitmap = (a << 16) | (b << 8) | c;
result += chars.charAt((bitmap >> 18) & 63);
result += chars.charAt((bitmap >> 12) & 63);
result += i - 2 < bytes.length ? chars.charAt((bitmap >> 6) & 63) : '=';
result += i - 1 < bytes.length ? chars.charAt(bitmap & 63) : '=';
}
return result;
}
},
decode: (str: string): string => {
// Handle base64uri by converting back to standard base64
const base64String = str
.replace(/-/g, '+')
.replace(/_/g, '/')
.padEnd(str.length + ((4 - (str.length % 4)) % 4), '=');
if (typeof Buffer !== 'undefined') {
// Node.js environment
return Buffer.from(base64String, 'base64').toString('utf8');
} else if (typeof atob !== 'undefined') {
// Browser environment
const binaryString = atob(base64String);
const bytes = new Uint8Array(binaryString.length);
for (let i = 0; i < binaryString.length; i++) {
bytes[i] = binaryString.charCodeAt(i);
}
return new TextDecoder().decode(bytes);
} else {
// Fallback pure JS implementation
const chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
let bytes: number[] = [];
let i = 0;
while (i < base64String.length) {
const encoded1 = chars.indexOf(base64String.charAt(i++));
const encoded2 = chars.indexOf(base64String.charAt(i++));
const encoded3 = chars.indexOf(base64String.charAt(i++));
const encoded4 = chars.indexOf(base64String.charAt(i++));
const bitmap = (encoded1 << 18) | (encoded2 << 12) | (encoded3 << 6) | encoded4;
bytes.push((bitmap >> 16) & 255);
if (encoded3 !== 64) bytes.push((bitmap >> 8) & 255);
if (encoded4 !== 64) bytes.push(bitmap & 255);
}
return new TextDecoder().decode(new Uint8Array(bytes));
}
}
};
/**
* handle base64 strings
*/
export class Base64 {
private refString: string;
constructor(inputStringArg: string, typeArg: TStringInputType) {
switch (typeArg) {
case 'string': // easiest case
this.refString = inputStringArg;
break;
case 'base64':
this.refString = base64.decode(inputStringArg);
break;
case 'base64uri':
this.refString = base64.decode(inputStringArg);
}
}
/**
* the simple string (unencoded)
*/
get simpleString() {
return this.refString;
}
/**
* the base64 encoded version of the original string
*/
get base64String() {
return base64.encode(this.refString);
}
/**
* the base64uri encoded version of the original string
*/
get base64UriString() {
return base64.encodeUri(this.refString);
}
}
export let base64 = {
/**
* encodes the string
*/
encode: (stringArg: string) => {
return universalBase64.encode(stringArg);
},
/**
* encodes a stringArg to base64 uri style
*/
encodeUri: (stringArg: string) => {
return universalBase64.encode(stringArg)
.replace(/\+/g, '-')
.replace(/\//g, '_')
.replace(/=/g, '');
},
/**
* decodes a base64 encoded string
*/
decode: (stringArg: string) => {
return universalBase64.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);
},
};
+87
View File
@@ -0,0 +1,87 @@
import * as plugins from './smartstring.plugins.js';
/**
* Cross-platform random number generator
* Uses crypto.getRandomValues in browser and Math.random as fallback
*/
const getRandomInt = (min: number, max: number): number => {
if (typeof globalThis !== 'undefined' && globalThis.crypto && globalThis.crypto.getRandomValues) {
// Browser environment with crypto API
const range = max - min;
const array = new Uint32Array(1);
globalThis.crypto.getRandomValues(array);
return min + (array[0] % range);
} else {
// Fallback to Math.random for environments without crypto
return Math.floor(Math.random() * (max - min)) + min;
}
};
/**
* Custom implementation of randomatic pattern-based string generator
* Pattern characters:
* A - Uppercase letter
* a - Lowercase letter
* 0 - Number (0-9)
* ! - Special character
* * - Any character (A, a, 0, or !)
*/
const customRandomatic = (pattern: string, length?: number, options?: unknown): string => {
const charSets: Record<string, string> = {
'A': 'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'a': 'abcdefghijklmnopqrstuvwxyz',
'0': '0123456789',
'!': '!@#$%^&*()_+-=[]{}|;:,.<>?',
'*': 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+-=[]{}|;:,.<>?'
};
// If length is provided, repeat the pattern to match length
let actualPattern = pattern;
if (length && length > pattern.length) {
actualPattern = pattern.repeat(Math.ceil(length / pattern.length)).slice(0, length);
} else if (length) {
actualPattern = pattern.slice(0, length);
}
let result = '';
for (const char of actualPattern) {
if (charSets[char]) {
const charSet = charSets[char];
const randomIndex = getRandomInt(0, charSet.length);
result += charSet[randomIndex];
} else {
// If not a pattern character, use it literally
result += char;
}
}
return result;
};
/**
* creates a random string
*
* ```ts
* createRandomString('AAAA')
* //=> 'AGHR'
* ```
*
* @param patternArg the pattern argument to use, Aa0!* are viable pattern descritors
* @param lengthArg the length of the random string
* @param optionsArg options
*/
export const createRandomString = (
patternArg: string,
lengthArg?: number,
optionsArg?: any
): string => {
return customRandomatic(patternArg, lengthArg, optionsArg);
};
/**
* creates a crytic string in the speicifed length
* @param lengthArg the length of the crypto string
*/
export const createCryptoRandomString = (): string => {
return plugins.isounique.uni();
};
+13 -10
View File
@@ -1,17 +1,20 @@
import "typings-global"
import plugins = require("./smartstring.plugins");
import * as plugins from './smartstring.plugins.js';
/**
* converts an erray of env strings from docker remote api to an usable object.
* @param envArrayArg
* @returns {}
*/
export let makeEnvObject = function(envArrayArg:string[]){
let returnObject = {};
let regexString = /(.*)=(.*)/;
for(let envKey in envArrayArg){
let regexMatches = regexString.exec(envArrayArg[envKey]);
export const makeEnvObject = function (envArrayArg: string[]): Record<string, string> {
const returnObject: Record<string, string> = {};
const regexString = /(.*)=(.*)/;
if (typeof envArrayArg !== 'undefined') {
for (const envString of envArrayArg) {
const regexMatches = regexString.exec(envString);
if (regexMatches) {
returnObject[regexMatches[1]] = regexMatches[2];
};
return returnObject;
};
}
}
}
return returnObject;
};
+76 -44
View File
@@ -1,51 +1,83 @@
import "typings-global"
import plugins = require("./smartstring.plugins");
export class Domain {
fullName:string;
level1:string;
level2:string;
level3:string;
level4:string;
level5:string;
protocol:string;
zoneName:string;
//aliases
topLevel:string;
domainName;
subDomain;
constructor(domainStringArg:string){
this.fullName = domainStringArg;
let regexMatches = domainRegex(domainStringArg);
this.level1 = regexMatches[0];
this.level2 = regexMatches[1];
this.level3 = regexMatches[2];
this.level4 = regexMatches[3];
this.level5 = regexMatches[4];
this.protocol = protocolRegex(domainStringArg)[1];
this.zoneName = this.level2 + "." + this.level1;
// aliases
this.topLevel = this.level1;
this.domainName = this.level2;
this.subDomain = this.level3;
public fullName: string;
public level1?: string;
public level2?: string;
public level3?: string;
public level4?: string;
public level5?: string;
public protocol?: string;
public zoneName: string;
// aliases
public topLevel?: string;
public domainName?: string;
public subDomain?: string;
public port: string;
public nodeParsedUrl: URL;
constructor(domainStringArg: string) {
// lets do the node standard stuff first
this.protocol = this._protocolRegex(domainStringArg);
if (!this.protocol) {
domainStringArg = `https://${domainStringArg}`;
}
}
this.nodeParsedUrl = new URL(domainStringArg);
this.port = this.nodeParsedUrl.port;
// lets do the rest after
const regexMatches = this._domainRegex(
domainStringArg.replace(this.nodeParsedUrl.pathname, '')
);
[this.level1, this.level2, this.level3, this.level4, this.level5] = regexMatches;
this.fullName = '';
for (const localMatch of regexMatches) {
if (this.fullName === '') {
this.fullName = localMatch;
} else {
this.fullName = localMatch + '.' + this.fullName;
}
}
this.zoneName = [this.level2, this.level1].filter(Boolean).join('.');
let domainRegex = function(stringArg:string){
let regexString = /([a-zA-Z0-9]*)\.{0,1}([a-zA-Z0-9]*)\.{0,1}([a-zA-Z0-9]*)\.{0,1}([a-zA-Z0-9]*)\.{0,1}([a-zA-Z0-9]*)\.{0,1}$/;
let regexMatches = regexString.exec(stringArg);
regexMatches.reverse();
let regexMatchesFiltered = regexMatches.filter(function(stringArg:string){
return(stringArg != "");
// aliases
this.topLevel = this.level1;
this.domainName = this.level2;
this.subDomain = this.level3;
}
// helper functions
/** */
private _domainRegex(stringArg: string): string[] {
const regexString =
/([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}([a-zA-Z0-9\-\_]*)\.{0,1}$/;
const regexMatches = regexString.exec(stringArg);
if (!regexMatches) {
return [];
}
const reversedMatches = [...regexMatches].reverse(); // make sure we build the domain from top level to subdomain
reversedMatches.pop(); // pop the last element, which is, since we reversed the Array, the full String of matched elements
const regexMatchesFiltered = reversedMatches.filter(function (stringArg: string) {
return stringArg !== '';
});
return regexMatchesFiltered;
};
}
let protocolRegex = function(stringArg:string){
let regexString = /^([a-zA-Z0-9]*):\/\//;
let regexMatches = regexString.exec(stringArg);
console.log(regexMatches);
return regexMatches;
}
private _protocolRegex(stringArg: string): string | undefined {
const regexString = /^([a-zA-Z0-9]*):\/\//;
const regexMatches = regexString.exec(stringArg);
if (regexMatches) {
return regexMatches[1];
} else {
return undefined;
}
}
private _portRegex(stringArg: string): string | undefined {
const regexString = /^([a-zA-Z0-9]*):\/\//;
const regexMatches = regexString.exec(stringArg);
if (regexMatches) {
return regexMatches[1];
} else {
return undefined;
}
}
}
+40 -42
View File
@@ -1,53 +1,51 @@
import "typings-global"
import plugins = require("./smartstring.plugins");
/* ---------------------------------------------- *
* ------------------ classes ------------------- *
* ---------------------------------------------- */
export class GitRepo {
host:string;
user:string;
repo:string;
accessToken:string;
sshUrl:string;
httpsUrl:string;
constructor(stringArg:string,tokenArg?:string){
let regexMatches = gitRegex(stringArg);
this.host = regexMatches[1];
this.user = regexMatches[2];
this.repo = regexMatches[3];
this.accessToken = tokenArg;
this.sshUrl = gitLink(this.host,this.user,this.repo,this.accessToken, "ssh");
this.httpsUrl = gitLink(this.host,this.user,this.repo,this.accessToken, "https");
};
host: string;
user: string;
repo: string;
accessToken?: string;
sshUrl: string;
httpsUrl: string;
constructor(stringArg: string, tokenArg?: string) {
const regexMatches = gitRegex(stringArg);
if (!regexMatches) {
throw new Error(`Invalid git repository URL: ${stringArg}`);
}
this.host = regexMatches[1];
this.user = regexMatches[2];
this.repo = regexMatches[3];
this.accessToken = tokenArg;
this.sshUrl = gitLink(this.host, this.user, this.repo, this.accessToken, 'ssh');
this.httpsUrl = gitLink(this.host, this.user, this.repo, this.accessToken, 'https');
}
}
/* ---------------------------------------------- *
* ------------------ helpers ------------------- *
* ---------------------------------------------- */
let gitRegex = function(stringArg:string){
let regexString = /(?:git\+|git\@|https\:\/\/|)(?:https\:\/\/|)([^\/|\:]*)(?:\/|:)([^\/]+)*(?:\/|:)([^\.]+)/;
let regexMatches = regexString.exec(stringArg);
return regexMatches;
const gitRegex = function (stringArg: string): RegExpExecArray | null {
const regexString =
/([a-zA-Z0-9\-_\.]*)(?:\/|\:)([a-zA-Z0-9\-_\.]*)(?:\/)([a-zA-Z0-9\-_\.]*)(?:\.git)/;
const regexMatches = regexString.exec(stringArg);
return regexMatches;
};
let gitLink = function(hostArg:string, userArg:string, repoArg:string, tokenArg:string = "", linkTypeArg):string{
let returnString;
if (tokenArg !== ""){
tokenArg = tokenArg + "@"
}
switch (linkTypeArg) {
case "https":
returnString = "https://" +
tokenArg + hostArg + "/" + userArg + "/" + repoArg + ".git";
break;
case "ssh":
returnString = "git@" +
hostArg + ":" + userArg + "/" + repoArg + ".git";
break;
default:
plugins.beautylog.error("Link Type " + linkTypeArg + " not known");
break;
}
return returnString;
};
const gitLink = function (
hostArg: string,
userArg: string,
repoArg: string,
tokenArg = '',
linkTypeArg: 'https' | 'ssh'
): string {
if (tokenArg !== '') {
tokenArg = tokenArg + '@';
}
switch (linkTypeArg) {
case 'https':
return 'https://' + tokenArg + hostArg + '/' + userArg + '/' + repoArg + '.git';
case 'ssh':
return 'git@' + hostArg + ':' + userArg + '/' + repoArg + '.git';
}
};
+94
View File
@@ -0,0 +1,94 @@
import * as plugins from './smartstring.plugins.js';
/**
* splits a string into an array
* @param stringArg
*/
const splitStringAtLineBreak = (stringArg: string): string[] => {
let resultArray = stringArg.split('\n');
return cleanStringArray(resultArray);
};
/**
* joins a string together again
* @param stringArrayArg
*/
const joinStringWithLineBreaks = (stringArrayArg: string[]): string => {
let resultString: string = '';
for (let line of stringArrayArg) {
resultString = resultString + line + '\n'; // add new line at end
}
return resultString;
};
/**
* cleans first and last line in case they are empty
* @param stringArrayArg
*/
const cleanStringArray = (stringArrayArg: string[]): string[] => {
let testRegex = /^[\s]*$/;
if (testRegex.test(stringArrayArg[0])) {
stringArrayArg.shift();
}
if (testRegex.test(stringArrayArg[stringArrayArg.length - 1])) {
stringArrayArg.pop();
}
return stringArrayArg;
};
/**
* indent an array
* @param stringArg
* @param spaceAmount
*/
export const indent = (stringArg: string, spaceAmount: number): string => {
let localStringArray = splitStringAtLineBreak(stringArg);
for (let stringArg of localStringArray) {
stringArg = ' '.repeat(spaceAmount) + stringArg;
}
let resultString = joinStringWithLineBreaks(localStringArray);
return resultString;
};
/**
* indents a string with prefix
* @param stringArg
* @param prefixArg
*/
export const indentWithPrefix = (stringArg: string, prefixArg: string): string => {
let resultString: string;
let stringArray = splitStringAtLineBreak(stringArg);
let resultArray: string[] = [];
for (let stringItem of stringArray) {
resultArray.push(prefixArg + stringItem);
}
resultString = joinStringWithLineBreaks(resultArray);
return resultString;
};
export const normalize = (stringArg: string): string => {
let resultString: string;
let splitStringArray: string[] = splitStringAtLineBreak(stringArg);
let minCommonLeftOffset: number | undefined;
const deIndentRegex = /^(\s*)/;
const emptyLineRegex = /^(\s*)$/;
for (let stringItem of splitStringArray) {
const regexMatch = deIndentRegex.exec(stringItem);
let offsetString = regexMatch ? regexMatch[1] : '';
if (
(typeof minCommonLeftOffset === 'undefined' || offsetString.length < minCommonLeftOffset) &&
!emptyLineRegex.test(stringItem)
) {
minCommonLeftOffset = offsetString.length;
}
}
let resultSplitStringArray = [];
const commonLeftOffset = minCommonLeftOffset || 0;
for (let stringItem of splitStringArray) {
resultSplitStringArray.push(stringItem.substr(commonLeftOffset));
}
resultString = joinStringWithLineBreaks(resultSplitStringArray);
return resultString;
};
+81
View File
@@ -0,0 +1,81 @@
/**
* replaces all occurences of something in a string
* @param stringArg
* @param searchPattern
* @param replacementString
*/
export const replaceAll = (stringArg: string, searchPattern: string, replacementString: string) => {
return stringArg.replace(new RegExp(searchPattern, 'g'), replacementString);
};
/**
* Custom implementation of strip-indent
* Removes the minimum indentation from all lines
*/
const stripIndent = (str: string): string => {
const lines = str.split('\n');
// Find the minimum indentation (ignoring empty lines)
let minIndent = Infinity;
for (const line of lines) {
if (line.trim().length > 0) {
const match = line.match(/^(\s*)/);
if (match) {
minIndent = Math.min(minIndent, match[1].length);
}
}
}
// If no indentation found, return original string
if (minIndent === Infinity || minIndent === 0) {
return str;
}
// Remove the minimum indentation from all lines
return lines.map(line => {
if (line.length >= minIndent) {
return line.slice(minIndent);
}
return line;
}).join('\n');
};
export interface INormalizeOptions {
stripLeadingTrailingEmptyLines?: boolean;
stripAllEmptyLines?: boolean;
stripIndent?: boolean;
normalizeNewline?: boolean;
replaceTabs?: boolean;
}
/**
* Normalizes a string
* @param stringArg
* @param options
*/
export const standard = (stringArg: string, options?: INormalizeOptions): string => {
let result = stringArg;
if (!options || options.stripIndent) {
result = 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;
};
+3 -2
View File
@@ -1,3 +1,4 @@
import "typings-global"
// @push.rocks ecosystem
import * as isounique from '@push.rocks/isounique';
export import beautylog = require("beautylog");
export { isounique };
+108
View File
@@ -0,0 +1,108 @@
import * as plugins from './smartstring.plugins.js';
import * as base64 from './smartstring.base64.js';
export const isUtf8 = (stringArg: string): boolean => {
// 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;
while (i < bytes.length) {
if (
// ASCII
bytes[i] === 0x09 ||
bytes[i] === 0x0a ||
bytes[i] === 0x0d ||
(0x20 <= bytes[i] && bytes[i] <= 0x7e)
) {
i += 1;
continue;
}
if (
// non-overlong 2-byte
0xc2 <= bytes[i] &&
bytes[i] <= 0xdf &&
0x80 <= bytes[i + 1] &&
bytes[i + 1] <= 0xbf
) {
i += 2;
continue;
}
if (
// excluding overlongs
(bytes[i] === 0xe0 &&
0xa0 <= bytes[i + 1] &&
bytes[i + 1] <= 0xbf &&
0x80 <= bytes[i + 2] &&
bytes[i + 2] <= 0xbf) ||
// straight 3-byte
(((0xe1 <= bytes[i] && bytes[i] <= 0xec) || bytes[i] === 0xee || bytes[i] === 0xef) &&
0x80 <= bytes[i + 1] &&
bytes[i + 1] <= 0xbf &&
0x80 <= bytes[i + 2] &&
bytes[i + 2] <= 0xbf) ||
// excluding surrogates
(bytes[i] === 0xed &&
0x80 <= bytes[i + 1] &&
bytes[i + 1] <= 0x9f &&
0x80 <= bytes[i + 2] &&
bytes[i + 2] <= 0xbf)
) {
i += 3;
continue;
}
if (
// planes 1-3
(bytes[i] === 0xf0 &&
0x90 <= bytes[i + 1] &&
bytes[i + 1] <= 0xbf &&
0x80 <= bytes[i + 2] &&
bytes[i + 2] <= 0xbf &&
0x80 <= bytes[i + 3] &&
bytes[i + 3] <= 0xbf) ||
// planes 4-15
(0xf1 <= bytes[i] &&
bytes[i] <= 0xf3 &&
0x80 <= bytes[i + 1] &&
bytes[i + 1] <= 0xbf &&
0x80 <= bytes[i + 2] &&
bytes[i + 2] <= 0xbf &&
0x80 <= bytes[i + 3] &&
bytes[i + 3] <= 0xbf) ||
// plane 16
(bytes[i] === 0xf4 &&
0x80 <= bytes[i + 1] &&
bytes[i + 1] <= 0x8f &&
0x80 <= bytes[i + 2] &&
bytes[i + 2] <= 0xbf &&
0x80 <= bytes[i + 3] &&
bytes[i + 3] <= 0xbf)
) {
i += 4;
continue;
}
return false;
}
return true;
};
export const isBase64 = (stringArg: string) => {
const notBase64 = /[^A-Z0-9+\/=]/i;
const len = stringArg.length;
if (!len || len % 4 !== 0 || notBase64.test(stringArg)) {
return false;
}
const firstPaddingChar = stringArg.indexOf('=');
return (
firstPaddingChar === -1 ||
firstPaddingChar === len - 1 ||
(firstPaddingChar === len - 2 && stringArg[len - 1] === '=')
);
};
-4
View File
@@ -1,4 +0,0 @@
import "typings-global"
import plugins = require("./smartstring.plugins");
export let regexReferencePath = /\/\/\/\s*<reference\s+path\s*=\s*["|'].*["|']\s*\/>\s*[\\n]?/
-7
View File
@@ -1,7 +0,0 @@
{
"ambientDependencies": {
"node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts",
"mocha": "github:Bartvds/tsd-deftools/typings/DefinitelyTyped/mocha/mocha.d.ts",
"colors": "github:DefinitelyTyped/DefinitelyTyped/colors/colors.d.ts"
}
}
+14
View File
@@ -0,0 +1,14 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"noImplicitAny": true,
"esModuleInterop": true,
"verbatimModuleSyntax": true,
"types": ["node"]
},
"exclude": ["dist_*/**/*.d.ts"]
}