├── .eslintignore ├── .eslintrc.json ├── .gitignore ├── .npmignore ├── CHANGELOG.md ├── README.md ├── __root_ws.d.ts ├── __root_ws.js ├── __root_ws.ts ├── jest-preset.js ├── jest.config.js ├── lerna.json ├── package.json ├── packages ├── @lazy-cjk │ ├── fullhalf-char-code │ │ ├── .gitignore │ │ ├── .npmignore │ │ ├── CHANGELOG.md │ │ ├── README.md │ │ ├── dist │ │ │ ├── index.cjs │ │ │ ├── index.cjs.development.cjs │ │ │ ├── index.cjs.production.min.cjs │ │ │ ├── index.d.ts │ │ │ └── index.esm.mjs │ │ ├── jest.config.js │ │ ├── package.json │ │ ├── src │ │ │ └── index.ts │ │ ├── test │ │ │ ├── __root.ts │ │ │ └── tsconfig.json │ │ └── tsconfig.json │ ├── fullhalf-data │ │ ├── .gitignore │ │ ├── .npmignore │ │ ├── CHANGELOG.md │ │ ├── README.md │ │ ├── dist │ │ │ ├── index.cjs │ │ │ ├── index.cjs.development.cjs │ │ │ ├── index.cjs.production.min.cjs │ │ │ ├── index.d.ts │ │ │ └── index.esm.mjs │ │ ├── jest.config.js │ │ ├── package.json │ │ ├── src │ │ │ ├── _table.ts │ │ │ ├── defaults.ts │ │ │ ├── index.ts │ │ │ └── table.ts │ │ ├── test │ │ │ ├── __root.ts │ │ │ ├── script │ │ │ │ └── build-table.ts │ │ │ └── tsconfig.json │ │ └── tsconfig.json │ ├── fullhalf │ │ ├── .gitignore │ │ ├── .npmignore │ │ ├── CHANGELOG.md │ │ ├── README.md │ │ ├── dist │ │ │ ├── index.cjs │ │ │ ├── index.cjs.development.cjs │ │ │ ├── index.cjs.production.min.cjs │ │ │ ├── index.d.ts │ │ │ └── index.esm.mjs │ │ ├── jest.config.js │ │ ├── package.json │ │ ├── src │ │ │ └── index.ts │ │ ├── test │ │ │ ├── __root.ts │ │ │ ├── chinese.test.ts │ │ │ ├── fullhalf.test.ts │ │ │ ├── script │ │ │ │ └── build-table.ts │ │ │ └── tsconfig.json │ │ └── tsconfig.json │ ├── str-util-char-code-at │ │ ├── .gitignore │ │ ├── .npmignore │ │ ├── CHANGELOG.md │ │ ├── README.md │ │ ├── dist │ │ │ ├── index.cjs │ │ │ ├── index.cjs.development.cjs │ │ │ ├── index.cjs.production.min.cjs │ │ │ ├── index.d.ts │ │ │ └── index.esm.mjs │ │ ├── jest.config.js │ │ ├── package.json │ │ ├── src │ │ │ └── index.ts │ │ ├── test │ │ │ ├── __root.ts │ │ │ └── tsconfig.json │ │ └── tsconfig.json │ ├── str-util-normalize │ │ ├── .gitignore │ │ ├── .npmignore │ │ ├── CHANGELOG.md │ │ ├── README.md │ │ ├── dist │ │ │ ├── index.cjs │ │ │ ├── index.cjs.development.cjs │ │ │ ├── index.cjs.production.min.cjs │ │ │ ├── index.d.ts │ │ │ └── index.esm.mjs │ │ ├── jest.config.js │ │ ├── package.json │ │ ├── src │ │ │ └── index.ts │ │ ├── test │ │ │ ├── __root.ts │ │ │ └── tsconfig.json │ │ └── tsconfig.json │ ├── str-util-trim │ │ ├── .gitignore │ │ ├── .npmignore │ │ ├── CHANGELOG.md │ │ ├── README.md │ │ ├── jest.config.js │ │ ├── package.json │ │ ├── src │ │ │ └── index.ts │ │ ├── test │ │ │ ├── __root.ts │ │ │ └── tsconfig.json │ │ └── tsconfig.json │ └── zh2num │ │ ├── .gitignore │ │ ├── .npmignore │ │ ├── CHANGELOG.md │ │ ├── README.md │ │ ├── dist │ │ ├── index.cjs │ │ ├── index.cjs.development.cjs │ │ ├── index.cjs.production.min.cjs │ │ ├── index.d.ts │ │ └── index.esm.mjs │ │ ├── jest.config.js │ │ ├── package.json │ │ ├── src │ │ └── index.ts │ │ ├── test │ │ ├── __root.ts │ │ ├── __snapshots__ │ │ │ └── zh2num.test.ts.snap │ │ ├── tsconfig.json │ │ └── zh2num.test.ts │ │ └── tsconfig.json ├── blank-line │ ├── .gitignore │ ├── .npmignore │ ├── CHANGELOG.md │ ├── README.md │ ├── dist │ │ ├── index.cjs │ │ ├── index.cjs.development.cjs │ │ ├── index.cjs.production.min.cjs │ │ ├── index.d.ts │ │ └── index.esm.mjs │ ├── jest.config.js │ ├── package.json │ ├── src │ │ ├── index.ts │ │ └── normalize.ts │ ├── test │ │ ├── __snapshots__ │ │ │ └── demo.spec.ts.snap │ │ ├── demo.spec.ts │ │ └── demo.ts │ └── tsconfig.json ├── chinese-parseint2 │ ├── .gitignore │ ├── .npmignore │ ├── CHANGELOG.md │ ├── README.md │ ├── dist │ │ ├── index.cjs │ │ ├── index.cjs.development.cjs │ │ ├── index.cjs.production.min.cjs │ │ ├── index.d.ts │ │ └── index.esm.mjs │ ├── jest.config.js │ ├── package.json │ ├── src │ │ ├── data.ts │ │ └── index.ts │ ├── test │ │ └── test.test.ts │ └── tsconfig.json ├── crlf-normalize-stream │ ├── .gitignore │ ├── .npmignore │ ├── CHANGELOG.md │ ├── README.md │ ├── dist │ │ ├── index.cjs │ │ ├── index.cjs.development.cjs │ │ ├── index.cjs.production.min.cjs │ │ ├── index.d.ts │ │ └── index.esm.mjs │ ├── jest.config.js │ ├── package.json │ ├── src │ │ ├── index.cts │ │ └── index.ts │ ├── test │ │ ├── __root.ts │ │ └── tsconfig.json │ └── tsconfig.json ├── crlf-normalize │ ├── .gitignore │ ├── .npmignore │ ├── CHANGELOG.md │ ├── README.md │ ├── dist │ │ ├── index.cjs │ │ ├── index.cjs.development.cjs │ │ ├── index.cjs.production.min.cjs │ │ ├── index.d.ts │ │ └── index.esm.mjs │ ├── jest.config.js │ ├── package.json │ ├── src │ │ ├── index.d.ts │ │ └── index.ts │ ├── test │ │ ├── __root.ts │ │ ├── __snapshots__ │ │ │ └── demo.spec.ts.snap │ │ ├── demo.spec.ts │ │ ├── demo.ts │ │ └── tsconfig.json │ └── tsconfig.json ├── normalize-num │ ├── .gitignore │ ├── .npmignore │ ├── CHANGELOG.md │ ├── README.md │ ├── index.d.ts │ ├── index.js │ ├── index.ts │ ├── jest.config.js │ ├── lib │ │ └── type │ │ │ ├── circle.d.ts │ │ │ ├── circle.js │ │ │ ├── circle.ts │ │ │ ├── roman.d.ts │ │ │ ├── roman.js │ │ │ └── roman.ts │ └── package.json ├── num-is-roman │ ├── .gitignore │ ├── .npmignore │ ├── CHANGELOG.md │ ├── README.md │ ├── dist │ │ ├── index.cjs │ │ ├── index.cjs.development.cjs │ │ ├── index.cjs.production.min.cjs │ │ ├── index.d.ts │ │ └── index.esm.mjs │ ├── jest.config.js │ ├── package.json │ ├── src │ │ └── index.ts │ └── tsconfig.json ├── reserved │ ├── .gitignore │ ├── .npmignore │ ├── CHANGELOG.md │ ├── LICENSE-MIT │ ├── README.md │ ├── dist │ │ ├── index.cjs │ │ ├── index.cjs.development.cjs │ │ ├── index.cjs.production.min.cjs │ │ ├── index.d.ts │ │ └── index.esm.mjs │ ├── jest.config.js │ ├── package.json │ ├── src │ │ └── index.ts │ ├── test │ │ ├── __root.ts │ │ └── tsconfig.json │ └── tsconfig.json ├── runes2 │ ├── .gitignore │ ├── .npmignore │ ├── CHANGELOG.md │ ├── LICENSE │ ├── dist │ │ ├── index.cjs │ │ ├── index.cjs.development.cjs │ │ ├── index.cjs.production.min.cjs │ │ ├── index.d.ts │ │ └── index.esm.mjs │ ├── jest.config.js │ ├── package.json │ ├── readme.md │ ├── src │ │ ├── index.cts │ │ └── index.ts │ ├── test │ │ ├── __snapshots__ │ │ │ └── runes.spec.ts.snap │ │ └── runes.spec.ts │ └── tsconfig.json ├── safe-variable-name │ ├── .gitignore │ ├── .npmignore │ ├── CHANGELOG.md │ ├── README.md │ ├── dist │ │ ├── index.cjs │ │ ├── index.cjs.development.cjs │ │ ├── index.cjs.production.min.cjs │ │ ├── index.d.ts │ │ └── index.esm.mjs │ ├── jest.config.js │ ├── package.json │ ├── src │ │ └── index.ts │ ├── test │ │ ├── __root.ts │ │ ├── __snapshots__ │ │ │ └── var.spec.ts.snap │ │ ├── tsconfig.json │ │ └── var.spec.ts │ └── tsconfig.json ├── str-util │ ├── .gitignore │ ├── .npmignore │ ├── CHANGELOG.md │ ├── README.md │ ├── index.d.ts │ ├── index.js │ ├── index.ts │ ├── jest.config.js │ ├── lib │ │ ├── fullhalf.d.ts │ │ ├── fullhalf.js │ │ ├── fullhalf.ts │ │ ├── han │ │ │ ├── table.d.ts │ │ │ ├── table.js │ │ │ ├── table.ts │ │ │ ├── teachKanjiComparison.cache.json │ │ │ ├── teachKanjiComparison.cache2.json │ │ │ ├── teachKanjiComparison.json │ │ │ ├── teachKanjiComparison.safe.json │ │ │ ├── zh2jp.d.ts │ │ │ ├── zh2jp.js │ │ │ ├── zh2jp.ts │ │ │ ├── zh2num.d.ts │ │ │ ├── zh2num.js │ │ │ └── zh2num.ts │ │ ├── is-fullwidth.d.ts │ │ ├── is-fullwidth.js │ │ ├── is-fullwidth.ts │ │ ├── normalize.d.ts │ │ ├── normalize.js │ │ ├── normalize.ts │ │ ├── trim.d.ts │ │ ├── trim.js │ │ ├── trim.ts │ │ ├── var.d.ts │ │ ├── var.js │ │ ├── var.ts │ │ ├── width.d.ts │ │ ├── width.js │ │ └── width.ts │ ├── package.json │ └── test │ │ └── han │ │ └── __snapshots__ │ │ └── zh2num.test.ts.snap ├── string-indent │ ├── .gitignore │ ├── .npmignore │ ├── CHANGELOG.md │ ├── README.md │ ├── dist │ │ ├── index.cjs │ │ ├── index.cjs.development.cjs │ │ ├── index.cjs.production.min.cjs │ │ ├── index.d.ts │ │ └── index.esm.mjs │ ├── jest.config.js │ ├── package.json │ ├── src │ │ └── index.ts │ ├── test │ │ ├── __root.ts │ │ ├── __snapshots__ │ │ │ └── demo.spec.ts.snap │ │ ├── demo.spec.ts │ │ └── tsconfig.json │ └── tsconfig.json ├── string-split-keep │ ├── .gitignore │ ├── .npmignore │ ├── CHANGELOG.md │ ├── LICENSE │ ├── README.md │ ├── dist │ │ ├── index.cjs │ │ ├── index.cjs.development.cjs │ │ ├── index.cjs.production.min.cjs │ │ ├── index.d.ts │ │ └── index.esm.mjs │ ├── jest.config.js │ ├── package.json │ ├── src │ │ └── index.ts │ ├── test │ │ ├── __root.ts │ │ ├── test.test.ts │ │ └── tsconfig.json │ └── tsconfig.json ├── uni-string │ ├── .gitignore │ ├── .npmignore │ ├── CHANGELOG.md │ ├── README.md │ ├── dist │ │ ├── index.cjs │ │ ├── index.cjs.development.cjs │ │ ├── index.cjs.production.min.cjs │ │ ├── index.d.ts │ │ └── index.esm.mjs │ ├── jest.config.js │ ├── package.json │ ├── src │ │ ├── index.cts │ │ ├── index.d.ts │ │ └── index.ts │ ├── test │ │ ├── __snapshots__ │ │ │ └── test.test.ts.snap │ │ ├── demo.ts │ │ ├── test.test.ts │ │ └── unsafe.spec.ts │ └── tsconfig.json └── zero-width │ ├── .eslintignore │ ├── .gitignore │ ├── .npmignore │ ├── CHANGELOG.md │ ├── README.md │ ├── index.d.ts │ ├── index.js │ ├── index.ts │ ├── jest.config.js │ ├── lib │ ├── const.d.ts │ ├── const.js │ ├── const.js.map │ ├── const.ts │ ├── index.d.ts │ ├── index.js │ ├── index.ts │ ├── re.d.ts │ ├── re.js │ ├── re.js.map │ ├── re.ts │ ├── stat.d.ts │ ├── stat.js │ ├── stat.js.map │ ├── stat.ts │ ├── util.d.ts │ ├── util.js │ └── util.ts │ ├── package.json │ └── test │ ├── __snapshots__ │ └── lazy.spec.ts.snap │ ├── lazy.spec.ts │ └── scripts │ ├── build-re.ts │ └── src │ └── re.ts ├── script ├── run │ ├── postpublish-add.d.ts │ ├── postpublish-add.js │ ├── postpublish-add.ts │ ├── postpublish-subtree.d.ts │ ├── postpublish-subtree.js │ └── postpublish-subtree.ts └── util │ ├── add-to-postpublish-task.d.ts │ ├── add-to-postpublish-task.js │ ├── add-to-postpublish-task.ts │ ├── create-cache-name.d.ts │ ├── create-cache-name.js │ ├── create-cache-name.ts │ ├── git-subtree-push.d.ts │ ├── git-subtree-push.js │ └── git-subtree-push.ts ├── tsconfig.json └── yarn.lock /.eslintignore: -------------------------------------------------------------------------------- 1 | 2 | 3 | /test/ 4 | __test__ 5 | __tests__ 6 | node_modules 7 | /node_modules/ 8 | **/node_modules/ 9 | tests 10 | .idea 11 | .nyc_output 12 | coverage 13 | 14 | *.js 15 | *.d.ts 16 | 17 | *.spec.js 18 | *.test.js 19 | 20 | *.spec.ts 21 | *.test.ts 22 | 23 | bin/**/* 24 | 25 | *.tsbuildinfo 26 | 27 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "bluelovers" 4 | ], 5 | "rules": {} 6 | } 7 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | /.pnp 2 | .pnp.js 3 | .idea 4 | ~ci.list.txt 5 | ~ci.log.txt 6 | ~ci.errors.txt 7 | *.stackdump 8 | *.bak 9 | *.old 10 | *.log 11 | tsconfig.json 12 | package-lock.json 13 | test 14 | .github 15 | .gitkeep 16 | /.*/ 17 | /.* 18 | tests 19 | /~* 20 | __test__ 21 | __tests__ 22 | node_modules 23 | /node_modules/ 24 | **/node_modules/ 25 | *.ts 26 | !*.d.ts 27 | /bin/**/*.d.ts 28 | /bin/*.d.ts 29 | 30 | !*.d.mts 31 | /bin/**/*.d.mts 32 | /bin/*.d.mts 33 | 34 | !*.d.cts 35 | /bin/**/*.d.cts 36 | /bin/*.d.cts 37 | 38 | !/src/**/*.ts 39 | !/src/**/*.cts 40 | !/src/**/*.mts 41 | !/src/**/*.tsx 42 | 43 | /src/**/*.d.ts 44 | /src/**/*.js 45 | /src/**/*.d.cts 46 | /src/**/*.d.mts 47 | /src/**/*.cjs 48 | /src/**/*.mjs 49 | /src/**/*.jsx 50 | 51 | *.tgz 52 | /tsconfig.json.tpl 53 | yarn-error.log 54 | .git 55 | yarn.lock 56 | .env.local 57 | .env.*.local 58 | npm-debug.log* 59 | yarn-debug.log* 60 | yarn-error.log* 61 | .vscode 62 | *.suo 63 | *.ntvs* 64 | *.njsproj 65 | *.sln 66 | *.sw? 67 | *.vue.js 68 | *.vue.d.ts 69 | *.vue.js.map 70 | .nyc_output 71 | coverage 72 | /*.tpl 73 | webpack.config.js 74 | vue.config.js 75 | /jestconfig.json 76 | /tslint.json 77 | .git 78 | webpack.*.config.js 79 | webpack.*.config.d.ts 80 | webpack.*.config.js.map 81 | webpack.*.config.ts 82 | karma.conf.js 83 | /_config.yml 84 | intellij-style-guide.xml 85 | jest.config.js 86 | *.tsbuildinfo 87 | tsconfig.*.json 88 | tsconfig.esm.json.tpl 89 | /package.d.ts 90 | .mocharc.yml 91 | jest.config.js 92 | jest.config.* 93 | /jest-preset.* 94 | /report.*.json 95 | now.json 96 | /Makefile 97 | *.spec.d.ts 98 | *.spec.js 99 | *.spec.ts 100 | 101 | *.spec.d.cts 102 | *.spec.cjs 103 | *.spec.cts 104 | 105 | *.spec.d.mts 106 | *.spec.mjs 107 | *.spec.mts 108 | 109 | *.spec.d.tsx 110 | *.spec.tsx 111 | 112 | __mocks__ 113 | __tests__ 114 | __snapshots__ 115 | *.snap 116 | npm-shrinkwrap.json 117 | /example/ 118 | *.stat 119 | .vercel 120 | tsdx.config.js 121 | /report.json 122 | 123 | /_*/ 124 | _snowpack 125 | 126 | /snowpack.config.js 127 | web_modules 128 | cz-adapter 129 | 130 | tsc-multi.json.tpl 131 | tsc-multi.json 132 | 133 | changelog-option.js 134 | 135 | bin/tsconfig.json 136 | bin/tsconfig.*.json 137 | 138 | .yarnrc.yml 139 | .turbo 140 | __file_snapshots__ 141 | __fixtures__ 142 | /fixture/ 143 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # README.md 2 | 3 | 4 | 5 | ## install 6 | 7 | ``` 8 | yarn add 9 | ``` 10 | 11 | -------------------------------------------------------------------------------- /__root_ws.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2020/5/11. 3 | */ 4 | export declare const __root_ws: string; 5 | export default __root_ws; 6 | -------------------------------------------------------------------------------- /__root_ws.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * Created by user on 2020/5/11. 4 | */ 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | exports.__root_ws = void 0; 7 | exports.__root_ws = __dirname; 8 | exports.default = exports.__root_ws; 9 | //# sourceMappingURL=__root_ws.js.map -------------------------------------------------------------------------------- /__root_ws.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2020/5/11. 3 | */ 4 | 5 | export const __root_ws = __dirname; 6 | 7 | export default __root_ws; 8 | -------------------------------------------------------------------------------- /jest-preset.js: -------------------------------------------------------------------------------- 1 | const { mixinJestConfig } = require('@bluelovers/jest-config'); 2 | 3 | module.exports = mixinJestConfig({}, true, { 4 | file: __filename, 5 | }) 6 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "packages": [ 3 | "packages/@lazy-cjk/*", 4 | "packages/@regexp-cjk/*", 5 | "packages/@node-novel/*", 6 | "packages/*" 7 | ], 8 | "command": { 9 | "publish": { 10 | "concurrency": 1, 11 | "loglevel": "silly", 12 | "ignoreChanges": [ 13 | "**/node_modules/**", 14 | "**/__snapshots__/**", 15 | "**/__fixtures__/**", 16 | "**/__tests__/**", 17 | "*.map", 18 | "*.spec.*", 19 | "*.test.*", 20 | "packages/cjk-conv/test/list.ts", 21 | ".gitrepo", 22 | "lerna.json", 23 | "CHANGELOG.md", 24 | ".gitignore", 25 | "**/test/**", 26 | "**/tests/**", 27 | "**/test/temp/**" 28 | ], 29 | "message": "chore(release): publish", 30 | "bump": "patch", 31 | "noPrivate": true, 32 | "conventionalCommits": true, 33 | "conventionalGraduate": false 34 | }, 35 | "version": { 36 | "concurrency": 1, 37 | "noPrivate": true, 38 | "conventionalCommits": true, 39 | "changelogPreset": "@bluelovers/conventional-changelog-bluelovers" 40 | }, 41 | "run": { 42 | "concurrency": 1, 43 | "stream": true 44 | }, 45 | "exec": { 46 | "concurrency": 1, 47 | "stream": true 48 | }, 49 | "add": { 50 | "concurrency": 1, 51 | "stream": true 52 | } 53 | }, 54 | "npmClient": "yarn", 55 | "useWorkspaces": true, 56 | "version": "independent" 57 | } 58 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf-char-code/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## 1.0.1 (2024-01-29) 7 | 8 | 9 | 10 | ### 📦 Code Refactoring 11 | 12 | * @lazy-cjk/fullhalf-char-code ([92019ae](https://github.com/bluelovers/ws-string/commit/92019ae8287a6b7a604dda9307e062e909d09285)) 13 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf-char-code/README.md: -------------------------------------------------------------------------------- 1 | # README.md 2 | 3 | 4 | 5 | ## install 6 | 7 | ```bash 8 | yarn add @lazy-cjk/fullhalf-char-code 9 | yarn-tool add @lazy-cjk/fullhalf-char-code 10 | yt add @lazy-cjk/fullhalf-char-code 11 | ``` 12 | 13 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf-char-code/dist/index.cjs: -------------------------------------------------------------------------------- 1 | 2 | 'use strict' 3 | 4 | if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production') { 5 | module.exports = require('./index.cjs.development.cjs') 6 | } else { 7 | module.exports = require('./index.cjs.production.min.cjs') 8 | } 9 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf-char-code/dist/index.cjs.production.min.cjs: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var e; 4 | 5 | function detectFullHalfCharCode(e) { 6 | return 0x0020 <= e && e < 0x007F ? 0 : 0x3000 === e || 0xFF00 < e && e < 0xFF5F ? 1 : -1; 7 | } 8 | 9 | Object.defineProperty(exports, "__esModule", { 10 | value: !0 11 | }), exports.EnumFullHalfTableType = void 0, (e = exports.EnumFullHalfTableType || (exports.EnumFullHalfTableType = {}))[e.FULL_WIDTH = 1] = "FULL_WIDTH", 12 | e[e.HALF_WIDTH = 0] = "HALF_WIDTH", e[e.NO_EXIST = -1] = "NO_EXIST", exports.detectFullHalfCharCode = detectFullHalfCharCode, 13 | exports.isFullHalfCharCode = function isFullHalfCharCode(e) { 14 | const l = detectFullHalfCharCode(e); 15 | return 1 === l || 0 !== l && null; 16 | }, exports.toFullWidthCharCode = function toFullWidthCharCode(e) { 17 | return 0x0020 < e && e < 0x007F ? e - 0x0020 + 0xFF00 : 0x0020 === e ? 0x3000 : e; 18 | }, exports.toHalfWidthCharCode = function toHalfWidthCharCode(e) { 19 | return 0xFF00 < e && e < 0xFF5F ? e - 0xFF00 + 0x0020 : 0x3000 === e ? 0x0020 : e; 20 | }; 21 | //# sourceMappingURL=index.cjs.production.min.cjs.map 22 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf-char-code/dist/index.d.ts: -------------------------------------------------------------------------------- 1 | export declare const enum EnumFullHalfTableType { 2 | FULL_WIDTH = 1, 3 | HALF_WIDTH = 0, 4 | NO_EXIST = -1 5 | } 6 | /** 7 | * Determines whether the specified character code is full-width or half-width. 8 | */ 9 | export declare function detectFullHalfCharCode(charCode: number): EnumFullHalfTableType; 10 | /** 11 | * Determines whether the specified character code is full-width or half-width. 12 | */ 13 | export declare function isFullHalfCharCode(charCode: number): boolean; 14 | /** 15 | * Converts a half-width character code to a full-width character code. 16 | * @param {number} charCode - The half-width character code to convert. 17 | * @returns {number} The full-width character code. 18 | */ 19 | export declare function toFullWidthCharCode(charCode: number): number; 20 | /** 21 | * Converts a full-width character code to a half-width character code. 22 | * @param {number} charCode - The full-width character code to convert. 23 | * @returns {number} The half-width character code. 24 | */ 25 | export declare function toHalfWidthCharCode(charCode: number): number; 26 | 27 | export {}; 28 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf-char-code/dist/index.esm.mjs: -------------------------------------------------------------------------------- 1 | var t; 2 | 3 | function detectFullHalfCharCode(t) { 4 | return 0x0020 <= t && t < 0x007F ? 0 : 0x3000 === t || 0xFF00 < t && t < 0xFF5F ? 1 : -1; 5 | } 6 | 7 | function isFullHalfCharCode(t) { 8 | const l = detectFullHalfCharCode(t); 9 | return 1 === l || 0 !== l && null; 10 | } 11 | 12 | function toFullWidthCharCode(t) { 13 | return 0x0020 < t && t < 0x007F ? t - 0x0020 + 0xFF00 : 0x0020 === t ? 0x3000 : t; 14 | } 15 | 16 | function toHalfWidthCharCode(t) { 17 | return 0xFF00 < t && t < 0xFF5F ? t - 0xFF00 + 0x0020 : 0x3000 === t ? 0x0020 : t; 18 | } 19 | 20 | !function(t) { 21 | t[t.FULL_WIDTH = 1] = "FULL_WIDTH", t[t.HALF_WIDTH = 0] = "HALF_WIDTH", t[t.NO_EXIST = -1] = "NO_EXIST"; 22 | }(t || (t = {})); 23 | 24 | export { t as EnumFullHalfTableType, detectFullHalfCharCode, isFullHalfCharCode, toFullWidthCharCode, toHalfWidthCharCode }; 25 | //# sourceMappingURL=index.esm.mjs.map 26 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf-char-code/src/index.ts: -------------------------------------------------------------------------------- 1 | 2 | export const enum EnumFullHalfTableType 3 | { 4 | FULL_WIDTH = 1, 5 | HALF_WIDTH = 0, 6 | NO_EXIST = -1, 7 | } 8 | 9 | /** 10 | * Determines whether the specified character code is full-width or half-width. 11 | */ 12 | export function detectFullHalfCharCode(charCode: number) 13 | { 14 | if (0x0020 <= charCode && charCode < 0x007F) 15 | { 16 | return EnumFullHalfTableType.HALF_WIDTH; 17 | } 18 | 19 | if (0x3000 === charCode || 0xFF00 < charCode && charCode < 0xFF5F) 20 | { 21 | return EnumFullHalfTableType.FULL_WIDTH; 22 | } 23 | 24 | return EnumFullHalfTableType.NO_EXIST; 25 | } 26 | 27 | /** 28 | * Determines whether the specified character code is full-width or half-width. 29 | */ 30 | export function isFullHalfCharCode(charCode: number) 31 | { 32 | const r = detectFullHalfCharCode(charCode); 33 | 34 | if (r === EnumFullHalfTableType.FULL_WIDTH) 35 | { 36 | return true; 37 | } 38 | else if (r === EnumFullHalfTableType.HALF_WIDTH) 39 | { 40 | return false; 41 | } 42 | else 43 | { 44 | // @todo add more... 45 | } 46 | 47 | return null; 48 | } 49 | 50 | /** 51 | * Converts a half-width character code to a full-width character code. 52 | * @param {number} charCode - The half-width character code to convert. 53 | * @returns {number} The full-width character code. 54 | */ 55 | export function toFullWidthCharCode(charCode: number) 56 | { 57 | if (0x0020 < charCode && charCode < 0x007F) 58 | { 59 | return 0xFF00 + (charCode - 0x0020); 60 | } 61 | 62 | if (0x0020 === charCode) 63 | { 64 | return 0x3000; 65 | } 66 | 67 | return charCode; 68 | } 69 | 70 | /** 71 | * Converts a full-width character code to a half-width character code. 72 | * @param {number} charCode - The full-width character code to convert. 73 | * @returns {number} The half-width character code. 74 | */ 75 | export function toHalfWidthCharCode(charCode: number) 76 | { 77 | if (0xFF00 < charCode && charCode < 0xFF5F) 78 | { 79 | return 0x0020 + (charCode - 0xFF00); 80 | } 81 | 82 | if (0x3000 === charCode) 83 | { 84 | return 0x0020; 85 | } 86 | 87 | return charCode; 88 | } 89 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf-char-code/test/__root.ts: -------------------------------------------------------------------------------- 1 | import { join } from "path"; 2 | 3 | export const __ROOT = join(__dirname, '..'); 4 | 5 | export const isWin = process.platform === "win32"; 6 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf-char-code/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "module": "NodeNext", 5 | "noEmit": true, 6 | "declaration": false, 7 | "noUnusedParameters": false, 8 | "allowUnusedLabels": true, 9 | "noUnusedLocals": false, 10 | "noPropertyAccessFromIndexSignature": false 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf-char-code/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@bluelovers/tsconfig/tsdx/index.json", 3 | "compilerOptions": {}, 4 | "exclude": [ 5 | "dist", 6 | "test" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf-data/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## 1.0.1 (2024-01-29) 7 | 8 | 9 | 10 | ### 📦 Code Refactoring 11 | 12 | * rename ([157c470](https://github.com/bluelovers/ws-string/commit/157c4705df3555f7cfdaa777c0853885684788a7)) 13 | * @lazy-cjk/fullhalf-data ([56a3809](https://github.com/bluelovers/ws-string/commit/56a3809fad657c1fe6806a43e68a71ce65c6d93e)) 14 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf-data/README.md: -------------------------------------------------------------------------------- 1 | # README.md 2 | 3 | 4 | 5 | ## install 6 | 7 | ```bash 8 | yarn add @lazy-cjk/fullhalf-data 9 | yarn-tool add @lazy-cjk/fullhalf-data 10 | yt add @lazy-cjk/fullhalf-data 11 | ``` 12 | 13 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf-data/dist/index.cjs: -------------------------------------------------------------------------------- 1 | 2 | 'use strict' 3 | 4 | if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production') { 5 | module.exports = require('./index.cjs.development.cjs') 6 | } else { 7 | module.exports = require('./index.cjs.production.min.cjs') 8 | } 9 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf-data/dist/index.cjs.development.cjs: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Object.defineProperty(exports, '__esModule', { value: true }); 4 | 5 | const tableFullHalfDefaultInclude = ['number', 'A-Z', 'a-z', 'space', 'not_default']; 6 | 7 | const tableFullHalf = [{ 8 | "default": { 9 | "from": 65281, 10 | "to": 65374, 11 | "values": [12288] 12 | }, 13 | "number": { 14 | "from": 65296, 15 | "to": 65305 16 | }, 17 | "A-Z": { 18 | "from": 65313, 19 | "to": 65338 20 | }, 21 | "a-z": { 22 | "from": 65345, 23 | "to": 65370 24 | }, 25 | "space": { 26 | "values": [12288] 27 | }, 28 | "slash": { 29 | "values": [65295, 65340] 30 | }, 31 | "bracket": { 32 | "values": [65288, 65289, 65339, 65341, 65371, 65373] 33 | }, 34 | "not_default": { 35 | "from": 65281, 36 | "to": 65374, 37 | "values": [12288], 38 | "not": [{ 39 | "from": 65296, 40 | "to": 65305 41 | }, { 42 | "from": 65313, 43 | "to": 65338 44 | }, { 45 | "from": 65345, 46 | "to": 65370 47 | }, { 48 | "values": [12288] 49 | }] 50 | } 51 | }, { 52 | "default": { 53 | "from": 33, 54 | "to": 126, 55 | "values": [32] 56 | }, 57 | "number": { 58 | "from": 48, 59 | "to": 57 60 | }, 61 | "A-Z": { 62 | "from": 65, 63 | "to": 90 64 | }, 65 | "a-z": { 66 | "from": 97, 67 | "to": 122 68 | }, 69 | "space": { 70 | "values": [32] 71 | }, 72 | "slash": { 73 | "values": [47, 92] 74 | }, 75 | "bracket": { 76 | "values": [40, 41, 91, 93, 123, 125] 77 | }, 78 | "not_default": { 79 | "from": 33, 80 | "to": 126, 81 | "values": [32], 82 | "not": [{ 83 | "from": 48, 84 | "to": 57 85 | }, { 86 | "from": 65, 87 | "to": 90 88 | }, { 89 | "from": 97, 90 | "to": 122 91 | }, { 92 | "values": [32] 93 | }] 94 | } 95 | }]; 96 | 97 | exports.default = tableFullHalf; 98 | exports.tableFullHalf = tableFullHalf; 99 | exports.tableFullHalfDefaultInclude = tableFullHalfDefaultInclude; 100 | //# sourceMappingURL=index.cjs.development.cjs.map 101 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf-data/dist/index.cjs.production.min.cjs: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: !0 5 | }); 6 | 7 | const o = [ { 8 | default: { 9 | from: 65281, 10 | to: 65374, 11 | values: [ 12288 ] 12 | }, 13 | number: { 14 | from: 65296, 15 | to: 65305 16 | }, 17 | "A-Z": { 18 | from: 65313, 19 | to: 65338 20 | }, 21 | "a-z": { 22 | from: 65345, 23 | to: 65370 24 | }, 25 | space: { 26 | values: [ 12288 ] 27 | }, 28 | slash: { 29 | values: [ 65295, 65340 ] 30 | }, 31 | bracket: { 32 | values: [ 65288, 65289, 65339, 65341, 65371, 65373 ] 33 | }, 34 | not_default: { 35 | from: 65281, 36 | to: 65374, 37 | values: [ 12288 ], 38 | not: [ { 39 | from: 65296, 40 | to: 65305 41 | }, { 42 | from: 65313, 43 | to: 65338 44 | }, { 45 | from: 65345, 46 | to: 65370 47 | }, { 48 | values: [ 12288 ] 49 | } ] 50 | } 51 | }, { 52 | default: { 53 | from: 33, 54 | to: 126, 55 | values: [ 32 ] 56 | }, 57 | number: { 58 | from: 48, 59 | to: 57 60 | }, 61 | "A-Z": { 62 | from: 65, 63 | to: 90 64 | }, 65 | "a-z": { 66 | from: 97, 67 | to: 122 68 | }, 69 | space: { 70 | values: [ 32 ] 71 | }, 72 | slash: { 73 | values: [ 47, 92 ] 74 | }, 75 | bracket: { 76 | values: [ 40, 41, 91, 93, 123, 125 ] 77 | }, 78 | not_default: { 79 | from: 33, 80 | to: 126, 81 | values: [ 32 ], 82 | not: [ { 83 | from: 48, 84 | to: 57 85 | }, { 86 | from: 65, 87 | to: 90 88 | }, { 89 | from: 97, 90 | to: 122 91 | }, { 92 | values: [ 32 ] 93 | } ] 94 | } 95 | } ]; 96 | 97 | exports.default = o, exports.tableFullHalf = o, exports.tableFullHalfDefaultInclude = [ "number", "A-Z", "a-z", "space", "not_default" ]; 98 | //# sourceMappingURL=index.cjs.production.min.cjs.map 99 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf-data/dist/index.d.ts: -------------------------------------------------------------------------------- 1 | export declare const tableFullHalfDefaultInclude: readonly [ 2 | "number", 3 | "A-Z", 4 | "a-z", 5 | "space", 6 | "not_default" 7 | ]; 8 | export declare const tableFullHalf: { 9 | default: { 10 | from: number; 11 | to: number; 12 | values: number[]; 13 | }; 14 | number: { 15 | from: number; 16 | to: number; 17 | }; 18 | "A-Z": { 19 | from: number; 20 | to: number; 21 | }; 22 | "a-z": { 23 | from: number; 24 | to: number; 25 | }; 26 | space: { 27 | values: number[]; 28 | }; 29 | slash: { 30 | values: number[]; 31 | }; 32 | bracket: { 33 | values: number[]; 34 | }; 35 | not_default: { 36 | from: number; 37 | to: number; 38 | values: number[]; 39 | not: ({ 40 | from: number; 41 | to: number; 42 | values?: undefined; 43 | } | { 44 | values: number[]; 45 | from?: undefined; 46 | to?: undefined; 47 | })[]; 48 | }; 49 | }[]; 50 | export interface ITableFullHalfObject { 51 | from?: number; 52 | to?: number; 53 | values?: number[]; 54 | not?: ITableFullHalfObject[]; 55 | } 56 | export interface ITableFullHalf { 57 | default?: ITableFullHalfObject; 58 | number?: ITableFullHalfObject; 59 | space?: ITableFullHalfObject; 60 | "A-Z"?: ITableFullHalfObject; 61 | "a-z"?: ITableFullHalfObject; 62 | not_default?: ITableFullHalfObject; 63 | [index: string]: ITableFullHalfObject; 64 | } 65 | export type ITableFullHalfDefaultIncludeKey = typeof tableFullHalfDefaultInclude[number]; 66 | 67 | export { 68 | tableFullHalf as default, 69 | }; 70 | 71 | export {}; 72 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf-data/dist/index.esm.mjs: -------------------------------------------------------------------------------- 1 | const o = [ "number", "A-Z", "a-z", "space", "not_default" ], t = [ { 2 | default: { 3 | from: 65281, 4 | to: 65374, 5 | values: [ 12288 ] 6 | }, 7 | number: { 8 | from: 65296, 9 | to: 65305 10 | }, 11 | "A-Z": { 12 | from: 65313, 13 | to: 65338 14 | }, 15 | "a-z": { 16 | from: 65345, 17 | to: 65370 18 | }, 19 | space: { 20 | values: [ 12288 ] 21 | }, 22 | slash: { 23 | values: [ 65295, 65340 ] 24 | }, 25 | bracket: { 26 | values: [ 65288, 65289, 65339, 65341, 65371, 65373 ] 27 | }, 28 | not_default: { 29 | from: 65281, 30 | to: 65374, 31 | values: [ 12288 ], 32 | not: [ { 33 | from: 65296, 34 | to: 65305 35 | }, { 36 | from: 65313, 37 | to: 65338 38 | }, { 39 | from: 65345, 40 | to: 65370 41 | }, { 42 | values: [ 12288 ] 43 | } ] 44 | } 45 | }, { 46 | default: { 47 | from: 33, 48 | to: 126, 49 | values: [ 32 ] 50 | }, 51 | number: { 52 | from: 48, 53 | to: 57 54 | }, 55 | "A-Z": { 56 | from: 65, 57 | to: 90 58 | }, 59 | "a-z": { 60 | from: 97, 61 | to: 122 62 | }, 63 | space: { 64 | values: [ 32 ] 65 | }, 66 | slash: { 67 | values: [ 47, 92 ] 68 | }, 69 | bracket: { 70 | values: [ 40, 41, 91, 93, 123, 125 ] 71 | }, 72 | not_default: { 73 | from: 33, 74 | to: 126, 75 | values: [ 32 ], 76 | not: [ { 77 | from: 48, 78 | to: 57 79 | }, { 80 | from: 65, 81 | to: 90 82 | }, { 83 | from: 97, 84 | to: 122 85 | }, { 86 | values: [ 32 ] 87 | } ] 88 | } 89 | } ]; 90 | 91 | export { t as default, t as tableFullHalf, o as tableFullHalfDefaultInclude }; 92 | //# sourceMappingURL=index.esm.mjs.map 93 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf-data/src/_table.ts: -------------------------------------------------------------------------------- 1 | import { charCodeAt } from '@lazy-cjk/str-util-char-code-at'; 2 | 3 | /** 4 | * @see https://en.wikipedia.org/wiki/Code_page_437 5 | */ 6 | export let _table = { 7 | default: { 8 | from: 0x0020 + 1, 9 | to: 0x007F - 1, 10 | values: [0x0020], 11 | }, 12 | 13 | number: [0x0030, 0x0039], 14 | 15 | 'A-Z': [0x0041, 0x005A], 16 | 'a-z': [0x0061, 0x007A], 17 | 18 | space: [0x0020], 19 | 20 | slash: { 21 | values: charCodeAt(`/\\`), 22 | }, 23 | 24 | bracket: { 25 | values: charCodeAt(`()[]{}`), 26 | }, 27 | } as const; 28 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf-data/src/defaults.ts: -------------------------------------------------------------------------------- 1 | export const tableFullHalfDefaultInclude = [ 2 | 'number', 3 | 'A-Z', 4 | 'a-z', 5 | 'space', 6 | 'not_default', 7 | ] as const; 8 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf-data/src/index.ts: -------------------------------------------------------------------------------- 1 | import { tableFullHalfDefaultInclude } from './defaults'; 2 | import { tableFullHalf } from './table'; 3 | 4 | export interface ITableFullHalfObject 5 | { 6 | from?: number; 7 | to?: number; 8 | 9 | values?: number[]; 10 | 11 | not?: ITableFullHalfObject[], 12 | } 13 | 14 | export interface ITableFullHalf 15 | { 16 | default?: ITableFullHalfObject; 17 | 18 | number?: ITableFullHalfObject; 19 | space?: ITableFullHalfObject; 20 | 21 | 'A-Z'?: ITableFullHalfObject; 22 | 'a-z'?: ITableFullHalfObject; 23 | 24 | not_default?: ITableFullHalfObject; 25 | 26 | [index: string]: ITableFullHalfObject; 27 | } 28 | 29 | export type ITableFullHalfDefaultIncludeKey = typeof tableFullHalfDefaultInclude[number] 30 | 31 | export { tableFullHalf, tableFullHalfDefaultInclude } 32 | 33 | export default tableFullHalf 34 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf-data/src/table.ts: -------------------------------------------------------------------------------- 1 | import { ITableFullHalf } from './index'; 2 | 3 | export const tableFullHalf = [ 4 | { 5 | "default": { 6 | "from": 65281, 7 | "to": 65374, 8 | "values": [ 9 | 12288 10 | ] 11 | }, 12 | "number": { 13 | "from": 65296, 14 | "to": 65305 15 | }, 16 | "A-Z": { 17 | "from": 65313, 18 | "to": 65338 19 | }, 20 | "a-z": { 21 | "from": 65345, 22 | "to": 65370 23 | }, 24 | "space": { 25 | "values": [ 26 | 12288 27 | ] 28 | }, 29 | "slash": { 30 | "values": [ 31 | 65295, 32 | 65340 33 | ] 34 | }, 35 | "bracket": { 36 | "values": [ 37 | 65288, 38 | 65289, 39 | 65339, 40 | 65341, 41 | 65371, 42 | 65373 43 | ] 44 | }, 45 | "not_default": { 46 | "from": 65281, 47 | "to": 65374, 48 | "values": [ 49 | 12288 50 | ], 51 | "not": [ 52 | { 53 | "from": 65296, 54 | "to": 65305 55 | }, 56 | { 57 | "from": 65313, 58 | "to": 65338 59 | }, 60 | { 61 | "from": 65345, 62 | "to": 65370 63 | }, 64 | { 65 | "values": [ 66 | 12288 67 | ] 68 | } 69 | ] 70 | } 71 | }, 72 | { 73 | "default": { 74 | "from": 33, 75 | "to": 126, 76 | "values": [ 77 | 32 78 | ] 79 | }, 80 | "number": { 81 | "from": 48, 82 | "to": 57 83 | }, 84 | "A-Z": { 85 | "from": 65, 86 | "to": 90 87 | }, 88 | "a-z": { 89 | "from": 97, 90 | "to": 122 91 | }, 92 | "space": { 93 | "values": [ 94 | 32 95 | ] 96 | }, 97 | "slash": { 98 | "values": [ 99 | 47, 100 | 92 101 | ] 102 | }, 103 | "bracket": { 104 | "values": [ 105 | 40, 106 | 41, 107 | 91, 108 | 93, 109 | 123, 110 | 125 111 | ] 112 | }, 113 | "not_default": { 114 | "from": 33, 115 | "to": 126, 116 | "values": [ 117 | 32 118 | ], 119 | "not": [ 120 | { 121 | "from": 48, 122 | "to": 57 123 | }, 124 | { 125 | "from": 65, 126 | "to": 90 127 | }, 128 | { 129 | "from": 97, 130 | "to": 122 131 | }, 132 | { 133 | "values": [ 134 | 32 135 | ] 136 | } 137 | ] 138 | } 139 | } 140 | ] satisfies ITableFullHalf[]; 141 | 142 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf-data/test/__root.ts: -------------------------------------------------------------------------------- 1 | import { join } from "path"; 2 | 3 | export const __ROOT = join(__dirname, '..'); 4 | 5 | export const isWin = process.platform === "win32"; 6 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf-data/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "module": "NodeNext", 5 | "noEmit": true, 6 | "declaration": false, 7 | "noUnusedParameters": false, 8 | "allowUnusedLabels": true, 9 | "noUnusedLocals": false, 10 | "noPropertyAccessFromIndexSignature": false 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf-data/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@bluelovers/tsconfig/tsdx/index.json", 3 | "compilerOptions": {}, 4 | "exclude": [ 5 | "dist", 6 | "test" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## 1.0.1 (2024-01-29) 7 | 8 | 9 | ### BREAKING CHANGES 10 | 11 | * @lazy-cjk/fullhalf 12 | 13 | 14 | 15 | ### 📦 Code Refactoring 16 | 17 | * @lazy-cjk/fullhalf ([04d2a7a](https://github.com/bluelovers/ws-string/commit/04d2a7adb4af497ca2d2e2e24977f5dcdc156c66)) 18 | * @lazy-cjk/fullhalf ([120040d](https://github.com/bluelovers/ws-string/commit/120040d7729033ac6ee6863037b903ab71352cde)) 19 | 20 | 21 | ### 🔖 Miscellaneous 22 | 23 | * . ([8dada2c](https://github.com/bluelovers/ws-string/commit/8dada2c75f6ae33e6f298f68422536fd3d9b5664)) 24 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf/README.md: -------------------------------------------------------------------------------- 1 | # README.md 2 | 3 | 4 | 5 | ## install 6 | 7 | ```bash 8 | yarn add @lazy-cjk/fullhalf 9 | yarn-tool add @lazy-cjk/fullhalf 10 | yt add @lazy-cjk/fullhalf 11 | ``` 12 | 13 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf/dist/index.cjs: -------------------------------------------------------------------------------- 1 | 2 | 'use strict' 3 | 4 | if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production') { 5 | module.exports = require('./index.cjs.development.cjs') 6 | } else { 7 | module.exports = require('./index.cjs.production.min.cjs') 8 | } 9 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf/test/__root.ts: -------------------------------------------------------------------------------- 1 | import { join } from "path"; 2 | 3 | export const __ROOT = join(__dirname, '..'); 4 | 5 | export const isWin = process.platform === "win32"; 6 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf/test/chinese.test.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2019/5/27. 3 | */ 4 | 5 | // @ts-ignore 6 | /// 7 | // @ts-ignore 8 | /// 9 | // @ts-ignore 10 | /// 11 | // @ts-ignore 12 | /// 13 | 14 | import { unsafeChinese } from 'cjk-conv/lib/zh/data/unsafe'; 15 | import { toFullWidth, toHalfWidth, toFullEnglish, toFullNumber, toHalfEnglish, toHalfNumber } from '../src'; 16 | import UString from 'uni-string'; 17 | 18 | // @ts-ignore 19 | describe(`unsafe chinese, every thing should not change`, () => 20 | { 21 | const unsafeChineseString = unsafeChinese.join(''); 22 | 23 | Object.entries({ 24 | toFullWidth, 25 | toHalfWidth, 26 | toFullEnglish, 27 | toFullNumber, 28 | toHalfEnglish, 29 | toHalfNumber, 30 | } as const).forEach(function ([name, fn]) 31 | { 32 | // @ts-ignore 33 | it(name, () => 34 | { 35 | //console.log('it:inner', currentTest.title); 36 | //console.log('it:inner', currentTest.fullTitle()); 37 | 38 | let actual = fn(unsafeChineseString); 39 | let expected = unsafeChineseString; 40 | 41 | expect(actual).toEqual(expected); 42 | 43 | expect(UString.toArray(actual)).toEqual(unsafeChinese); 44 | 45 | }); 46 | }); 47 | }); 48 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "module": "NodeNext", 5 | "noEmit": true, 6 | "declaration": false, 7 | "noUnusedParameters": false, 8 | "allowUnusedLabels": true, 9 | "noUnusedLocals": false, 10 | "noPropertyAccessFromIndexSignature": false 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/fullhalf/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@bluelovers/tsconfig/tsdx/index.json", 3 | "compilerOptions": {}, 4 | "exclude": [ 5 | "dist", 6 | "test" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/str-util-char-code-at/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## 1.0.1 (2024-01-29) 7 | 8 | 9 | 10 | ### 📦 Code Refactoring 11 | 12 | * @lazy-cjk/str-util-char-code-at ([e01d337](https://github.com/bluelovers/ws-string/commit/e01d337839864da7219d2210216acd9ac6a3cdda)) 13 | * @lazy-cjk/str-util-char-code-at ([f0391eb](https://github.com/bluelovers/ws-string/commit/f0391eb9e75dc730ceffd2bec4776abf9503da72)) 14 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/str-util-char-code-at/README.md: -------------------------------------------------------------------------------- 1 | # README.md 2 | 3 | 4 | 5 | ## install 6 | 7 | ```bash 8 | yarn add @lazy-cjk/str-util-char-code-at 9 | yarn-tool add @lazy-cjk/str-util-char-code-at 10 | yt add @lazy-cjk/str-util-char-code-at 11 | ``` 12 | 13 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/str-util-char-code-at/dist/index.cjs: -------------------------------------------------------------------------------- 1 | 2 | 'use strict' 3 | 4 | if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production') { 5 | module.exports = require('./index.cjs.development.cjs') 6 | } else { 7 | module.exports = require('./index.cjs.production.min.cjs') 8 | } 9 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/str-util-char-code-at/dist/index.cjs.development.cjs: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Object.defineProperty(exports, '__esModule', { value: true }); 4 | 5 | function split(str) { 6 | return str.toString().split(''); 7 | } 8 | function charCodeAt(str, cb) { 9 | let ret = []; 10 | if (typeof cb !== 'function') { 11 | cb = void 0; 12 | } 13 | let _str = Array.isArray(str) ? str : str.toString(); 14 | for (let char of _str) { 15 | let charCode = char.charCodeAt(); 16 | let r; 17 | if (cb && (r = cb(char, charCode, str), typeof r != 'undefined')) { 18 | if (!r) { 19 | continue; 20 | } else if (Array.isArray(r)) { 21 | ret = ret.concat(r); 22 | continue; 23 | } 24 | } 25 | ret.push(charCode); 26 | } 27 | return ret; 28 | } 29 | 30 | exports.charCodeAt = charCodeAt; 31 | exports.default = charCodeAt; 32 | exports.split = split; 33 | //# sourceMappingURL=index.cjs.development.cjs.map 34 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/str-util-char-code-at/dist/index.cjs.production.min.cjs: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | function charCodeAt(t, e) { 4 | let r = []; 5 | "function" != typeof e && (e = void 0); 6 | let o = Array.isArray(t) ? t : t.toString(); 7 | for (let i of o) { 8 | let o, n = i.charCodeAt(); 9 | if (e && (o = e(i, n, t), void 0 !== o)) { 10 | if (!o) continue; 11 | if (Array.isArray(o)) { 12 | r = r.concat(o); 13 | continue; 14 | } 15 | } 16 | r.push(n); 17 | } 18 | return r; 19 | } 20 | 21 | Object.defineProperty(exports, "__esModule", { 22 | value: !0 23 | }), exports.charCodeAt = charCodeAt, exports.default = charCodeAt, exports.split = function split(t) { 24 | return t.toString().split(""); 25 | }; 26 | //# sourceMappingURL=index.cjs.production.min.cjs.map 27 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/str-util-char-code-at/dist/index.d.ts: -------------------------------------------------------------------------------- 1 | export interface IcharCodeAtFn { 2 | (char: unknown, charCode: unknown, str: unknown): unknown; 3 | } 4 | export declare function split(str: unknown): string[]; 5 | export declare function charCodeAt(str: unknown, cb?: IcharCodeAtFn): number[]; 6 | 7 | export { 8 | charCodeAt as default, 9 | }; 10 | 11 | export {}; 12 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/str-util-char-code-at/dist/index.esm.mjs: -------------------------------------------------------------------------------- 1 | function split(t) { 2 | return t.toString().split(""); 3 | } 4 | 5 | function charCodeAt(t, r) { 6 | let o = []; 7 | "function" != typeof r && (r = void 0); 8 | let i = Array.isArray(t) ? t : t.toString(); 9 | for (let e of i) { 10 | let i, n = e.charCodeAt(); 11 | if (r && (i = r(e, n, t), void 0 !== i)) { 12 | if (!i) continue; 13 | if (Array.isArray(i)) { 14 | o = o.concat(i); 15 | continue; 16 | } 17 | } 18 | o.push(n); 19 | } 20 | return o; 21 | } 22 | 23 | export { charCodeAt, charCodeAt as default, split }; 24 | //# sourceMappingURL=index.esm.mjs.map 25 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/str-util-char-code-at/src/index.ts: -------------------------------------------------------------------------------- 1 | 2 | export interface IcharCodeAtFn 3 | { 4 | (char: unknown, charCode: unknown, str: unknown): unknown 5 | } 6 | 7 | export function split(str: unknown): string[] 8 | { 9 | return str.toString().split(''); 10 | } 11 | 12 | export function charCodeAt(str: unknown, cb?: IcharCodeAtFn): number[] 13 | { 14 | let ret: any[] = []; 15 | 16 | if (typeof cb !== 'function') 17 | { 18 | cb = void(0); 19 | } 20 | 21 | let _str = Array.isArray(str) ? str : str.toString(); 22 | 23 | for (let char of _str) 24 | { 25 | let charCode = char.charCodeAt(); 26 | let r; 27 | 28 | if (cb && (r = cb(char, charCode, str), typeof r != 'undefined')) 29 | { 30 | if (!r) 31 | { 32 | continue; 33 | } 34 | else if (Array.isArray(r)) 35 | { 36 | ret = ret.concat(r); 37 | 38 | continue; 39 | } 40 | } 41 | 42 | ret.push(charCode); 43 | } 44 | 45 | return ret; 46 | } 47 | 48 | export default charCodeAt 49 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/str-util-char-code-at/test/__root.ts: -------------------------------------------------------------------------------- 1 | import { join } from "path"; 2 | 3 | export const __ROOT = join(__dirname, '..'); 4 | 5 | export const isWin = process.platform === "win32"; 6 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/str-util-char-code-at/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "module": "NodeNext", 5 | "noEmit": true, 6 | "declaration": false, 7 | "noUnusedParameters": false, 8 | "allowUnusedLabels": true, 9 | "noUnusedLocals": false, 10 | "noPropertyAccessFromIndexSignature": false 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/str-util-char-code-at/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@bluelovers/tsconfig/tsdx/index.json", 3 | "compilerOptions": {}, 4 | "exclude": [ 5 | "dist", 6 | "test" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/str-util-normalize/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## 1.0.1 (2024-02-03) 7 | 8 | 9 | 10 | ### 🔖 Miscellaneous 11 | 12 | * . ([0315714](https://github.com/bluelovers/ws-string/commit/0315714ab0f98cce959be71cbe0b86c3e96401f3)) 13 | * @lazy-cjk/str-util-normalize ([64554ab](https://github.com/bluelovers/ws-string/commit/64554ab7215653f89e566771630124052ee9d2a4)) 14 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/str-util-normalize/README.md: -------------------------------------------------------------------------------- 1 | # README.md 2 | 3 | 4 | 5 | ## install 6 | 7 | ```bash 8 | yarn add @lazy-cjk/str-util-normalize 9 | yarn-tool add @lazy-cjk/str-util-normalize 10 | yt add @lazy-cjk/str-util-normalize 11 | ``` 12 | 13 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/str-util-normalize/dist/index.cjs: -------------------------------------------------------------------------------- 1 | 2 | 'use strict' 3 | 4 | if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production') { 5 | module.exports = require('./index.cjs.development.cjs') 6 | } else { 7 | module.exports = require('./index.cjs.production.min.cjs') 8 | } 9 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/str-util-normalize/dist/index.cjs.development.cjs: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Object.defineProperty(exports, '__esModule', { value: true }); 4 | 5 | const StripTable = [/[\u2000-\u200F]/g, /[\u2028-\u202F]/g, /[\u205F-\u206F]/g, /\uFEFF/g]; 6 | function normalize(input, options = {}) { 7 | if (!options.allow_nbsp) { 8 | input = input.replace(/\xA0/g, ' '); 9 | } 10 | if (!options.allow_bom) { 11 | input = input.replace(/\uFEFF/g, ''); 12 | } 13 | StripTable.forEach(function (r) { 14 | input = input.replace(r, ''); 15 | }); 16 | return input; 17 | } 18 | 19 | exports.StripTable = StripTable; 20 | exports.default = normalize; 21 | exports.normalize = normalize; 22 | //# sourceMappingURL=index.cjs.development.cjs.map 23 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/str-util-normalize/dist/index.cjs.production.min.cjs: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: !0 5 | }); 6 | 7 | const e = [ /[\u2000-\u200F]/g, /[\u2028-\u202F]/g, /[\u205F-\u206F]/g, /\uFEFF/g ]; 8 | 9 | function normalize(r, o = {}) { 10 | return o.allow_nbsp || (r = r.replace(/\xA0/g, " ")), o.allow_bom || (r = r.replace(/\uFEFF/g, "")), 11 | e.forEach((function(e) { 12 | r = r.replace(e, ""); 13 | })), r; 14 | } 15 | 16 | exports.StripTable = e, exports.default = normalize, exports.normalize = normalize; 17 | //# sourceMappingURL=index.cjs.production.min.cjs.map 18 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/str-util-normalize/dist/index.d.ts: -------------------------------------------------------------------------------- 1 | export declare const StripTable: readonly RegExp[]; 2 | export declare function normalize(input: string, options?: IOptions): string; 3 | export type IOptions = { 4 | allow_nbsp?: boolean; 5 | allow_bom?: boolean; 6 | }; 7 | 8 | export { 9 | normalize as default, 10 | }; 11 | 12 | export {}; 13 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/str-util-normalize/dist/index.esm.mjs: -------------------------------------------------------------------------------- 1 | const e = [ /[\u2000-\u200F]/g, /[\u2028-\u202F]/g, /[\u205F-\u206F]/g, /\uFEFF/g ]; 2 | 3 | function normalize(u, a = {}) { 4 | return a.allow_nbsp || (u = u.replace(/\xA0/g, " ")), a.allow_bom || (u = u.replace(/\uFEFF/g, "")), 5 | e.forEach((function(e) { 6 | u = u.replace(e, ""); 7 | })), u; 8 | } 9 | 10 | export { e as StripTable, normalize as default, normalize }; 11 | //# sourceMappingURL=index.esm.mjs.map 12 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/str-util-normalize/src/index.ts: -------------------------------------------------------------------------------- 1 | 2 | export const StripTable = [ 3 | 4 | /[\u2000-\u200F]/g, 5 | /[\u2028-\u202F]/g, 6 | /[\u205F-\u206F]/g, 7 | 8 | // ZERO WIDTH NO-BREAK SPACE 9 | /\uFEFF/g, 10 | 11 | ] as readonly RegExp[]; 12 | 13 | export function normalize(input: string, options: IOptions = {}): string 14 | { 15 | if (!options.allow_nbsp) 16 | { 17 | input = input.replace(/\xA0/g, ' '); 18 | } 19 | 20 | if (!options.allow_bom) 21 | { 22 | input = input.replace(/\uFEFF/g, ''); 23 | } 24 | 25 | StripTable.forEach(function (r) 26 | { 27 | input = input.replace(r, ''); 28 | }); 29 | 30 | return input; 31 | } 32 | 33 | export type IOptions = { 34 | allow_nbsp?: boolean, 35 | allow_bom?: boolean, 36 | } 37 | 38 | export default normalize; 39 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/str-util-normalize/test/__root.ts: -------------------------------------------------------------------------------- 1 | import { join } from "path"; 2 | 3 | export const __ROOT = join(__dirname, '..'); 4 | 5 | export const isWin = process.platform === "win32"; 6 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/str-util-normalize/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "module": "NodeNext", 5 | "noEmit": true, 6 | "declaration": false, 7 | "noUnusedParameters": false, 8 | "allowUnusedLabels": true, 9 | "noUnusedLocals": false, 10 | "noPropertyAccessFromIndexSignature": false 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/str-util-normalize/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@bluelovers/tsconfig/tsdx/index.json", 3 | "compilerOptions": {}, 4 | "exclude": [ 5 | "dist", 6 | "test" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/str-util-trim/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## 1.0.1 (2024-02-03) 7 | 8 | 9 | 10 | ### 🔖 Miscellaneous 11 | 12 | * @lazy-cjk/str-util-trim ([64b5de1](https://github.com/bluelovers/ws-string/commit/64b5de18f3347253d147ee6e811db578194a9cbd)) 13 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/str-util-trim/README.md: -------------------------------------------------------------------------------- 1 | # README.md 2 | 3 | 4 | 5 | ## install 6 | 7 | ```bash 8 | yarn add @lazy-cjk/str-util-trim 9 | yarn-tool add @lazy-cjk/str-util-trim 10 | yt add @lazy-cjk/str-util-trim 11 | ``` 12 | 13 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/str-util-trim/src/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2018/1/7/007. 3 | */ 4 | 5 | export interface ITrimOptions 6 | { 7 | trim?: string, 8 | multiline?: boolean, 9 | 10 | no_start?: boolean, 11 | no_end?: boolean, 12 | } 13 | 14 | export function trim(txt: unknown, character_mask?: string): string 15 | export function trim(txt: unknown, character_mask?: ITrimOptions): string 16 | export function trim(txt: unknown, character_mask?: string | ITrimOptions): string 17 | { 18 | let ret = txt.toString(); 19 | 20 | if (typeof character_mask == 'number' || typeof character_mask == 'string') 21 | { 22 | character_mask = { 23 | trim: character_mask.toString(), 24 | }; 25 | } 26 | 27 | if (character_mask) 28 | { 29 | let flags = ''; 30 | 31 | if (character_mask.multiline) 32 | { 33 | flags += 'm'; 34 | } 35 | 36 | let rs = []; 37 | let r; 38 | 39 | if (typeof character_mask.trim == 'string') 40 | { 41 | r = character_mask.trim.replace(/(\W)/g, '\\$1'); 42 | 43 | if (character_mask.multiline) 44 | { 45 | r += ' \\t\\uFEFF\\xA0'; 46 | } 47 | else 48 | { 49 | r += '\\s\\uFEFF\\xA0'; 50 | } 51 | } 52 | else 53 | { 54 | if (character_mask.multiline) 55 | { 56 | r = ' \\t\\uFEFF\\xA0'; 57 | } 58 | else 59 | { 60 | r = '\\s\\uFEFF\\xA0'; 61 | } 62 | } 63 | 64 | if (!character_mask.no_start) 65 | { 66 | rs.push(`^[${r}]+`); 67 | } 68 | 69 | if (!character_mask.no_end) 70 | { 71 | rs.push(`[${r}]+$`); 72 | } 73 | 74 | rs = rs.map(r => new RegExp(r, flags)); 75 | 76 | //console.log(rs); 77 | 78 | for (let r of rs) 79 | { 80 | ret = ret.replace(r, ''); 81 | } 82 | } 83 | else 84 | { 85 | ret = ret 86 | .replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '') 87 | ; 88 | } 89 | 90 | return ret; 91 | } 92 | 93 | export default trim 94 | 95 | //console.log(trim('. 123 ?', '.?')); 96 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/str-util-trim/test/__root.ts: -------------------------------------------------------------------------------- 1 | import { join } from "path"; 2 | 3 | export const __ROOT = join(__dirname, '..'); 4 | 5 | export const isWin = process.platform === "win32"; 6 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/str-util-trim/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "module": "NodeNext", 5 | "noEmit": true, 6 | "declaration": false, 7 | "noUnusedParameters": false, 8 | "allowUnusedLabels": true, 9 | "noUnusedLocals": false, 10 | "noPropertyAccessFromIndexSignature": false 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/str-util-trim/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@bluelovers/tsconfig/tsdx/index.json", 3 | "compilerOptions": {}, 4 | "exclude": [ 5 | "dist", 6 | "test" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/zh2num/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [1.0.2](https://github.com/bluelovers/ws-string/compare/@lazy-cjk/zh2num@1.0.1...@lazy-cjk/zh2num@1.0.2) (2024-02-03) 7 | 8 | 9 | 10 | ### 🔖 Miscellaneous 11 | 12 | * . ([91827bc](https://github.com/bluelovers/ws-string/commit/91827bc744c17170bd9d9010ed49e77590da211f)) 13 | 14 | 15 | 16 | ## 1.0.1 (2024-01-29) 17 | 18 | 19 | ### BREAKING CHANGES 20 | 21 | * @lazy-cjk/zh2num 22 | 23 | 24 | 25 | ### 📦 Code Refactoring 26 | 27 | * @lazy-cjk/zh2num ([9cf2092](https://github.com/bluelovers/ws-string/commit/9cf2092e0d7dfdcdc2e28b5c6a8cc9e562c4548b)) 28 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/zh2num/README.md: -------------------------------------------------------------------------------- 1 | # README.md 2 | 3 | 將漢字轉換成數字 4 | Parse Chinese/Japanese numeric strings to integer 5 | 6 | ## install 7 | 8 | ```bash 9 | yarn add @lazy-cjk/zh2num 10 | yarn-tool add @lazy-cjk/zh2num 11 | yt add @lazy-cjk/zh2num 12 | ``` 13 | 14 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/zh2num/dist/index.cjs: -------------------------------------------------------------------------------- 1 | 2 | 'use strict' 3 | 4 | if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production') { 5 | module.exports = require('./index.cjs.development.cjs') 6 | } else { 7 | module.exports = require('./index.cjs.production.min.cjs') 8 | } 9 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/zh2num/dist/index.d.ts: -------------------------------------------------------------------------------- 1 | export interface IOptions { 2 | /** 3 | * @see https://github.com/hakatashi/japanese.js/blob/master/src/numbers.es6 4 | */ 5 | digits?: string[]; 6 | /** 7 | * @see https://github.com/hakatashi/japanese.js/blob/master/src/numbers.es6 8 | */ 9 | unitNames?: string[]; 10 | /** 11 | * replace all 12 | */ 13 | unsafe?: boolean; 14 | /** 15 | * RegExp Flags 16 | */ 17 | flags?: string; 18 | chars?: string; 19 | truncateOne?: number | boolean; 20 | strict?: boolean; 21 | one?: boolean; 22 | string?: boolean; 23 | } 24 | export declare const defaultOptions: IOptions; 25 | /** 26 | * 將漢字轉換成數字 27 | * Parse Chinese/Japanese numeric strings to integer 28 | * 29 | * @param str 30 | * @param {IOptions} options 31 | * @returns {string|number} 32 | * 33 | * @example zh2num('千百十七') == 1117 34 | */ 35 | export declare function zh2num(str: number, options?: IOptions): number; 36 | export declare function zh2num(str: unknown, options?: IOptions): string; 37 | export declare function _chinese_parseInt(str: string, options: IOptions & { 38 | string: true; 39 | }): string; 40 | export declare function _chinese_parseInt(str: string, options?: IOptions & { 41 | string?: false; 42 | }): number; 43 | export declare function _chinese_parseInt(str: string, options?: IOptions): number; 44 | /** 45 | * 將數字轉為漢字 46 | * 47 | * @param number 48 | * @param options 49 | * @returns {string} 50 | * 51 | * @example num2zh(1117) == '千百十七' 52 | */ 53 | export declare function num2zh(number: unknown, options?: { 54 | strict?: boolean; 55 | }): string; 56 | declare const _default: { 57 | zh2num: typeof zh2num; 58 | num2zh: typeof num2zh; 59 | }; 60 | 61 | export { 62 | _default as default, 63 | }; 64 | 65 | export {}; 66 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/zh2num/dist/index.esm.mjs: -------------------------------------------------------------------------------- 1 | import { transcribeNumber as e, transcriptionConfigs as n, predefineedTranscriptionConfigs as t } from "@lazy-cjk/japanese"; 2 | 3 | export { predefineedTranscriptionConfigs, transcriptionConfigs } from "@lazy-cjk/japanese"; 4 | 5 | import { characters as r, chinese_parseInt as a } from "chinese-parseint2"; 6 | 7 | const s = { 8 | one: !0 9 | }; 10 | 11 | function zh2num(e, a = {}) { 12 | var i; 13 | a = Object.assign({}, s, a); 14 | let u = [], c = !0, o = n, l = t; 15 | for (let e of [ "digits", "unitNames" ]) if (Array.isArray(a[e]) && a[e].length) for (let n of a[e]) l[e][n] && (u = u.concat(Object.values(l[e][n]))); 16 | if ("number" == typeof a.truncateOne) for (let e in o.default.truncateOne) e < a.truncateOne && u.push(o.default.truncateOne[e]); else void 0 !== a.truncateOne && !0 !== a.truncateOne || !u.length || (u = u.concat(Object.values(o.default.truncateOne))); 17 | a.chars && (u = u.concat(Array.isArray(a.chars) ? a.chars : a.chars.split(""))), 18 | u.length && (c = !1), u.filter((function(e) { 19 | return 1 === e.length && e in r; 20 | })), c && (u = Object.keys(r)), (i = a).flags || (i.flags = "u"), a.unsafe && (a.flags += "g"); 21 | let f = u.join(""), p = e.toString(); 22 | if (!new RegExp("([^" + f + "])").test(p)) return _chinese_parseInt(p, a); 23 | if (a.strict) return Number.NaN; 24 | let h = new RegExp("([" + f + "]+)", a.flags); 25 | return p.replace(h, (function(...e) { 26 | return _chinese_parseInt(e[1], a); 27 | })).toString(); 28 | } 29 | 30 | const i = /([佰百])([一二三四五六七八九壹貳參肆伍陸柒捌玖])(?![零○〇一二三四五六七八九壹貳參肆伍陸柒捌玖拾十什])/; 31 | 32 | function _chinese_parseInt(e, n = {}) { 33 | n.one && (e = e.replace(i, "$1〇$2")); 34 | let t = a(e); 35 | return n.string && (t = t.toString()), t; 36 | } 37 | 38 | function num2zh(n, t = {}) { 39 | let r = parseInt(n); 40 | if (Number.isNaN(r) || null != t && t.strict && ("number" != typeof n || r !== n)) throw new TypeError(`${n} is not valid allow number`); 41 | return e(r, t); 42 | } 43 | 44 | var u = { 45 | zh2num, 46 | num2zh 47 | }; 48 | 49 | export { _chinese_parseInt, u as default, s as defaultOptions, num2zh, zh2num }; 50 | //# sourceMappingURL=index.esm.mjs.map 51 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/zh2num/test/__root.ts: -------------------------------------------------------------------------------- 1 | import { join } from "path"; 2 | 3 | export const __ROOT = join(__dirname, '..'); 4 | 5 | export const isWin = process.platform === "win32"; 6 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/zh2num/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "module": "NodeNext", 5 | "noEmit": true, 6 | "declaration": false, 7 | "noUnusedParameters": false, 8 | "allowUnusedLabels": true, 9 | "noUnusedLocals": false, 10 | "noPropertyAccessFromIndexSignature": false 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/@lazy-cjk/zh2num/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@bluelovers/tsconfig/tsdx/index.json", 3 | "compilerOptions": {}, 4 | "exclude": [ 5 | "dist", 6 | "test" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /packages/blank-line/.npmignore: -------------------------------------------------------------------------------- 1 | /.pnp 2 | .pnp.js 3 | .idea 4 | ~ci.list.txt 5 | ~ci.log.txt 6 | ~ci.errors.txt 7 | *.stackdump 8 | *.bak 9 | *.old 10 | *.log 11 | tsconfig.json 12 | package-lock.json 13 | test 14 | .github 15 | .gitkeep 16 | /.*/ 17 | /.* 18 | tests 19 | /~* 20 | __test__ 21 | __tests__ 22 | node_modules 23 | /node_modules/ 24 | **/node_modules/ 25 | *.ts 26 | !*.d.ts 27 | /bin/**/*.d.ts 28 | /bin/*.d.ts 29 | 30 | !*.d.mts 31 | /bin/**/*.d.mts 32 | /bin/*.d.mts 33 | 34 | !*.d.cts 35 | /bin/**/*.d.cts 36 | /bin/*.d.cts 37 | 38 | !/src/**/*.ts 39 | !/src/**/*.cts 40 | !/src/**/*.mts 41 | !/src/**/*.tsx 42 | 43 | /src/**/*.d.ts 44 | /src/**/*.js 45 | /src/**/*.d.cts 46 | /src/**/*.d.mts 47 | /src/**/*.cjs 48 | /src/**/*.mjs 49 | /src/**/*.jsx 50 | 51 | *.tgz 52 | /tsconfig.json.tpl 53 | yarn-error.log 54 | .git 55 | yarn.lock 56 | .env.local 57 | .env.*.local 58 | npm-debug.log* 59 | yarn-debug.log* 60 | yarn-error.log* 61 | .vscode 62 | *.suo 63 | *.ntvs* 64 | *.njsproj 65 | *.sln 66 | *.sw? 67 | *.vue.js 68 | *.vue.d.ts 69 | *.vue.js.map 70 | .nyc_output 71 | coverage 72 | /*.tpl 73 | webpack.config.js 74 | vue.config.js 75 | /jestconfig.json 76 | /tslint.json 77 | .git 78 | webpack.*.config.js 79 | webpack.*.config.d.ts 80 | webpack.*.config.js.map 81 | webpack.*.config.ts 82 | karma.conf.js 83 | /_config.yml 84 | intellij-style-guide.xml 85 | jest.config.js 86 | *.tsbuildinfo 87 | tsconfig.*.json 88 | tsconfig.esm.json.tpl 89 | /package.d.ts 90 | .mocharc.yml 91 | jest.config.js 92 | jest.config.* 93 | /jest-preset.* 94 | /report.*.json 95 | now.json 96 | /Makefile 97 | *.spec.d.ts 98 | *.spec.js 99 | *.spec.ts 100 | 101 | *.spec.d.cts 102 | *.spec.cjs 103 | *.spec.cts 104 | 105 | *.spec.d.mts 106 | *.spec.mjs 107 | *.spec.mts 108 | 109 | *.spec.d.tsx 110 | *.spec.tsx 111 | 112 | __mocks__ 113 | __tests__ 114 | __snapshots__ 115 | *.snap 116 | npm-shrinkwrap.json 117 | /example/ 118 | *.stat 119 | .vercel 120 | tsdx.config.js 121 | /report.json 122 | 123 | /_*/ 124 | _snowpack 125 | 126 | /snowpack.config.js 127 | web_modules 128 | cz-adapter 129 | 130 | tsc-multi.json.tpl 131 | tsc-multi.json 132 | 133 | changelog-option.js 134 | 135 | bin/tsconfig.json 136 | bin/tsconfig.*.json 137 | 138 | .yarnrc.yml 139 | .turbo 140 | __file_snapshots__ 141 | __fixtures__ 142 | /fixture/ 143 | -------------------------------------------------------------------------------- /packages/blank-line/README.md: -------------------------------------------------------------------------------- 1 | # blank-line 2 | 3 | > get min/mid/max blank line length in text ( not include start/end line ) 4 | 5 | `npm i blank-line` 6 | 7 | # demo 8 | 9 | 10 | ```javascript 11 | 12 | import blankLine from 'blank-line'; 13 | 14 | [ 15 | ` 16 | 17 | 18 | 19 | 黑暗,无论哪里都是黑暗,感觉不到一点光线的黑暗。 20 | 21 | 最初感到不协调是气味,鼻子疼,有一股浓厚的腥臭味。然后呼吸器官开始陷入有某种胶状的污泥升上来的错觉中,被这样的不快感所震惊。 22 | 23 | 睁开双眼,一跃而起。 24 | 25 | 「--!」 26 | 27 | 映入视野中的是黑暗的回廊,没有一丝丝的光照,只有默默发光的石造房间。 28 | 29 | 环视四周,背后是小型祭坛一般的建筑。仔细观察发现「祭坛」风化严重,处在快要奔溃的边缘。 30 | 31 | 上面有小石台和两只蜡烛的残渣,还供奉着插着箭的动物皮。 32 | 33 | `, 34 | 35 | ` 36 | 37 | 黑暗,无论哪里都是黑暗,感觉不到一点光线的黑暗。 38 | 最初感到不协调是气味,鼻子疼,有一股浓厚的腥臭味。然后呼吸器官开始陷入有某种胶状的污泥升上来的错觉中,被这样的不快感所震惊。 39 | 40 | 睁开双眼,一跃而起。 41 | 42 | 「--!」 43 | 44 | 45 | 映入视野中的是黑暗的回廊,没有一丝丝的光照,只有默默发光的石造房间。 46 | 47 | 环视四周,背后是小型祭坛一般的建筑。仔细观察发现「祭坛」风化严重,处在快要奔溃的边缘。 48 | 49 | 上面有小石台和两只蜡烛的残渣,还供奉着插着箭的动物皮。 50 | 51 | `, 52 | 53 | ` 54 | 55 | 黑暗,无论哪里都是黑暗,感觉不到一点光线的黑暗。 56 | 57 | 最初感到不协调是气味,鼻子疼,有一股浓厚的腥臭味。然后呼吸器官开始陷入有某种胶状的污泥升上来的错觉中,被这样的不快感所震惊。 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 睁开双眼,一跃而起。 69 | 70 | 「--!」 71 | 72 | 73 | 74 | 75 | 76 | 映入视野中的是黑暗的回廊,没有一丝丝的光照,只有默默发光的石造房间。 77 | 78 | 环视四周,背后是小型祭坛一般的建筑。仔细观察发现「祭坛」风化严重,处在快要奔溃的边缘。 79 | 80 | 上面有小石台和两只蜡烛的残渣,还供奉着插着箭的动物皮。 81 | 82 | 83 | 84 | 85 | `, 86 | 87 | ` 88 | 89 | 黑暗,无论哪里都是黑暗,感觉不到一点光线的黑暗。 90 | 最初感到不协调是气味,鼻子疼,有一股浓厚的腥臭味。然后呼吸器官开始陷入有某种胶状的污泥升上来的错觉中,被这样的不快感所震惊。 91 | 睁开双眼,一跃而起。 92 | 「--!」 93 | 映入视野中的是黑暗的回廊,没有一丝丝的光照,只有默默发光的石造房间。 94 | 环视四周,背后是小型祭坛一般的建筑。仔细观察发现「祭坛」风化严重,处在快要奔溃的边缘。 95 | 上面有小石台和两只蜡烛的残渣,还供奉着插着箭的动物皮。 96 | 97 | 98 | 99 | 100 | `, 101 | 102 | ].forEach(function (value, index, array) 103 | { 104 | console.log(index, blankLine(value)); 105 | }); 106 | 107 | //0 [ 2, 2, 2 ] 108 | //1 [ 1, 2, 3 ] 109 | //2 [ 2, 6, 11 ] 110 | //3 [ 1, 1, 1 ] 111 | 112 | ``` 113 | 114 | -------------------------------------------------------------------------------- /packages/blank-line/dist/index.cjs: -------------------------------------------------------------------------------- 1 | 2 | 'use strict' 3 | 4 | if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production') { 5 | module.exports = require('./index.cjs.development.cjs') 6 | } else { 7 | module.exports = require('./index.cjs.production.min.cjs') 8 | } 9 | -------------------------------------------------------------------------------- /packages/blank-line/dist/index.cjs.development.cjs: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Object.defineProperty(exports, '__esModule', { value: true }); 4 | 5 | var execall2 = require('execall2'); 6 | 7 | const LF = "\n"; 8 | function normalize(txt) { 9 | return String(txt).replace(/\r\n|\r(?!\n)|\n/g, LF).replace(/\uFEFF/g, '').replace(/[  \xA0]/g, ' ').replace(/[ \t \xA0\u3000]+\n/g, '\n').replace(/^\n+|[\s \xA0\u3000]+$/g, ''); 10 | } 11 | 12 | function getBlankLine(txt, options = {}) { 13 | let _ms = execall2.execall(/\n+/g, normalize(txt)); 14 | if (_ms.length) { 15 | let _ret = _ms.reduce(function (a, b) { 16 | a.push(b.match.length); 17 | return a; 18 | }, []); 19 | if (options.filter) { 20 | _ret = _ret.filter(function (v, i, a) { 21 | return a.indexOf(v) == i; 22 | }); 23 | } 24 | if (options.sort) { 25 | _ret.sort(function (a, b) { 26 | return a - b; 27 | }); 28 | } 29 | return _ret; 30 | } 31 | return null; 32 | } 33 | function getMinMidMax(txt) { 34 | let _ms = getBlankLine(txt, { 35 | filter: true, 36 | sort: true 37 | }); 38 | if (!(_ms !== null && _ms !== void 0 && _ms.length)) { 39 | return [null, null, null]; 40 | } 41 | let min = _ms[0] || null; 42 | let max = _ms[_ms.length - 1] || min; 43 | let mid = _ms[1] || min; 44 | return [min, mid, max]; 45 | } 46 | 47 | exports.default = getMinMidMax; 48 | exports.getBlankLine = getBlankLine; 49 | exports.getMinMidMax = getMinMidMax; 50 | exports.normalize = normalize; 51 | //# sourceMappingURL=index.cjs.development.cjs.map 52 | -------------------------------------------------------------------------------- /packages/blank-line/dist/index.cjs.production.min.cjs: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: !0 5 | }); 6 | 7 | var e = require("execall2"); 8 | 9 | const n = "\n"; 10 | 11 | function normalize(e) { 12 | return String(e).replace(/\r\n|\r(?!\n)|\n/g, n).replace(/\uFEFF/g, "").replace(/[  \xA0]/g, " ").replace(/[ \t \xA0\u3000]+\n/g, "\n").replace(/^\n+|[\s \xA0\u3000]+$/g, ""); 13 | } 14 | 15 | function getBlankLine(n, t = {}) { 16 | let r = e.execall(/\n+/g, normalize(n)); 17 | if (r.length) { 18 | let e = r.reduce((function(e, n) { 19 | return e.push(n.match.length), e; 20 | }), []); 21 | return t.filter && (e = e.filter((function(e, n, t) { 22 | return t.indexOf(e) == n; 23 | }))), t.sort && e.sort((function(e, n) { 24 | return e - n; 25 | })), e; 26 | } 27 | return null; 28 | } 29 | 30 | function getMinMidMax(e) { 31 | let n = getBlankLine(e, { 32 | filter: !0, 33 | sort: !0 34 | }); 35 | if (null == n || !n.length) return [ null, null, null ]; 36 | let t = n[0] || null; 37 | return [ t, n[1] || t, n[n.length - 1] || t ]; 38 | } 39 | 40 | exports.default = getMinMidMax, exports.getBlankLine = getBlankLine, exports.getMinMidMax = getMinMidMax, 41 | exports.normalize = normalize; 42 | //# sourceMappingURL=index.cjs.production.min.cjs.map 43 | -------------------------------------------------------------------------------- /packages/blank-line/dist/index.d.ts: -------------------------------------------------------------------------------- 1 | export declare function normalize(txt: string | Buffer): string; 2 | export interface IOptions { 3 | filter?: boolean; 4 | sort?: boolean; 5 | } 6 | export declare function getBlankLine(txt: string | Buffer, options?: IOptions): number[]; 7 | export type IGetMinMidMax = [ 8 | /** 9 | * min 10 | */ 11 | min: number, 12 | /** 13 | * mid 14 | */ 15 | mid: number, 16 | /** 17 | * max 18 | */ 19 | max: number 20 | ]; 21 | export declare function getMinMidMax(txt: string | Buffer): IGetMinMidMax; 22 | 23 | export { 24 | getMinMidMax as default, 25 | }; 26 | 27 | export {}; 28 | -------------------------------------------------------------------------------- /packages/blank-line/dist/index.esm.mjs: -------------------------------------------------------------------------------- 1 | import { execall as n } from "execall2"; 2 | 3 | const e = "\n"; 4 | 5 | function normalize(n) { 6 | return String(n).replace(/\r\n|\r(?!\n)|\n/g, e).replace(/\uFEFF/g, "").replace(/[  \xA0]/g, " ").replace(/[ \t \xA0\u3000]+\n/g, "\n").replace(/^\n+|[\s \xA0\u3000]+$/g, ""); 7 | } 8 | 9 | function getBlankLine(e, t = {}) { 10 | let l = n(/\n+/g, normalize(e)); 11 | if (l.length) { 12 | let n = l.reduce((function(n, e) { 13 | return n.push(e.match.length), n; 14 | }), []); 15 | return t.filter && (n = n.filter((function(n, e, t) { 16 | return t.indexOf(n) == e; 17 | }))), t.sort && n.sort((function(n, e) { 18 | return n - e; 19 | })), n; 20 | } 21 | return null; 22 | } 23 | 24 | function getMinMidMax(n) { 25 | let e = getBlankLine(n, { 26 | filter: !0, 27 | sort: !0 28 | }); 29 | if (null == e || !e.length) return [ null, null, null ]; 30 | let t = e[0] || null; 31 | return [ t, e[1] || t, e[e.length - 1] || t ]; 32 | } 33 | 34 | export { getMinMidMax as default, getBlankLine, getMinMidMax, normalize }; 35 | //# sourceMappingURL=index.esm.mjs.map 36 | -------------------------------------------------------------------------------- /packages/blank-line/src/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2018/1/13/013. 3 | */ 4 | 5 | import { execall } from 'execall2'; 6 | import { normalize } from './normalize'; 7 | 8 | export interface IOptions 9 | { 10 | filter?: boolean, 11 | sort?: boolean, 12 | } 13 | 14 | export { normalize } 15 | 16 | export function getBlankLine(txt: string | Buffer, options: IOptions = {}): number[] 17 | { 18 | let _ms = execall(/\n+/g, normalize(txt)); 19 | 20 | if (_ms.length) 21 | { 22 | let _ret: number[] = (_ms) 23 | .reduce(function (a, b) 24 | { 25 | a.push(b.match.length); 26 | 27 | return a; 28 | }, []) 29 | ; 30 | 31 | if (options.filter) 32 | { 33 | _ret = _ret.filter(function (v, i, a) 34 | { 35 | return a.indexOf(v) == i; 36 | }); 37 | } 38 | 39 | if (options.sort) 40 | { 41 | _ret.sort(function (a, b) 42 | { 43 | return a - b; 44 | }); 45 | } 46 | 47 | return _ret; 48 | } 49 | 50 | return null; 51 | } 52 | 53 | export type IGetMinMidMax = [ 54 | /** 55 | * min 56 | */ 57 | min: number, 58 | /** 59 | * mid 60 | */ 61 | mid: number, 62 | /** 63 | * max 64 | */ 65 | max: number, 66 | ]; 67 | 68 | export function getMinMidMax(txt: string | Buffer): IGetMinMidMax 69 | { 70 | let _ms = getBlankLine(txt, { 71 | filter: true, 72 | sort: true, 73 | }); 74 | 75 | if (!_ms?.length) 76 | { 77 | return [null, null, null]; 78 | } 79 | 80 | let min = _ms[0] || null; 81 | let max = _ms[_ms.length - 1] || min; 82 | 83 | let mid = _ms[1] || min; 84 | 85 | return [min, mid, max]; 86 | } 87 | 88 | export default getMinMidMax; 89 | -------------------------------------------------------------------------------- /packages/blank-line/src/normalize.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2018/1/19/019. 3 | */ 4 | 5 | export const LF = "\n"; 6 | 7 | export function normalize(txt: string | Buffer) 8 | { 9 | return String(txt) 10 | .replace(/\r\n|\r(?!\n)|\n/g, LF) 11 | .replace(/\uFEFF/g, '') 12 | .replace(/[  \xA0]/g, ' ') 13 | .replace(/[ \t \xA0\u3000]+\n/g, '\n') 14 | .replace(/^\n+|[\s \xA0\u3000]+$/g, '') 15 | ; 16 | } 17 | 18 | export default normalize; 19 | //export default exports; 20 | -------------------------------------------------------------------------------- /packages/blank-line/test/__snapshots__/demo.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`demo blankLine:0 1`] = ` 4 | [ 5 | 2, 6 | 2, 7 | 2, 8 | 2, 9 | 2, 10 | 2, 11 | ] 12 | `; 13 | 14 | exports[`demo blankLine:1 1`] = ` 15 | [ 16 | 1, 17 | 2, 18 | 2, 19 | 3, 20 | 2, 21 | 2, 22 | ] 23 | `; 24 | 25 | exports[`demo blankLine:2 1`] = ` 26 | [ 27 | 2, 28 | 11, 29 | 2, 30 | 6, 31 | 2, 32 | 2, 33 | ] 34 | `; 35 | 36 | exports[`demo blankLine:3 1`] = ` 37 | [ 38 | 1, 39 | 1, 40 | 1, 41 | 1, 42 | 1, 43 | 1, 44 | ] 45 | `; 46 | 47 | exports[`demo blankLine:4 1`] = ` 48 | [ 49 | 1, 50 | 2, 51 | 2, 52 | 3, 53 | 2, 54 | 2, 55 | ] 56 | `; 57 | 58 | exports[`demo blankLine:5 1`] = ` 59 | [ 60 | 2, 61 | 11, 62 | 2, 63 | 6, 64 | 2, 65 | 2, 66 | 8, 67 | 3, 68 | ] 69 | `; 70 | 71 | exports[`demo getMinMidMax:0 1`] = ` 72 | [ 73 | 2, 74 | 2, 75 | 2, 76 | ] 77 | `; 78 | 79 | exports[`demo getMinMidMax:1 1`] = ` 80 | [ 81 | 1, 82 | 2, 83 | 3, 84 | ] 85 | `; 86 | 87 | exports[`demo getMinMidMax:2 1`] = ` 88 | [ 89 | 2, 90 | 6, 91 | 11, 92 | ] 93 | `; 94 | 95 | exports[`demo getMinMidMax:3 1`] = ` 96 | [ 97 | 1, 98 | 1, 99 | 1, 100 | ] 101 | `; 102 | 103 | exports[`demo getMinMidMax:4 1`] = ` 104 | [ 105 | 1, 106 | 2, 107 | 3, 108 | ] 109 | `; 110 | 111 | exports[`demo getMinMidMax:5 1`] = ` 112 | [ 113 | 2, 114 | 3, 115 | 11, 116 | ] 117 | `; 118 | -------------------------------------------------------------------------------- /packages/blank-line/test/demo.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2018/1/19/019. 3 | */ 4 | 5 | import blankLine from '../src'; 6 | 7 | [ 8 | ` 9 | 10 | 11 | 12 | 黑暗,无论哪里都是黑暗,感觉不到一点光线的黑暗。 13 | 14 | 最初感到不协调是气味,鼻子疼,有一股浓厚的腥臭味。然后呼吸器官开始陷入有某种胶状的污泥升上来的错觉中,被这样的不快感所震惊。 15 | 16 | 睁开双眼,一跃而起。 17 | 18 | 「--!」 19 | 20 | 映入视野中的是黑暗的回廊,没有一丝丝的光照,只有默默发光的石造房间。 21 | 22 | 环视四周,背后是小型祭坛一般的建筑。仔细观察发现「祭坛」风化严重,处在快要奔溃的边缘。 23 | 24 | 上面有小石台和两只蜡烛的残渣,还供奉着插着箭的动物皮。 25 | 26 | `, 27 | 28 | ` 29 | 30 | 黑暗,无论哪里都是黑暗,感觉不到一点光线的黑暗。 31 | 最初感到不协调是气味,鼻子疼,有一股浓厚的腥臭味。然后呼吸器官开始陷入有某种胶状的污泥升上来的错觉中,被这样的不快感所震惊。 32 | 33 | 睁开双眼,一跃而起。 34 | 35 | 「--!」 36 | 37 | 38 | 映入视野中的是黑暗的回廊,没有一丝丝的光照,只有默默发光的石造房间。 39 | 40 | 环视四周,背后是小型祭坛一般的建筑。仔细观察发现「祭坛」风化严重,处在快要奔溃的边缘。 41 | 42 | 上面有小石台和两只蜡烛的残渣,还供奉着插着箭的动物皮。 43 | 44 | `, 45 | 46 | ` 47 | 48 | 黑暗,无论哪里都是黑暗,感觉不到一点光线的黑暗。 49 | 50 | 最初感到不协调是气味,鼻子疼,有一股浓厚的腥臭味。然后呼吸器官开始陷入有某种胶状的污泥升上来的错觉中,被这样的不快感所震惊。 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 睁开双眼,一跃而起。 62 | 63 | 「--!」 64 | 65 | 66 | 67 | 68 | 69 | 映入视野中的是黑暗的回廊,没有一丝丝的光照,只有默默发光的石造房间。 70 | 71 | 环视四周,背后是小型祭坛一般的建筑。仔细观察发现「祭坛」风化严重,处在快要奔溃的边缘。 72 | 73 | 上面有小石台和两只蜡烛的残渣,还供奉着插着箭的动物皮。 74 | 75 | 76 | 77 | 78 | `, 79 | 80 | ` 81 | 82 | 黑暗,无论哪里都是黑暗,感觉不到一点光线的黑暗。 83 | 最初感到不协调是气味,鼻子疼,有一股浓厚的腥臭味。然后呼吸器官开始陷入有某种胶状的污泥升上来的错觉中,被这样的不快感所震惊。 84 | 睁开双眼,一跃而起。 85 | 「--!」 86 | 映入视野中的是黑暗的回廊,没有一丝丝的光照,只有默默发光的石造房间。 87 | 环视四周,背后是小型祭坛一般的建筑。仔细观察发现「祭坛」风化严重,处在快要奔溃的边缘。 88 | 上面有小石台和两只蜡烛的残渣,还供奉着插着箭的动物皮。 89 | 90 | 91 | 92 | 93 | `, 94 | 95 | ].forEach(function (value, index) 96 | { 97 | console.log(index, blankLine(value)); 98 | }); 99 | -------------------------------------------------------------------------------- /packages/blank-line/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@bluelovers/tsconfig/tsdx/index.json", 3 | "compilerOptions": { 4 | "importHelpers": true, 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/chinese-parseint2/README.md: -------------------------------------------------------------------------------- 1 | # chinese-parseint 2 | Parse Chinese numeric strings to integer; also usable for client-side script. 3 | 4 | ## In browsers (front-end JavaScript) 5 | Download `chinese-parseint.js`. 6 | ### Usage 7 | ```html 8 | 9 | 10 | 13 | ``` 14 | 15 | ## In Node.js 16 | `npm install chinese-parseint` 17 | ### Usage 18 | ```javascript 19 | var chinese_parseInt = require('chinese-parseint'); 20 | chinese_parseInt('一千零一十'); ///< returns 1010 21 | chinese_parseInt('二十四万二'); ///< returns 242000 22 | ``` 23 | 24 | ## Notes 25 | * This does NOT check if the string is semantically right in Chinese. For example, `chinese_parseInt('千三萬')` returns 10030000 instead of `NaN` even if '千三萬' is not a right term in Chinese. 26 | * See `chinese_parseInt.characters` for corresponding numbers of each accepted Chinese character. 27 | * To convert character encodings (such as from Big5 to UTF-8), consider [`iconv-lite`](https://www.npmjs.com/package/iconv-lite) package. 28 | -------------------------------------------------------------------------------- /packages/chinese-parseint2/dist/index.cjs: -------------------------------------------------------------------------------- 1 | 2 | 'use strict' 3 | 4 | if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production') { 5 | module.exports = require('./index.cjs.development.cjs') 6 | } else { 7 | module.exports = require('./index.cjs.production.min.cjs') 8 | } 9 | -------------------------------------------------------------------------------- /packages/chinese-parseint2/src/data.ts: -------------------------------------------------------------------------------- 1 | 2 | export const characters = Object.freeze({ 3 | "0": 0, "零": 0, "○": 0, "〇": 0, "洞": 0, 4 | "1": 1, "一": 1, "壹": 1, "ㄧ": 1, "弌": 1, "么": 1, 5 | "2": 2, "二": 2, "貳": 2, "贰": 2, "弍": 2, "兩": 2, "两": 2, 6 | "3": 3, "三": 3, "參": 3, "叁": 3, "弎": 3, "参": 3, "叄": 3, 7 | "4": 4, "四": 4, "肆": 4, "䦉": 4, "刀": 4, 8 | "5": 5, "五": 5, "伍": 5, 9 | "6": 6, "六": 6, "陸": 6, "陆": 6, 10 | "7": 7, "七": 7, "柒": 7, "拐": 7, 11 | "8": 8, "八": 8, "捌": 8, "杯": 8, 12 | "9": 9, "九": 9, "玖": 9, "勾": 9, 13 | "十": 10, "拾": 10, "什": 10, "呀": 10, 14 | "百": 100, "佰": 100, 15 | "千": 1000, "仟": 1000, 16 | "念": 20, "廿": 20, 17 | "卅": 30, "卌": 40, "皕": 200, 18 | "萬": 1e+4, "万": 1e+4, 19 | "億": 1e+8, "亿": 1e+8, 20 | "兆": 1e+12, 21 | "京": 1e+16, "經": 1e+16, "经": 1e+16, 22 | "垓": 1e+20, 23 | "秭": 1e+24, "杼": 1e+24, 24 | "穰": 1e+28, "壤": 1e+28, 25 | "溝": 1e+32, "沟": 1e+32, 26 | "澗": 1e+36, "涧": 1e+36, 27 | "正": 1e+40, "載": 1e+44, "極": 1e+48, 28 | } as const); 29 | -------------------------------------------------------------------------------- /packages/chinese-parseint2/test/test.test.ts: -------------------------------------------------------------------------------- 1 | import cpi from '../src'; 2 | 3 | const units = [ 4 | ['哈哈', NaN], 5 | ['零五', 5], 6 | ['六 八 九', 689], 7 | ['洞么兩三刀伍陸拐杯勾', 123456789], 8 | ['一千零十', 1010], 9 | ['一千零一十', 1010], 10 | ['二百五', 250], 11 | ['千三', 1300], 12 | ['二十四萬二', 242000], 13 | ['四萬萬五千萬', 450000000], 14 | ] as [string, number][]; 15 | 16 | describe(`demo`, () => { 17 | units.forEach(function (cur) 18 | { 19 | test(cur[0], () => { 20 | 21 | let actual = cpi(cur[0]); 22 | let expected = cur[1]; 23 | 24 | expect(actual).toStrictEqual(expected) 25 | 26 | }); 27 | }); 28 | }) 29 | -------------------------------------------------------------------------------- /packages/chinese-parseint2/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@bluelovers/tsconfig/tsdx/index.json", 3 | "compilerOptions": { 4 | "importHelpers": true, 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/crlf-normalize-stream/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [1.0.2](https://github.com/bluelovers/ws-string/compare/crlf-normalize-stream@1.0.1...crlf-normalize-stream@1.0.2) (2024-01-29) 7 | 8 | 9 | 10 | ### 🔖 Miscellaneous 11 | 12 | * . ([abfa4b0](https://github.com/bluelovers/ws-string/commit/abfa4b0ae395784c7c368d7bb34c2b22688dcc65)) 13 | 14 | 15 | 16 | ## 1.0.1 (2023-09-08) 17 | 18 | 19 | 20 | ### 🔖 Miscellaneous 21 | 22 | * crlf-normalize-stream ([f9aa36c](https://github.com/bluelovers/ws-string/commit/f9aa36c2e54d750ac804d8f581e8f81d9f076126)) 23 | -------------------------------------------------------------------------------- /packages/crlf-normalize-stream/README.md: -------------------------------------------------------------------------------- 1 | # README.md 2 | 3 | 4 | 5 | ## install 6 | 7 | ```bash 8 | yarn add crlf-normalize-stream 9 | yarn-tool add crlf-normalize-stream 10 | yt add crlf-normalize-stream 11 | ``` 12 | 13 | -------------------------------------------------------------------------------- /packages/crlf-normalize-stream/dist/index.cjs: -------------------------------------------------------------------------------- 1 | 2 | 'use strict' 3 | 4 | if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production') { 5 | module.exports = require('./index.cjs.development.cjs') 6 | } else { 7 | module.exports = require('./index.cjs.production.min.cjs') 8 | } 9 | -------------------------------------------------------------------------------- /packages/crlf-normalize-stream/dist/index.cjs.development.cjs: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var stream = require('stream'); 4 | var crlfNormalize = require('crlf-normalize'); 5 | 6 | function transformLinebreak(newline) { 7 | return new stream.Transform({ 8 | transform(chunk, _encoding, callback) { 9 | const data = crlfNormalize.crlf(chunk.toString(), newline); 10 | callback(null, data); 11 | } 12 | }); 13 | } 14 | // @ts-ignore 15 | { 16 | Object.defineProperty(transformLinebreak, "__esModule", { 17 | value: true 18 | }); 19 | Object.defineProperty(transformLinebreak, 'transformLinebreak', { 20 | value: transformLinebreak 21 | }); 22 | Object.defineProperty(transformLinebreak, 'default', { 23 | value: transformLinebreak 24 | }); 25 | } 26 | 27 | // @ts-ignore 28 | module.exports = transformLinebreak; 29 | //# sourceMappingURL=index.cjs.development.cjs.map 30 | -------------------------------------------------------------------------------- /packages/crlf-normalize-stream/dist/index.cjs.production.min.cjs: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | var r = require("stream"), e = require("crlf-normalize"); 4 | 5 | function transformLinebreak(n) { 6 | return new r.Transform({ 7 | transform(r, a, t) { 8 | t(null, e.crlf(r.toString(), n)); 9 | } 10 | }); 11 | } 12 | 13 | Object.defineProperty(transformLinebreak, "__esModule", { 14 | value: !0 15 | }), Object.defineProperty(transformLinebreak, "transformLinebreak", { 16 | value: transformLinebreak 17 | }), Object.defineProperty(transformLinebreak, "default", { 18 | value: transformLinebreak 19 | }), module.exports = transformLinebreak; 20 | //# sourceMappingURL=index.cjs.production.min.cjs.map 21 | -------------------------------------------------------------------------------- /packages/crlf-normalize-stream/dist/index.d.ts: -------------------------------------------------------------------------------- 1 | import { Transform } from 'stream'; 2 | import { ITSAndTypeAndStringLiteral } from 'ts-type/lib/helper/string'; 3 | 4 | export declare const enum EnumLineBreak { 5 | CR = "\r", 6 | CRLF = "\r\n", 7 | LF = "\n" 8 | } 9 | export type ILineBreakInput = ITSAndTypeAndStringLiteral; 10 | export declare function transformLinebreak(newline?: ILineBreakInput): Transform; 11 | 12 | export { 13 | transformLinebreak as default, 14 | }; 15 | 16 | export {}; 17 | -------------------------------------------------------------------------------- /packages/crlf-normalize-stream/dist/index.esm.mjs: -------------------------------------------------------------------------------- 1 | import { Transform as r } from "stream"; 2 | 3 | import { crlf as n } from "crlf-normalize"; 4 | 5 | function transformLinebreak(t) { 6 | return new r({ 7 | transform(r, e, o) { 8 | o(null, n(r.toString(), t)); 9 | } 10 | }); 11 | } 12 | 13 | export { transformLinebreak as default, transformLinebreak }; 14 | //# sourceMappingURL=index.esm.mjs.map 15 | -------------------------------------------------------------------------------- /packages/crlf-normalize-stream/src/index.cts: -------------------------------------------------------------------------------- 1 | import _ from './index'; 2 | 3 | // @ts-ignore 4 | export = _ 5 | -------------------------------------------------------------------------------- /packages/crlf-normalize-stream/src/index.ts: -------------------------------------------------------------------------------- 1 | import { Transform } from 'stream'; 2 | import { crlf, ILineBreakInput } from 'crlf-normalize'; 3 | 4 | export function transformLinebreak(newline?: ILineBreakInput) 5 | { 6 | return new Transform({ 7 | transform(chunk, _encoding, callback) 8 | { 9 | const data = crlf(chunk.toString(), newline); 10 | callback(null, data); 11 | }, 12 | }) 13 | } 14 | 15 | // @ts-ignore 16 | if (process.env.TSDX_FORMAT !== 'esm') 17 | { 18 | Object.defineProperty(transformLinebreak, "__esModule", { value: true }); 19 | 20 | Object.defineProperty(transformLinebreak, 'transformLinebreak', { value: transformLinebreak }); 21 | Object.defineProperty(transformLinebreak, 'default', { value: transformLinebreak }); 22 | 23 | 24 | } 25 | 26 | export default transformLinebreak 27 | -------------------------------------------------------------------------------- /packages/crlf-normalize-stream/test/__root.ts: -------------------------------------------------------------------------------- 1 | import { join } from "path"; 2 | 3 | export const __ROOT = join(__dirname, '..'); 4 | 5 | export const isWin = process.platform === "win32"; 6 | -------------------------------------------------------------------------------- /packages/crlf-normalize-stream/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "module": "NodeNext", 5 | "noEmit": true, 6 | "declaration": false, 7 | "noUnusedParameters": false, 8 | "allowUnusedLabels": true, 9 | "noUnusedLocals": false, 10 | "noPropertyAccessFromIndexSignature": false 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/crlf-normalize-stream/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@bluelovers/tsconfig/tsdx/index.json", 3 | "compilerOptions": {}, 4 | "exclude": [ 5 | "dist", 6 | "test" 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /packages/crlf-normalize/.npmignore: -------------------------------------------------------------------------------- 1 | /.pnp 2 | .pnp.js 3 | .idea 4 | ~ci.list.txt 5 | ~ci.log.txt 6 | ~ci.errors.txt 7 | *.stackdump 8 | *.bak 9 | *.old 10 | *.log 11 | tsconfig.json 12 | package-lock.json 13 | test 14 | .github 15 | .gitkeep 16 | /.*/ 17 | /.* 18 | tests 19 | /~* 20 | __test__ 21 | __tests__ 22 | node_modules 23 | /node_modules/ 24 | **/node_modules/ 25 | *.ts 26 | !*.d.ts 27 | /bin/**/*.d.ts 28 | /bin/*.d.ts 29 | 30 | !*.d.mts 31 | /bin/**/*.d.mts 32 | /bin/*.d.mts 33 | 34 | !*.d.cts 35 | /bin/**/*.d.cts 36 | /bin/*.d.cts 37 | 38 | !/src/**/*.ts 39 | !/src/**/*.cts 40 | !/src/**/*.mts 41 | !/src/**/*.tsx 42 | 43 | /src/**/*.d.ts 44 | /src/**/*.js 45 | /src/**/*.d.cts 46 | /src/**/*.d.mts 47 | /src/**/*.cjs 48 | /src/**/*.mjs 49 | /src/**/*.jsx 50 | 51 | *.tgz 52 | /tsconfig.json.tpl 53 | yarn-error.log 54 | .git 55 | yarn.lock 56 | .env.local 57 | .env.*.local 58 | npm-debug.log* 59 | yarn-debug.log* 60 | yarn-error.log* 61 | .vscode 62 | *.suo 63 | *.ntvs* 64 | *.njsproj 65 | *.sln 66 | *.sw? 67 | *.vue.js 68 | *.vue.d.ts 69 | *.vue.js.map 70 | .nyc_output 71 | coverage 72 | /*.tpl 73 | webpack.config.js 74 | vue.config.js 75 | /jestconfig.json 76 | /tslint.json 77 | .git 78 | webpack.*.config.js 79 | webpack.*.config.d.ts 80 | webpack.*.config.js.map 81 | webpack.*.config.ts 82 | karma.conf.js 83 | /_config.yml 84 | intellij-style-guide.xml 85 | jest.config.js 86 | *.tsbuildinfo 87 | tsconfig.*.json 88 | tsconfig.esm.json.tpl 89 | /package.d.ts 90 | .mocharc.yml 91 | jest.config.js 92 | jest.config.* 93 | /jest-preset.* 94 | /report.*.json 95 | now.json 96 | /Makefile 97 | *.spec.d.ts 98 | *.spec.js 99 | *.spec.ts 100 | 101 | *.spec.d.cts 102 | *.spec.cjs 103 | *.spec.cts 104 | 105 | *.spec.d.mts 106 | *.spec.mjs 107 | *.spec.mts 108 | 109 | *.spec.d.tsx 110 | *.spec.tsx 111 | 112 | __mocks__ 113 | __tests__ 114 | __snapshots__ 115 | *.snap 116 | npm-shrinkwrap.json 117 | /example/ 118 | *.stat 119 | .vercel 120 | tsdx.config.js 121 | /report.json 122 | 123 | /_*/ 124 | _snowpack 125 | 126 | /snowpack.config.js 127 | web_modules 128 | cz-adapter 129 | 130 | tsc-multi.json.tpl 131 | tsc-multi.json 132 | 133 | changelog-option.js 134 | 135 | bin/tsconfig.json 136 | bin/tsconfig.*.json 137 | 138 | .yarnrc.yml 139 | .turbo 140 | __file_snapshots__ 141 | __fixtures__ 142 | /fixture/ 143 | -------------------------------------------------------------------------------- /packages/crlf-normalize/README.md: -------------------------------------------------------------------------------- 1 | # crlf-normalize 2 | 3 | > Detect and Normalize the newline characters 4 | 5 | `npm install crlf-normalize` 6 | 7 | ## demo 8 | 9 | ```ts 10 | import { crlf, chkcrlf, LF, CRLF, CR } from 'crlf-normalize'; 11 | 12 | let text = 'foo\r\nbar\nbaz\r'; 13 | 14 | console.log([ 15 | crlf(text, LF), 16 | crlf(text, CRLF), 17 | crlf(text, CR), 18 | ]); 19 | 20 | console.log(chkcrlf(text)); 21 | 22 | /* 23 | [ 'foo\nbar\nbaz\n', 'foo\r\nbar\r\nbaz\r\n', 'foo\rbar\rbaz\r' ] 24 | { lf: true, crlf: true, cr: true } 25 | */ 26 | ``` 27 | 28 | ### crlf_unicode_normalize(text: string, newline: string = LF) 29 | 30 | ```ts 31 | function crlf_unicode_normalize(text: string, newline: string = LF): string 32 | { 33 | const ln3 = newline + newline + newline; 34 | const ln2 = newline + newline; 35 | 36 | return text 37 | .replace(/\u000C/g, ln3) 38 | .replace(/\u2028/g, newline) 39 | .replace(/\u2029/g, ln2) 40 | ; 41 | } 42 | ``` 43 | -------------------------------------------------------------------------------- /packages/crlf-normalize/dist/index.cjs: -------------------------------------------------------------------------------- 1 | 2 | 'use strict' 3 | 4 | if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production') { 5 | module.exports = require('./index.cjs.development.cjs') 6 | } else { 7 | module.exports = require('./index.cjs.production.min.cjs') 8 | } 9 | -------------------------------------------------------------------------------- /packages/crlf-normalize/test/__root.ts: -------------------------------------------------------------------------------- 1 | import { join } from "path"; 2 | 3 | export const __root = join(__dirname, '..'); 4 | 5 | export const isWin = process.platform === "win32"; 6 | -------------------------------------------------------------------------------- /packages/crlf-normalize/test/__snapshots__/demo.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`CR 1`] = ` 4 | "foo 5 | bar 6 | baz 7 | " 8 | `; 9 | 10 | exports[`CRLF 1`] = ` 11 | "foo 12 | bar 13 | baz 14 | " 15 | `; 16 | 17 | exports[`LF 1`] = ` 18 | "foo 19 | bar 20 | baz 21 | " 22 | `; 23 | 24 | exports[`chkcrlf 1`] = ` 25 | { 26 | "cr": true, 27 | "crlf": true, 28 | "lf": true, 29 | } 30 | `; 31 | 32 | exports[`detectLineBreak 1`] = ` 33 | " 34 | " 35 | `; 36 | 37 | exports[`lineSplit 1`] = ` 38 | [ 39 | "foo", 40 | "bar", 41 | "baz", 42 | "", 43 | ] 44 | `; 45 | -------------------------------------------------------------------------------- /packages/crlf-normalize/test/demo.spec.ts: -------------------------------------------------------------------------------- 1 | import { crlf, LF, CRLF, CR, chkcrlf, detectLineBreak, lineSplit } from '../src/index'; 2 | 3 | const text = 'foo\r\nbar\nbaz\r'; 4 | 5 | test(`LF`, () => 6 | { 7 | let actual = crlf(text, LF); 8 | 9 | expect(actual).not.toMatch(/\r/) 10 | expect(actual).toMatchSnapshot(); 11 | }); 12 | 13 | test(`CRLF`, () => 14 | { 15 | let actual = crlf(text, CRLF); 16 | 17 | expect(actual.replace(/\r\n/g, '')).toStrictEqual(actual.replace(/\s/g, '')) 18 | expect(actual).toMatchSnapshot(); 19 | }); 20 | 21 | 22 | test(`CR`, () => 23 | { 24 | let actual = crlf(text, CR); 25 | 26 | expect(actual).not.toMatch(/\n/) 27 | expect(actual).toMatchSnapshot(); 28 | }); 29 | 30 | test(`chkcrlf`, () => 31 | { 32 | let actual = chkcrlf(text); 33 | 34 | expect(actual).toMatchSnapshot(); 35 | }); 36 | 37 | test(`detectLineBreak`, () => 38 | { 39 | let actual = detectLineBreak(text); 40 | 41 | expect(actual).toMatchSnapshot(); 42 | }); 43 | 44 | test(lineSplit.name, () => 45 | { 46 | let actual = lineSplit(text); 47 | 48 | expect(actual).toMatchSnapshot(); 49 | }); 50 | -------------------------------------------------------------------------------- /packages/crlf-normalize/test/demo.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2018/1/26/026. 3 | */ 4 | 5 | import { 6 | crlf, 7 | chkcrlf, 8 | LF, 9 | CRLF, 10 | CR, 11 | detectCurrentIndexLineBreak, 12 | detectCurrentIndexLineBreakFromBufferLike, 13 | } from '../src'; 14 | 15 | let text = 'foo\r\nbar\nbaz\r'; 16 | 17 | console.log([ 18 | crlf(text, LF), 19 | crlf(text, CRLF), 20 | crlf(text, CR), 21 | ]); 22 | 23 | console.log(chkcrlf(text)); 24 | 25 | /* 26 | [ 'foo\nbar\nbaz\n', 'foo\r\nbar\r\nbaz\r\n', 'foo\rbar\rbaz\r' ] 27 | { lf: true, crlf: true, cr: true } 28 | */ 29 | 30 | console.log(LF.charCodeAt(0), CR.charCodeAt(0)) 31 | 32 | console.dir(detectCurrentIndexLineBreak(text, 3)) 33 | 34 | console.dir(detectCurrentIndexLineBreakFromBufferLike(Buffer.from(text), 3)) 35 | -------------------------------------------------------------------------------- /packages/crlf-normalize/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "module": "NodeNext", 5 | "noEmit": true, 6 | "declaration": false, 7 | "noUnusedParameters": false, 8 | "allowUnusedLabels": true, 9 | "noUnusedLocals": false, 10 | "noPropertyAccessFromIndexSignature": false 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/crlf-normalize/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@bluelovers/tsconfig/tsdx/index.json", 3 | "compilerOptions": { 4 | "importHelpers": true, 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/normalize-num/.npmignore: -------------------------------------------------------------------------------- 1 | /.pnp 2 | .pnp.js 3 | .idea 4 | ~ci.list.txt 5 | ~ci.log.txt 6 | ~ci.errors.txt 7 | *.stackdump 8 | *.bak 9 | *.old 10 | *.log 11 | tsconfig.json 12 | package-lock.json 13 | test 14 | .github 15 | .gitkeep 16 | /.*/ 17 | /.* 18 | tests 19 | /~* 20 | __test__ 21 | __tests__ 22 | node_modules 23 | /node_modules/ 24 | **/node_modules/ 25 | *.ts 26 | !*.d.ts 27 | /bin/**/*.d.ts 28 | /bin/*.d.ts 29 | 30 | !*.d.mts 31 | /bin/**/*.d.mts 32 | /bin/*.d.mts 33 | 34 | !*.d.cts 35 | /bin/**/*.d.cts 36 | /bin/*.d.cts 37 | 38 | !/src/**/*.ts 39 | !/src/**/*.cts 40 | !/src/**/*.mts 41 | !/src/**/*.tsx 42 | 43 | /src/**/*.d.ts 44 | /src/**/*.js 45 | /src/**/*.d.cts 46 | /src/**/*.d.mts 47 | /src/**/*.cjs 48 | /src/**/*.mjs 49 | /src/**/*.jsx 50 | 51 | *.tgz 52 | /tsconfig.json.tpl 53 | yarn-error.log 54 | .git 55 | yarn.lock 56 | .env.local 57 | .env.*.local 58 | npm-debug.log* 59 | yarn-debug.log* 60 | yarn-error.log* 61 | .vscode 62 | *.suo 63 | *.ntvs* 64 | *.njsproj 65 | *.sln 66 | *.sw? 67 | *.vue.js 68 | *.vue.d.ts 69 | *.vue.js.map 70 | .nyc_output 71 | coverage 72 | /*.tpl 73 | webpack.config.js 74 | vue.config.js 75 | /jestconfig.json 76 | /tslint.json 77 | .git 78 | webpack.*.config.js 79 | webpack.*.config.d.ts 80 | webpack.*.config.js.map 81 | webpack.*.config.ts 82 | karma.conf.js 83 | /_config.yml 84 | intellij-style-guide.xml 85 | jest.config.js 86 | *.tsbuildinfo 87 | tsconfig.*.json 88 | tsconfig.esm.json.tpl 89 | /package.d.ts 90 | .mocharc.yml 91 | jest.config.js 92 | jest.config.* 93 | /jest-preset.* 94 | /report.*.json 95 | now.json 96 | /Makefile 97 | *.spec.d.ts 98 | *.spec.js 99 | *.spec.ts 100 | 101 | *.spec.d.cts 102 | *.spec.cjs 103 | *.spec.cts 104 | 105 | *.spec.d.mts 106 | *.spec.mjs 107 | *.spec.mts 108 | 109 | *.spec.d.tsx 110 | *.spec.tsx 111 | 112 | __mocks__ 113 | __tests__ 114 | __snapshots__ 115 | *.snap 116 | npm-shrinkwrap.json 117 | /example/ 118 | *.stat 119 | .vercel 120 | tsdx.config.js 121 | /report.json 122 | 123 | /_*/ 124 | _snowpack 125 | 126 | /snowpack.config.js 127 | web_modules 128 | cz-adapter 129 | 130 | tsc-multi.json.tpl 131 | tsc-multi.json 132 | 133 | changelog-option.js 134 | 135 | bin/tsconfig.json 136 | bin/tsconfig.*.json 137 | 138 | .yarnrc.yml 139 | .turbo 140 | __file_snapshots__ 141 | __fixtures__ 142 | /fixture/ 143 | -------------------------------------------------------------------------------- /packages/normalize-num/README.md: -------------------------------------------------------------------------------- 1 | # README.md 2 | 3 | <%= description %> 4 | 5 | ## install 6 | 7 | ```bash 8 | yarn add <%= name %> 9 | yarn-tool add <%= name %> 10 | yt add <%= name %> 11 | ``` 12 | 13 | -------------------------------------------------------------------------------- /packages/normalize-num/index.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2018/5/15/015. 3 | */ 4 | import { circle2num } from './lib/type/circle'; 5 | import { roman2num } from './lib/type/roman'; 6 | export { circle2num, roman2num }; 7 | export interface IOptions { 8 | circle?: boolean; 9 | roman?: boolean; 10 | all?: boolean; 11 | } 12 | export declare function str2num(s: string, options?: IOptions): string; 13 | export default str2num; 14 | -------------------------------------------------------------------------------- /packages/normalize-num/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * Created by user on 2018/5/15/015. 4 | */ 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | exports.str2num = exports.roman2num = exports.circle2num = void 0; 7 | const circle_1 = require("./lib/type/circle"); 8 | Object.defineProperty(exports, "circle2num", { enumerable: true, get: function () { return circle_1.circle2num; } }); 9 | const roman_1 = require("./lib/type/roman"); 10 | Object.defineProperty(exports, "roman2num", { enumerable: true, get: function () { return roman_1.roman2num; } }); 11 | function str2num(s, options = {}) { 12 | if (options.all && options.roman !== false || options.roman) { 13 | let m = (0, roman_1.isRoman)(s); 14 | if (m) { 15 | let n = (0, roman_1.roman2num)(m[1]); 16 | s = n.toString() + s.slice(m[1].length); 17 | } 18 | } 19 | if (options.all && options.circle !== false || options.circle) { 20 | s = (0, circle_1.circle2num)(s); 21 | } 22 | return s; 23 | } 24 | exports.str2num = str2num; 25 | exports.default = str2num; 26 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /packages/normalize-num/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2018/5/15/015. 3 | */ 4 | 5 | import * as StrUtil from 'str-util'; 6 | import { circle2num } from './lib/type/circle'; 7 | import { roman2num, isRoman } from './lib/type/roman'; 8 | 9 | export { circle2num, roman2num } 10 | 11 | export interface IOptions 12 | { 13 | circle?: boolean, 14 | roman?: boolean, 15 | all?: boolean, 16 | } 17 | 18 | export function str2num(s: string, options: IOptions = {}): string 19 | { 20 | if (options.all && options.roman !== false || options.roman) 21 | { 22 | let m = isRoman(s); 23 | 24 | if (m) 25 | { 26 | let n = roman2num(m[1]); 27 | s = n.toString() + s.slice(m[1].length); 28 | } 29 | } 30 | 31 | if (options.all && options.circle !== false || options.circle) 32 | { 33 | s = circle2num(s); 34 | } 35 | 36 | return s; 37 | } 38 | 39 | export default str2num; 40 | -------------------------------------------------------------------------------- /packages/normalize-num/lib/type/circle.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2018/5/15/015. 3 | */ 4 | /** 5 | * @see http://xahlee.info/comp/unicode_circled_numbers.html 6 | * 7 | * @param str 8 | * @returns {string} 9 | * 10 | * @todo add more 11 | */ 12 | export declare function circle2num(str: any): string; 13 | export default circle2num; 14 | -------------------------------------------------------------------------------- /packages/normalize-num/lib/type/circle.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * Created by user on 2018/5/15/015. 4 | */ 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | exports.circle2num = void 0; 7 | /** 8 | * @see http://xahlee.info/comp/unicode_circled_numbers.html 9 | * 10 | * @param str 11 | * @returns {string} 12 | * 13 | * @todo add more 14 | */ 15 | function circle2num(str) { 16 | str = str 17 | .replace(new RegExp(String.fromCharCode(9450), 'g'), '0'); 18 | for (let n = 1; n <= 20; n++) { 19 | str = str 20 | .replace(new RegExp(String.fromCharCode(9312 + n - 1), 'g'), n); 21 | } 22 | for (let n = 21; n <= 35; n++) { 23 | str = str 24 | .replace(new RegExp(String.fromCharCode(12881 + n - 21), 'g'), n); 25 | } 26 | for (let n = 36; n <= 50; n++) { 27 | str = str 28 | .replace(new RegExp(String.fromCharCode(12977 + n - 36), 'g'), n); 29 | } 30 | //------------- 31 | for (let n = 1; n <= 10; n++) { 32 | str = str 33 | .replace(new RegExp(String.fromCharCode(0x24ea + n - 1), 'g'), n + 10); 34 | } 35 | //------------- 36 | str = str 37 | .replace(new RegExp(String.fromCharCode(0x24ff), 'g'), '0'); 38 | for (let n = 1; n <= 10; n++) { 39 | str = str 40 | .replace(new RegExp(String.fromCharCode(0x2776 + n - 1), 'g'), n); 41 | } 42 | //------------- 43 | for (let n = 1; n <= 10; n++) { 44 | str = str 45 | .replace(new RegExp(String.fromCharCode(0x278a + n - 1), 'g'), n); 46 | } 47 | for (let n = 11; n <= 20; n++) { 48 | str = str 49 | .replace(new RegExp(String.fromCharCode(0x24eb + n - 1), 'g'), n); 50 | } 51 | //------------- 52 | for (let n = 1; n <= 10; n++) { 53 | str = str 54 | .replace(new RegExp(String.fromCharCode(0x24f5 + n - 1), 'g'), n); 55 | } 56 | return str; 57 | } 58 | exports.circle2num = circle2num; 59 | exports.default = circle2num; 60 | //# sourceMappingURL=circle.js.map -------------------------------------------------------------------------------- /packages/normalize-num/lib/type/circle.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2018/5/15/015. 3 | */ 4 | 5 | /** 6 | * @see http://xahlee.info/comp/unicode_circled_numbers.html 7 | * 8 | * @param str 9 | * @returns {string} 10 | * 11 | * @todo add more 12 | */ 13 | export function circle2num(str): string 14 | { 15 | str = str 16 | .replace(new RegExp(String.fromCharCode(9450), 'g'), '0') 17 | ; 18 | 19 | for (let n = 1; n<= 20; n++) 20 | { 21 | str = str 22 | .replace(new RegExp(String.fromCharCode(9312 + n - 1), 'g'), n) 23 | ; 24 | } 25 | 26 | for (let n = 21; n<= 35; n++) 27 | { 28 | str = str 29 | .replace(new RegExp(String.fromCharCode(12881 + n - 21), 'g'), n) 30 | ; 31 | } 32 | 33 | for (let n = 36; n<= 50; n++) 34 | { 35 | str = str 36 | .replace(new RegExp(String.fromCharCode(12977 + n - 36), 'g'), n) 37 | ; 38 | } 39 | 40 | //------------- 41 | 42 | for (let n = 1; n<= 10; n++) 43 | { 44 | str = str 45 | .replace(new RegExp(String.fromCharCode(0x24ea + n - 1), 'g'), n + 10) 46 | ; 47 | } 48 | 49 | //------------- 50 | 51 | str = str 52 | .replace(new RegExp(String.fromCharCode(0x24ff), 'g'), '0') 53 | ; 54 | 55 | for (let n = 1; n<= 10; n++) 56 | { 57 | str = str 58 | .replace(new RegExp(String.fromCharCode(0x2776 + n - 1), 'g'), n) 59 | ; 60 | } 61 | 62 | //------------- 63 | 64 | for (let n = 1; n<= 10; n++) 65 | { 66 | str = str 67 | .replace(new RegExp(String.fromCharCode(0x278a + n - 1), 'g'), n) 68 | ; 69 | } 70 | 71 | for (let n = 11; n<= 20; n++) 72 | { 73 | str = str 74 | .replace(new RegExp(String.fromCharCode(0x24eb + n - 1), 'g'), n) 75 | ; 76 | } 77 | 78 | //------------- 79 | 80 | for (let n = 1; n<= 10; n++) 81 | { 82 | str = str 83 | .replace(new RegExp(String.fromCharCode(0x24f5 + n - 1), 'g'), n) 84 | ; 85 | } 86 | 87 | return str; 88 | } 89 | 90 | export default circle2num 91 | -------------------------------------------------------------------------------- /packages/normalize-num/lib/type/roman.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2018/5/15/015. 3 | */ 4 | import deromanize from 'deromanize'; 5 | import { isRoman } from 'num-is-roman'; 6 | export { isRoman }; 7 | export { deromanize }; 8 | export declare function normalizeRoman(input: string, bool?: boolean): string; 9 | export declare function roman2num(s: string): string; 10 | export default roman2num; 11 | -------------------------------------------------------------------------------- /packages/normalize-num/lib/type/roman.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * Created by user on 2018/5/15/015. 4 | */ 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | exports.roman2num = exports.normalizeRoman = exports.deromanize = exports.isRoman = void 0; 7 | const tslib_1 = require("tslib"); 8 | const deromanize_1 = tslib_1.__importDefault(require("deromanize")); 9 | exports.deromanize = deromanize_1.default; 10 | const num_is_roman_1 = require("num-is-roman"); 11 | Object.defineProperty(exports, "isRoman", { enumerable: true, get: function () { return num_is_roman_1.isRoman; } }); 12 | function normalizeRoman(input, bool) { 13 | let ro = ['I', 'II', 'III', 'IV', 'V', 'VI', 'VII', 'VIII', 'IX', 'X', 'XI', 'XII',]; 14 | for (let i = 0; i < 12; i++) { 15 | let r = new RegExp(String.fromCharCode(0x2160 + i) + '|' + String.fromCharCode(0x2160 + 16 + i), 'g'); 16 | input = input.replace(r, bool ? String.fromCharCode(0x2160 + i) : ro[i]); 17 | } 18 | return input; 19 | } 20 | exports.normalizeRoman = normalizeRoman; 21 | function roman2num(s) { 22 | return (0, deromanize_1.default)(normalizeRoman(s)).toString(); 23 | } 24 | exports.roman2num = roman2num; 25 | exports.default = roman2num; 26 | //# sourceMappingURL=roman.js.map -------------------------------------------------------------------------------- /packages/normalize-num/lib/type/roman.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2018/5/15/015. 3 | */ 4 | 5 | import deromanize from 'deromanize'; 6 | import { isRoman } from 'num-is-roman'; 7 | 8 | export { isRoman } 9 | export { deromanize } 10 | 11 | export function normalizeRoman(input: string, bool?: boolean) 12 | { 13 | let ro = ['I','II','III','IV','V','VI','VII','VIII','IX','X','XI','XII',]; 14 | 15 | for (let i = 0; i < 12; i++) 16 | { 17 | let r = new RegExp(String.fromCharCode(0x2160 + i) + '|' + String.fromCharCode(0x2160 + 16 + i), 'g'); 18 | input = input.replace(r, bool ? String.fromCharCode(0x2160 + i) : ro[i]); 19 | } 20 | 21 | return input; 22 | } 23 | 24 | export function roman2num(s: string): string 25 | { 26 | return deromanize(normalizeRoman(s)).toString(); 27 | } 28 | 29 | export default roman2num 30 | -------------------------------------------------------------------------------- /packages/normalize-num/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "normalize-num", 3 | "version": "1.0.16", 4 | "description": "", 5 | "keywords": [], 6 | "homepage": "https://github.com/bluelovers/ws-string/tree/master/packages/normalize-num#readme", 7 | "bugs": { 8 | "url": "https://github.com/bluelovers/ws-string/issues" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/bluelovers/ws-string.git", 13 | "directory": "packages/normalize-num" 14 | }, 15 | "license": "ISC", 16 | "author": "bluelovers", 17 | "main": "index.js", 18 | "directories": { 19 | "lib": "lib" 20 | }, 21 | "scripts": { 22 | "coverage": "yarn run test -- --coverage", 23 | "test": "echo \"Error: no test specified\"", 24 | "test:jest": "jest --passWithNoTests", 25 | "test:jest:coverage": "yarn run test:jest -- --coverage", 26 | "test:jest:snapshot": "yarn run test:jest -- -u", 27 | "test:snapshot": "yarn run test -- -u", 28 | "test:tsd": "ynpx tsd", 29 | "preversion": "yarn run test", 30 | "prepublishOnly:check-bin": "ynpx --quiet @yarn-tool/check-pkg-bin", 31 | "prepublishOnly:update": "yarn run ncu && yarn run sort-package-json", 32 | "ncu": "ynpx --quiet yarn-tool -- ncu -u", 33 | "sort-package-json": "ynpx --quiet yarn-tool -- sort", 34 | "tsc:showConfig": "ynpx get-current-tsconfig -p" 35 | }, 36 | "dependencies": { 37 | "deromanize": "^1.0.0", 38 | "num-is-roman": "^1.1.9", 39 | "tslib": "^2" 40 | }, 41 | "publishConfig": { 42 | "access": "public" 43 | }, 44 | "gitHead": "952f3f53bed3e2bf3ccaec50c46702f127ff4e7f" 45 | } 46 | -------------------------------------------------------------------------------- /packages/num-is-roman/README.md: -------------------------------------------------------------------------------- 1 | # README.md 2 | 3 | <%= description %> 4 | 5 | ## install 6 | 7 | ```bash 8 | yarn add <%= name %> 9 | yarn-tool add <%= name %> 10 | yt add <%= name %> 11 | ``` 12 | 13 | -------------------------------------------------------------------------------- /packages/num-is-roman/dist/index.cjs: -------------------------------------------------------------------------------- 1 | 2 | 'use strict' 3 | 4 | if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production') { 5 | module.exports = require('./index.cjs.development.cjs') 6 | } else { 7 | module.exports = require('./index.cjs.production.min.cjs') 8 | } 9 | -------------------------------------------------------------------------------- /packages/num-is-roman/dist/index.cjs.development.cjs: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Object.defineProperty(exports, '__esModule', { value: true }); 4 | 5 | function isRoman(str) { 6 | return /^([LCDMIVX\u2160-\u217f]+)(?![a-z\d])/ui.exec(str); 7 | } 8 | 9 | exports.default = isRoman; 10 | exports.isRoman = isRoman; 11 | //# sourceMappingURL=index.cjs.development.cjs.map 12 | -------------------------------------------------------------------------------- /packages/num-is-roman/dist/index.cjs.production.min.cjs: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | function isRoman(e) { 4 | return /^([LCDMIVX\u2160-\u217f]+)(?![a-z\d])/iu.exec(e); 5 | } 6 | 7 | Object.defineProperty(exports, "__esModule", { 8 | value: !0 9 | }), exports.default = isRoman, exports.isRoman = isRoman; 10 | //# sourceMappingURL=index.cjs.production.min.cjs.map 11 | -------------------------------------------------------------------------------- /packages/num-is-roman/dist/index.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2018/5/15/015. 3 | */ 4 | export declare function isRoman(str: string): RegExpExecArray; 5 | 6 | export { 7 | isRoman as default, 8 | }; 9 | 10 | export {}; 11 | -------------------------------------------------------------------------------- /packages/num-is-roman/dist/index.esm.mjs: -------------------------------------------------------------------------------- 1 | function isRoman(a) { 2 | return /^([LCDMIVX\u2160-\u217f]+)(?![a-z\d])/iu.exec(a); 3 | } 4 | 5 | export { isRoman as default, isRoman }; 6 | //# sourceMappingURL=index.esm.mjs.map 7 | -------------------------------------------------------------------------------- /packages/num-is-roman/src/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2018/5/15/015. 3 | */ 4 | 5 | export function isRoman(str: string) 6 | { 7 | return /^([LCDMIVX\u2160-\u217f]+)(?![a-z\d])/ui.exec(str); 8 | } 9 | 10 | export default isRoman 11 | -------------------------------------------------------------------------------- /packages/num-is-roman/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@bluelovers/tsconfig/tsdx/index.json", 3 | "compilerOptions": { 4 | "importHelpers": true, 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/reserved/.npmignore: -------------------------------------------------------------------------------- 1 | /.pnp 2 | .pnp.js 3 | .idea 4 | ~ci.list.txt 5 | ~ci.log.txt 6 | ~ci.errors.txt 7 | *.stackdump 8 | *.bak 9 | *.old 10 | *.log 11 | tsconfig.json 12 | package-lock.json 13 | test 14 | .github 15 | .gitkeep 16 | /.*/ 17 | /.* 18 | tests 19 | /~* 20 | __test__ 21 | __tests__ 22 | node_modules 23 | /node_modules/ 24 | **/node_modules/ 25 | *.ts 26 | !*.d.ts 27 | /bin/**/*.d.ts 28 | /bin/*.d.ts 29 | 30 | !*.d.mts 31 | /bin/**/*.d.mts 32 | /bin/*.d.mts 33 | 34 | !*.d.cts 35 | /bin/**/*.d.cts 36 | /bin/*.d.cts 37 | 38 | !/src/**/*.ts 39 | !/src/**/*.cts 40 | !/src/**/*.mts 41 | !/src/**/*.tsx 42 | 43 | /src/**/*.d.ts 44 | /src/**/*.js 45 | /src/**/*.d.cts 46 | /src/**/*.d.mts 47 | /src/**/*.cjs 48 | /src/**/*.mjs 49 | /src/**/*.jsx 50 | 51 | *.tgz 52 | /tsconfig.json.tpl 53 | yarn-error.log 54 | .git 55 | yarn.lock 56 | .env.local 57 | .env.*.local 58 | npm-debug.log* 59 | yarn-debug.log* 60 | yarn-error.log* 61 | .vscode 62 | *.suo 63 | *.ntvs* 64 | *.njsproj 65 | *.sln 66 | *.sw? 67 | *.vue.js 68 | *.vue.d.ts 69 | *.vue.js.map 70 | .nyc_output 71 | coverage 72 | /*.tpl 73 | webpack.config.js 74 | vue.config.js 75 | /jestconfig.json 76 | /tslint.json 77 | .git 78 | webpack.*.config.js 79 | webpack.*.config.d.ts 80 | webpack.*.config.js.map 81 | webpack.*.config.ts 82 | karma.conf.js 83 | /_config.yml 84 | intellij-style-guide.xml 85 | jest.config.js 86 | *.tsbuildinfo 87 | tsconfig.*.json 88 | tsconfig.esm.json.tpl 89 | /package.d.ts 90 | .mocharc.yml 91 | jest.config.js 92 | jest.config.* 93 | /jest-preset.* 94 | /report.*.json 95 | now.json 96 | /Makefile 97 | *.spec.d.ts 98 | *.spec.js 99 | *.spec.ts 100 | 101 | *.spec.d.cts 102 | *.spec.cjs 103 | *.spec.cts 104 | 105 | *.spec.d.mts 106 | *.spec.mjs 107 | *.spec.mts 108 | 109 | *.spec.d.tsx 110 | *.spec.tsx 111 | 112 | __mocks__ 113 | __tests__ 114 | __snapshots__ 115 | *.snap 116 | npm-shrinkwrap.json 117 | /example/ 118 | *.stat 119 | .vercel 120 | tsdx.config.js 121 | /report.json 122 | 123 | /_*/ 124 | _snowpack 125 | 126 | /snowpack.config.js 127 | web_modules 128 | cz-adapter 129 | 130 | tsc-multi.json.tpl 131 | tsc-multi.json 132 | 133 | changelog-option.js 134 | 135 | bin/tsconfig.json 136 | bin/tsconfig.*.json 137 | 138 | .yarnrc.yml 139 | .turbo 140 | __file_snapshots__ 141 | __fixtures__ 142 | /fixture/ 143 | -------------------------------------------------------------------------------- /packages/reserved/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [0.1.6](https://github.com/bluelovers/ws-string/compare/reserved2@0.1.5...reserved2@0.1.6) (2024-01-29) 7 | 8 | 9 | 10 | ### 🔖 Miscellaneous 11 | 12 | * . ([f5d4f83](https://github.com/bluelovers/ws-string/commit/f5d4f8356dfba2fa3954afab13556dbe9b53d53a)) 13 | 14 | 15 | 16 | ## [0.1.5](https://github.com/bluelovers/ws-string/compare/reserved2@0.1.4...reserved2@0.1.5) (2023-04-12) 17 | 18 | 19 | 20 | ### 🔖 Miscellaneous 21 | 22 | * . ([0d0b919](https://github.com/bluelovers/ws-string/commit/0d0b9196399b184f6431a3718bae6bfaf41164fd)) 23 | 24 | 25 | 26 | ## [0.1.4](https://github.com/bluelovers/ws-string/compare/reserved2@0.1.3...reserved2@0.1.4) (2022-11-01) 27 | 28 | 29 | 30 | ### 🔖 Miscellaneous 31 | 32 | * . ([c16d3cd](https://github.com/bluelovers/ws-string/commit/c16d3cd54f8a49287f41805546dca27f709f009d)) 33 | 34 | 35 | 36 | ## 0.1.3 (2022-10-27) 37 | 38 | 39 | 40 | ### 🔖 Miscellaneous 41 | 42 | * safe-variable-name ([7c02f7f](https://github.com/bluelovers/ws-string/commit/7c02f7f9a68e98189bea2eab254c0fb9cac4b3e2)) 43 | * . ([97e252c](https://github.com/bluelovers/ws-string/commit/97e252c0fed1fadc78670bcdc595da6e7d46f8af)) 44 | -------------------------------------------------------------------------------- /packages/reserved/LICENSE-MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 , contributors. 2 | 3 | Permission is hereby granted, free of charge, to any person 4 | obtaining a copy of this software and associated documentation 5 | files (the "Software"), to deal in the Software without 6 | restriction, including without limitation the rights to use, 7 | copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the 9 | Software is furnished to do so, subject to the following 10 | conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 17 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 18 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 19 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 20 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /packages/reserved/README.md: -------------------------------------------------------------------------------- 1 | # reserved [![NPM version](https://badge.fury.io/js/reserved.png)](http://badge.fury.io/js/reserved) 2 | 3 | > Reserved words that may not be used as variables, functions, methods, or object identifiers, since ECMAScript specifies special behavior for them. 4 | 5 | Used in [variable](https://github.com/jonschlinkert/variable) 6 | 7 | ## Install 8 | Install with [npm](npmjs.org): 9 | 10 | ```bash 11 | npm i reserved --save-dev 12 | ``` 13 | 14 | 15 | ## Usage 16 | 17 | ```js 18 | var reserved = require('reserved'); 19 | console.log(reserved); 20 | //=> 'abstract', 'arguments', 'boolean', 'break', 'byte', 'case'... 21 | ``` 22 | 23 | ## Author 24 | 25 | **Jon Schlinkert** 26 | 27 | + [github/jonschlinkert](https://github.com/jonschlinkert) 28 | + [twitter/jonschlinkert](http://twitter.com/jonschlinkert) 29 | 30 | ## License 31 | Copyright (c) 2014 Jon Schlinkert, contributors. 32 | Released under the MIT license 33 | 34 | *** 35 | 36 | _This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on May 11, 2014._ -------------------------------------------------------------------------------- /packages/reserved/dist/index.cjs: -------------------------------------------------------------------------------- 1 | 2 | 'use strict' 3 | 4 | if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production') { 5 | module.exports = require('./index.cjs.development.cjs') 6 | } else { 7 | module.exports = require('./index.cjs.production.min.cjs') 8 | } 9 | -------------------------------------------------------------------------------- /packages/reserved/dist/index.cjs.development.cjs: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Object.defineProperty(exports, '__esModule', { value: true }); 4 | 5 | const reserved = /*#__PURE__*/Object.freeze(['abstract', 'arguments', 'boolean', 'break', 'byte', 'case', 'catch', 'char', 'class', 'const', 'continue', 'debugger', 'default', 'delete', 'do', 'double', 'else', 'enum', 'eval', 'export', 'extends', 'false', 'final', 'finally', 'float', 'for', 'function', 'goto', 'if', 'implements', 'import', 'in', 'instanceof', 'int', 'interface', 'let', 'long', 'native', 'new', 'null', 'package', 'private', 'protected', 'public', 'return', 'short', 'static', 'super', 'switch', 'synchronized', 'this', 'throw', 'throws', 'transient', 'true', 'try', 'typeof', 'var', 'void', 'volatile', 'while', 'with', 'yield']); 6 | /** 7 | * @see https://github.com/jonschlinkert/reserved 8 | */ 9 | const builtins = /*#__PURE__*/Object.freeze(['Array', 'Date', 'eval', 'function', 'hasOwnProperty', 'Infinity', 'isFinite', 'isNaN', 'isPrototypeOf', 'length', 'Math', 'name', 'NaN', 'Number', 'Object', 'prototype', 'String', 'toString', 'undefined', 'valueOf']); 10 | const mixinReservedBuiltins = /*#__PURE__*/Object.freeze([...reserved, ...builtins]); 11 | const mixinReservedBuiltinsLC = /*#__PURE__*/Object.freeze( /*#__PURE__*/mixinReservedBuiltins.map(s => s.toLowerCase())); 12 | function containReservedOrBuiltins(input) { 13 | return mixinReservedBuiltins.indexOf(input) !== -1; 14 | } 15 | function isReservedOrBuiltins(input) { 16 | return mixinReservedBuiltins.includes(input); 17 | } 18 | function isReservedOrBuiltinsLC(input) { 19 | return mixinReservedBuiltinsLC.includes(input); 20 | } 21 | 22 | exports.builtins = builtins; 23 | exports.containReservedOrBuiltins = containReservedOrBuiltins; 24 | exports.default = mixinReservedBuiltins; 25 | exports.isReservedOrBuiltins = isReservedOrBuiltins; 26 | exports.isReservedOrBuiltinsLC = isReservedOrBuiltinsLC; 27 | exports.mixinReservedBuiltins = mixinReservedBuiltins; 28 | exports.mixinReservedBuiltinsLC = mixinReservedBuiltinsLC; 29 | exports.reserved = reserved; 30 | //# sourceMappingURL=index.cjs.development.cjs.map 31 | -------------------------------------------------------------------------------- /packages/reserved/dist/index.cjs.production.min.cjs: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: !0 5 | }); 6 | 7 | const e = Object.freeze([ "abstract", "arguments", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "debugger", "default", "delete", "do", "double", "else", "enum", "eval", "export", "extends", "false", "final", "finally", "float", "for", "function", "goto", "if", "implements", "import", "in", "instanceof", "int", "interface", "let", "long", "native", "new", "null", "package", "private", "protected", "public", "return", "short", "static", "super", "switch", "synchronized", "this", "throw", "throws", "transient", "true", "try", "typeof", "var", "void", "volatile", "while", "with", "yield" ]), t = Object.freeze([ "Array", "Date", "eval", "function", "hasOwnProperty", "Infinity", "isFinite", "isNaN", "isPrototypeOf", "length", "Math", "name", "NaN", "Number", "Object", "prototype", "String", "toString", "undefined", "valueOf" ]), i = Object.freeze([ ...e, ...t ]), r = Object.freeze(i.map((e => e.toLowerCase()))); 8 | 9 | exports.builtins = t, exports.containReservedOrBuiltins = function containReservedOrBuiltins(e) { 10 | return -1 !== i.indexOf(e); 11 | }, exports.default = i, exports.isReservedOrBuiltins = function isReservedOrBuiltins(e) { 12 | return i.includes(e); 13 | }, exports.isReservedOrBuiltinsLC = function isReservedOrBuiltinsLC(e) { 14 | return r.includes(e); 15 | }, exports.mixinReservedBuiltins = i, exports.mixinReservedBuiltinsLC = r, exports.reserved = e; 16 | //# sourceMappingURL=index.cjs.production.min.cjs.map 17 | -------------------------------------------------------------------------------- /packages/reserved/dist/index.esm.mjs: -------------------------------------------------------------------------------- 1 | const e = Object.freeze([ "abstract", "arguments", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", "debugger", "default", "delete", "do", "double", "else", "enum", "eval", "export", "extends", "false", "final", "finally", "float", "for", "function", "goto", "if", "implements", "import", "in", "instanceof", "int", "interface", "let", "long", "native", "new", "null", "package", "private", "protected", "public", "return", "short", "static", "super", "switch", "synchronized", "this", "throw", "throws", "transient", "true", "try", "typeof", "var", "void", "volatile", "while", "with", "yield" ]), t = Object.freeze([ "Array", "Date", "eval", "function", "hasOwnProperty", "Infinity", "isFinite", "isNaN", "isPrototypeOf", "length", "Math", "name", "NaN", "Number", "Object", "prototype", "String", "toString", "undefined", "valueOf" ]), n = Object.freeze([ ...e, ...t ]), i = Object.freeze(n.map((e => e.toLowerCase()))); 2 | 3 | function containReservedOrBuiltins(e) { 4 | return -1 !== n.indexOf(e); 5 | } 6 | 7 | function isReservedOrBuiltins(e) { 8 | return n.includes(e); 9 | } 10 | 11 | function isReservedOrBuiltinsLC(e) { 12 | return i.includes(e); 13 | } 14 | 15 | export { t as builtins, containReservedOrBuiltins, n as default, isReservedOrBuiltins, isReservedOrBuiltinsLC, n as mixinReservedBuiltins, i as mixinReservedBuiltinsLC, e as reserved }; 16 | //# sourceMappingURL=index.esm.mjs.map 17 | -------------------------------------------------------------------------------- /packages/reserved/test/__root.ts: -------------------------------------------------------------------------------- 1 | import { join } from "path"; 2 | 3 | export const __ROOT = join(__dirname, '..'); 4 | 5 | export const isWin = process.platform === "win32"; 6 | -------------------------------------------------------------------------------- /packages/reserved/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "module": "NodeNext", 5 | "noEmit": true, 6 | "declaration": false, 7 | "noUnusedParameters": false, 8 | "allowUnusedLabels": true, 9 | "noUnusedLocals": false, 10 | "noPropertyAccessFromIndexSignature": false 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/reserved/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@bluelovers/tsconfig/tsdx/index.json", 3 | "compilerOptions": { 4 | "importHelpers": true, 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/runes2/.npmignore: -------------------------------------------------------------------------------- 1 | /.pnp 2 | .pnp.js 3 | .idea 4 | ~ci.list.txt 5 | ~ci.log.txt 6 | ~ci.errors.txt 7 | *.stackdump 8 | *.bak 9 | *.old 10 | *.log 11 | tsconfig.json 12 | package-lock.json 13 | test 14 | .github 15 | .gitkeep 16 | /.*/ 17 | /.* 18 | tests 19 | /~* 20 | __test__ 21 | __tests__ 22 | node_modules 23 | /node_modules/ 24 | **/node_modules/ 25 | *.ts 26 | !*.d.ts 27 | /bin/**/*.d.ts 28 | /bin/*.d.ts 29 | 30 | !*.d.mts 31 | /bin/**/*.d.mts 32 | /bin/*.d.mts 33 | 34 | !*.d.cts 35 | /bin/**/*.d.cts 36 | /bin/*.d.cts 37 | 38 | !/src/**/*.ts 39 | !/src/**/*.cts 40 | !/src/**/*.mts 41 | !/src/**/*.tsx 42 | 43 | /src/**/*.d.ts 44 | /src/**/*.js 45 | /src/**/*.d.cts 46 | /src/**/*.d.mts 47 | /src/**/*.cjs 48 | /src/**/*.mjs 49 | /src/**/*.jsx 50 | 51 | *.tgz 52 | /tsconfig.json.tpl 53 | yarn-error.log 54 | .git 55 | yarn.lock 56 | .env.local 57 | .env.*.local 58 | npm-debug.log* 59 | yarn-debug.log* 60 | yarn-error.log* 61 | .vscode 62 | *.suo 63 | *.ntvs* 64 | *.njsproj 65 | *.sln 66 | *.sw? 67 | *.vue.js 68 | *.vue.d.ts 69 | *.vue.js.map 70 | .nyc_output 71 | coverage 72 | /*.tpl 73 | webpack.config.js 74 | vue.config.js 75 | /jestconfig.json 76 | /tslint.json 77 | .git 78 | webpack.*.config.js 79 | webpack.*.config.d.ts 80 | webpack.*.config.js.map 81 | webpack.*.config.ts 82 | karma.conf.js 83 | /_config.yml 84 | intellij-style-guide.xml 85 | jest.config.js 86 | *.tsbuildinfo 87 | tsconfig.*.json 88 | tsconfig.esm.json.tpl 89 | /package.d.ts 90 | .mocharc.yml 91 | jest.config.js 92 | jest.config.* 93 | /jest-preset.* 94 | /report.*.json 95 | now.json 96 | /Makefile 97 | *.spec.d.ts 98 | *.spec.js 99 | *.spec.ts 100 | 101 | *.spec.d.cts 102 | *.spec.cjs 103 | *.spec.cts 104 | 105 | *.spec.d.mts 106 | *.spec.mjs 107 | *.spec.mts 108 | 109 | *.spec.d.tsx 110 | *.spec.tsx 111 | 112 | __mocks__ 113 | __tests__ 114 | __snapshots__ 115 | *.snap 116 | npm-shrinkwrap.json 117 | /example/ 118 | *.stat 119 | .vercel 120 | tsdx.config.js 121 | /report.json 122 | 123 | /_*/ 124 | _snowpack 125 | 126 | /snowpack.config.js 127 | web_modules 128 | cz-adapter 129 | 130 | tsc-multi.json.tpl 131 | tsc-multi.json 132 | 133 | changelog-option.js 134 | 135 | bin/tsconfig.json 136 | bin/tsconfig.*.json 137 | 138 | .yarnrc.yml 139 | .turbo 140 | __file_snapshots__ 141 | __fixtures__ 142 | /fixture/ 143 | -------------------------------------------------------------------------------- /packages/runes2/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Justin Sippel, Vitaly Domnikov 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/runes2/dist/index.cjs: -------------------------------------------------------------------------------- 1 | 2 | 'use strict' 3 | 4 | if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production') { 5 | module.exports = require('./index.cjs.development.cjs') 6 | } else { 7 | module.exports = require('./index.cjs.production.min.cjs') 8 | } 9 | -------------------------------------------------------------------------------- /packages/runes2/dist/index.d.ts: -------------------------------------------------------------------------------- 1 | export declare const enum EnumRunesCode { 2 | HIGH_SURROGATE_START = 55296, 3 | HIGH_SURROGATE_END = 56319, 4 | LOW_SURROGATE_START = 56320, 5 | REGIONAL_INDICATOR_START = 127462, 6 | REGIONAL_INDICATOR_END = 127487, 7 | FITZPATRICK_MODIFIER_START = 127995, 8 | FITZPATRICK_MODIFIER_END = 127999, 9 | VARIATION_MODIFIER_START = 65024, 10 | VARIATION_MODIFIER_END = 65039, 11 | DIACRITICAL_MARKS_START = 8400, 12 | DIACRITICAL_MARKS_END = 8447, 13 | SUBDIVISION_INDICATOR_START = 127988, 14 | TAGS_START = 917504, 15 | TAGS_END = 917631, 16 | ZWJ = 8205 17 | } 18 | export declare const GRAPHEMES: readonly number[]; 19 | export declare const enum EnumCodeUnits { 20 | unit_1 = 1, 21 | unit_2 = 2, 22 | unit_4 = 4 23 | } 24 | export declare function runes(string: string): string[]; 25 | export declare function nextUnits(i: number, string: string): number; 26 | export declare function isFirstOfSurrogatePair(string: string): boolean; 27 | export declare function isRegionalIndicator(string: string): boolean; 28 | export declare function isSubdivisionFlag(string: string): boolean; 29 | export declare function isFitzpatrickModifier(string: string): boolean; 30 | export declare function isVariationSelector(string: string): boolean; 31 | export declare function isDiacriticalMark(string: string): boolean; 32 | export declare function isSupplementarySpecialpurposePlane(string: string): boolean; 33 | export declare function isGrapheme(string: string): boolean; 34 | export declare function isZeroWidthJoiner(string: string): boolean; 35 | export declare function codePointFromSurrogatePair(pair: string): number; 36 | export declare function betweenInclusive(value: number, lower: number, upper: number): boolean; 37 | export declare function substring(string: string, start?: number, width?: number): string; 38 | 39 | export { 40 | runes as default, 41 | substring as substr, 42 | }; 43 | 44 | export {}; 45 | -------------------------------------------------------------------------------- /packages/runes2/readme.md: -------------------------------------------------------------------------------- 1 | # ✂️ Runes 2 | 3 | > Unicode-aware JS string splitting with full Emoji support. 4 | 5 | Split a string into its constituent characters, without munging emoji and other non-BMP code points. 6 | 7 | **this is typescript version fork form [`runes`](https://www.npmjs.com/package/runes)** 8 | 9 | ## Why? 10 | 11 | The native `String#split` implementation does not pay attention to [surrogate pairs](http://en.wikipedia.org/wiki/UTF-16). When the code units of a surrogate pair are split apart, they are not intelligible on their own. Unless they are put back together in the correct order, individual code units will cause problems in code that handles strings. 12 | 13 | ## Installation 14 | 15 | ```js 16 | $ npm install runes2 17 | ``` 18 | 19 | ## Example 20 | 21 | ```ts 22 | const runes = require('runes2').default 23 | const runes = require('runes2').runes 24 | import runes from 'runes2'; 25 | import { runes } from 'runes2'; 26 | ``` 27 | 28 | ```js 29 | // Standard String.split 30 | '♥️'.split('') // => ['♥', '️'] 31 | 'Emoji 🤖'.split('') // => ['E', 'm', 'o', 'j', 'i', ' ', '�', '�'] 32 | '👩‍👩‍👧‍👦'.split('') // => ['�', '�', '‍', '�', '�', '‍', '�', '�', '‍', '�', '�'] 33 | 34 | // ES6 string iterator 35 | [ 36 | ... 37 | '♥️' 38 | ] => 39 | ['♥', '️'] 40 | [ 41 | ... 42 | 'Emoji 🤖' 43 | ] // => [ 'E', 'm', 'o', 'j', 'i', ' ', '🤖' ] 44 | [...'👩‍👩‍👧‍👦'] // => [ '👩', '', '👩', '', '👧', '', '👦' ] 45 | 46 | // Runes 47 | runes('♥️') // => ['♥️'] 48 | runes('Emoji 🤖') // => ['E', 'm', 'o', 'j', 'i', ' ', '🤖'] 49 | runes('👩‍👩‍👧‍👦') // => ['👩‍👩‍👧‍👦'] 50 | 51 | ``` 52 | 53 | ## Substring example 54 | 55 | ```js 56 | // String.substring 57 | '👨‍👨‍👧‍👧a'.substring(1) // => '�‍👨‍👧‍👧a' 58 | 59 | // Runes 60 | runes.substr('👨‍👨‍👧‍👧a', 1) // => 'a' 61 | ``` 62 | -------------------------------------------------------------------------------- /packages/runes2/src/index.cts: -------------------------------------------------------------------------------- 1 | import { default as _ } from './index'; 2 | 3 | // @ts-ignore 4 | export = _ 5 | -------------------------------------------------------------------------------- /packages/runes2/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@bluelovers/tsconfig/tsdx/index.json", 3 | "compilerOptions": { 4 | "importHelpers": true, 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/safe-variable-name/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [1.0.4](https://github.com/bluelovers/ws-string/compare/safe-variable-name@1.0.3...safe-variable-name@1.0.4) (2024-01-29) 7 | 8 | **Note:** Version bump only for package safe-variable-name 9 | 10 | 11 | 12 | 13 | 14 | ## [1.0.3](https://github.com/bluelovers/ws-string/compare/safe-variable-name@1.0.2...safe-variable-name@1.0.3) (2023-04-12) 15 | 16 | 17 | 18 | ### 🔖 Miscellaneous 19 | 20 | * . ([0d0b919](https://github.com/bluelovers/ws-string/commit/0d0b9196399b184f6431a3718bae6bfaf41164fd)) 21 | 22 | 23 | 24 | ## [1.0.2](https://github.com/bluelovers/ws-string/compare/safe-variable-name@1.0.1...safe-variable-name@1.0.2) (2022-11-01) 25 | 26 | 27 | 28 | ### 🔖 Miscellaneous 29 | 30 | * . ([c16d3cd](https://github.com/bluelovers/ws-string/commit/c16d3cd54f8a49287f41805546dca27f709f009d)) 31 | 32 | 33 | 34 | ## 1.0.1 (2022-10-27) 35 | 36 | 37 | 38 | ### 🔖 Miscellaneous 39 | 40 | * safe-variable-name ([7c02f7f](https://github.com/bluelovers/ws-string/commit/7c02f7f9a68e98189bea2eab254c0fb9cac4b3e2)) 41 | -------------------------------------------------------------------------------- /packages/safe-variable-name/README.md: -------------------------------------------------------------------------------- 1 | # README.md 2 | 3 | 4 | 5 | ## install 6 | 7 | ```bash 8 | yarn add safe-variable-name 9 | yarn-tool add safe-variable-name 10 | yt add safe-variable-name 11 | ``` 12 | 13 | -------------------------------------------------------------------------------- /packages/safe-variable-name/dist/index.cjs: -------------------------------------------------------------------------------- 1 | 2 | 'use strict' 3 | 4 | if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production') { 5 | module.exports = require('./index.cjs.development.cjs') 6 | } else { 7 | module.exports = require('./index.cjs.production.min.cjs') 8 | } 9 | -------------------------------------------------------------------------------- /packages/safe-variable-name/dist/index.cjs.development.cjs: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Object.defineProperty(exports, '__esModule', { value: true }); 4 | 5 | var camelCase = require('camelcase'); 6 | var reserved2 = require('reserved2'); 7 | 8 | function _safeVariableName(input) { 9 | return camelCase(input.replace(/([^\w\-_ ])/ig, '-'), { 10 | pascalCase: true, 11 | preserveConsecutiveUppercase: true, 12 | locale: 'en-US' 13 | }).replace(/((^[^a-zA-Z]+)|[^\w.-])|([^a-zA-Z0-9]+$)/g, ''); 14 | } 15 | function safeVariableName(input) { 16 | let name = _safeVariableName(input); 17 | if (reserved2.isReservedOrBuiltinsLC(name.toLowerCase())) { 18 | name = '_' + name; 19 | } 20 | return name; 21 | } 22 | 23 | exports._safeVariableName = _safeVariableName; 24 | exports.default = safeVariableName; 25 | exports.safeVariableName = safeVariableName; 26 | //# sourceMappingURL=index.cjs.development.cjs.map 27 | -------------------------------------------------------------------------------- /packages/safe-variable-name/dist/index.cjs.production.min.cjs: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: !0 5 | }); 6 | 7 | var e = require("camelcase"), a = require("reserved2"); 8 | 9 | function _safeVariableName(a) { 10 | return e(a.replace(/([^\w\-_ ])/gi, "-"), { 11 | pascalCase: !0, 12 | preserveConsecutiveUppercase: !0, 13 | locale: "en-US" 14 | }).replace(/((^[^a-zA-Z]+)|[^\w.-])|([^a-zA-Z0-9]+$)/g, ""); 15 | } 16 | 17 | function safeVariableName(e) { 18 | let r = _safeVariableName(e); 19 | return a.isReservedOrBuiltinsLC(r.toLowerCase()) && (r = "_" + r), r; 20 | } 21 | 22 | exports._safeVariableName = _safeVariableName, exports.default = safeVariableName, 23 | exports.safeVariableName = safeVariableName; 24 | //# sourceMappingURL=index.cjs.production.min.cjs.map 25 | -------------------------------------------------------------------------------- /packages/safe-variable-name/dist/index.d.ts: -------------------------------------------------------------------------------- 1 | export declare function _safeVariableName(input: string): string; 2 | export declare function safeVariableName(input: string): string; 3 | 4 | export { 5 | safeVariableName as default, 6 | }; 7 | 8 | export {}; 9 | -------------------------------------------------------------------------------- /packages/safe-variable-name/dist/index.esm.mjs: -------------------------------------------------------------------------------- 1 | import e from "camelcase"; 2 | 3 | import { isReservedOrBuiltinsLC as a } from "reserved2"; 4 | 5 | function _safeVariableName(a) { 6 | return e(a.replace(/([^\w\-_ ])/gi, "-"), { 7 | pascalCase: !0, 8 | preserveConsecutiveUppercase: !0, 9 | locale: "en-US" 10 | }).replace(/((^[^a-zA-Z]+)|[^\w.-])|([^a-zA-Z0-9]+$)/g, ""); 11 | } 12 | 13 | function safeVariableName(e) { 14 | let r = _safeVariableName(e); 15 | return a(r.toLowerCase()) && (r = "_" + r), r; 16 | } 17 | 18 | export { _safeVariableName, safeVariableName as default, safeVariableName }; 19 | //# sourceMappingURL=index.esm.mjs.map 20 | -------------------------------------------------------------------------------- /packages/safe-variable-name/src/index.ts: -------------------------------------------------------------------------------- 1 | import camelCase from 'camelcase'; 2 | import { isReservedOrBuiltinsLC } from 'reserved2'; 3 | 4 | export function _safeVariableName(input: string) 5 | { 6 | return camelCase( 7 | input.replace(/([^\w\-_ ])/ig, '-') 8 | , { pascalCase: true, preserveConsecutiveUppercase: true, locale: 'en-US' }) 9 | .replace(/((^[^a-zA-Z]+)|[^\w.-])|([^a-zA-Z0-9]+$)/g, ''); 10 | } 11 | 12 | export function safeVariableName(input: string) 13 | { 14 | let name = _safeVariableName(input); 15 | 16 | if (isReservedOrBuiltinsLC(name.toLowerCase())) 17 | { 18 | name = '_' + name; 19 | } 20 | 21 | return name 22 | } 23 | 24 | export default safeVariableName 25 | -------------------------------------------------------------------------------- /packages/safe-variable-name/test/__root.ts: -------------------------------------------------------------------------------- 1 | import { join } from "path"; 2 | 3 | export const __ROOT = join(__dirname, '..'); 4 | 5 | export const isWin = process.platform === "win32"; 6 | -------------------------------------------------------------------------------- /packages/safe-variable-name/test/__snapshots__/var.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`when a basic one-word string is passed should return the string as-is 1`] = `"Foo"`; 4 | 5 | exports[`when a malformed name is passed should return a camel-case version of the name 1`] = `"ThisIsATest"`; 6 | 7 | exports[`when a malformed name is passed should return a camel-case version of the name 2`] = `"ThisIsATest"`; 8 | 9 | exports[`when a malformed name is passed should return a camel-case version of the name 3`] = `"ThisIsATest"`; 10 | 11 | exports[`when a two-word name separated by hyphens is passed should return a camel-case version of the name 1`] = `"FooBar"`; 12 | -------------------------------------------------------------------------------- /packages/safe-variable-name/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "module": "NodeNext", 5 | "noEmit": true, 6 | "declaration": false, 7 | "noUnusedParameters": false, 8 | "allowUnusedLabels": true, 9 | "noUnusedLocals": false, 10 | "noPropertyAccessFromIndexSignature": false 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/safe-variable-name/test/var.spec.ts: -------------------------------------------------------------------------------- 1 | //@noUnusedParameters:false 2 | /// 3 | /// 4 | /// 5 | 6 | import { basename, extname } from 'path'; 7 | import { safeVariableName } from '../src/index'; 8 | 9 | beforeAll(async () => 10 | { 11 | 12 | }); 13 | 14 | describe('when a basic one-word string is passed', function () 15 | { 16 | it('should return the string as-is', function () 17 | { 18 | var actual = safeVariableName('foo'); 19 | var expected = 'foo'; 20 | expect(actual).toMatchSnapshot(); 21 | }); 22 | }); 23 | 24 | describe('when a two-word name separated by hyphens is passed', function () 25 | { 26 | it('should return a camel-case version of the name', function () 27 | { 28 | var actual = safeVariableName('foo-bar'); 29 | var expected = 'fooBar'; 30 | expect(actual).toMatchSnapshot(); 31 | }); 32 | }); 33 | 34 | describe('when a malformed name is passed', function () 35 | { 36 | it('should return a camel-case version of the name', function () 37 | { 38 | var actual = safeVariableName('this is a test - _'); 39 | var expected = 'thisIsATest'; 40 | expect(actual).toMatchSnapshot(); 41 | }); 42 | 43 | it('should return a camel-case version of the name', function () 44 | { 45 | var actual = safeVariableName('_this is a test - _'); 46 | var expected = 'thisIsATest'; 47 | expect(actual).toMatchSnapshot(); 48 | }); 49 | 50 | it('should return a camel-case version of the name', function () 51 | { 52 | var actual = safeVariableName('_this&&&is a test - _'); 53 | var expected = 'thisIsATest'; 54 | expect(actual).toMatchSnapshot(); 55 | }); 56 | }); 57 | -------------------------------------------------------------------------------- /packages/safe-variable-name/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@bluelovers/tsconfig/tsdx/index.json", 3 | "compilerOptions": { 4 | "importHelpers": true, 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/str-util/.npmignore: -------------------------------------------------------------------------------- 1 | /.pnp 2 | .pnp.js 3 | .idea 4 | ~ci.list.txt 5 | ~ci.log.txt 6 | ~ci.errors.txt 7 | *.stackdump 8 | *.bak 9 | *.old 10 | *.log 11 | tsconfig.json 12 | package-lock.json 13 | test 14 | .github 15 | .gitkeep 16 | /.*/ 17 | /.* 18 | tests 19 | /~* 20 | __test__ 21 | __tests__ 22 | node_modules 23 | /node_modules/ 24 | **/node_modules/ 25 | *.ts 26 | !*.d.ts 27 | /bin/**/*.d.ts 28 | /bin/*.d.ts 29 | 30 | !*.d.mts 31 | /bin/**/*.d.mts 32 | /bin/*.d.mts 33 | 34 | !*.d.cts 35 | /bin/**/*.d.cts 36 | /bin/*.d.cts 37 | 38 | !/src/**/*.ts 39 | !/src/**/*.cts 40 | !/src/**/*.mts 41 | !/src/**/*.tsx 42 | 43 | /src/**/*.d.ts 44 | /src/**/*.js 45 | /src/**/*.d.cts 46 | /src/**/*.d.mts 47 | /src/**/*.cjs 48 | /src/**/*.mjs 49 | /src/**/*.jsx 50 | 51 | *.tgz 52 | /tsconfig.json.tpl 53 | yarn-error.log 54 | .git 55 | yarn.lock 56 | .env.local 57 | .env.*.local 58 | npm-debug.log* 59 | yarn-debug.log* 60 | yarn-error.log* 61 | .vscode 62 | *.suo 63 | *.ntvs* 64 | *.njsproj 65 | *.sln 66 | *.sw? 67 | *.vue.js 68 | *.vue.d.ts 69 | *.vue.js.map 70 | .nyc_output 71 | coverage 72 | /*.tpl 73 | webpack.config.js 74 | vue.config.js 75 | /jestconfig.json 76 | /tslint.json 77 | .git 78 | webpack.*.config.js 79 | webpack.*.config.d.ts 80 | webpack.*.config.js.map 81 | webpack.*.config.ts 82 | karma.conf.js 83 | /_config.yml 84 | intellij-style-guide.xml 85 | jest.config.js 86 | *.tsbuildinfo 87 | tsconfig.*.json 88 | tsconfig.esm.json.tpl 89 | /package.d.ts 90 | .mocharc.yml 91 | jest.config.js 92 | jest.config.* 93 | /jest-preset.* 94 | /report.*.json 95 | now.json 96 | /Makefile 97 | *.spec.d.ts 98 | *.spec.js 99 | *.spec.ts 100 | 101 | *.spec.d.cts 102 | *.spec.cjs 103 | *.spec.cts 104 | 105 | *.spec.d.mts 106 | *.spec.mjs 107 | *.spec.mts 108 | 109 | *.spec.d.tsx 110 | *.spec.tsx 111 | 112 | __mocks__ 113 | __tests__ 114 | __snapshots__ 115 | *.snap 116 | npm-shrinkwrap.json 117 | /example/ 118 | *.stat 119 | .vercel 120 | tsdx.config.js 121 | /report.json 122 | 123 | /_*/ 124 | _snowpack 125 | 126 | /snowpack.config.js 127 | web_modules 128 | cz-adapter 129 | 130 | tsc-multi.json.tpl 131 | tsc-multi.json 132 | 133 | changelog-option.js 134 | 135 | bin/tsconfig.json 136 | bin/tsconfig.*.json 137 | 138 | .yarnrc.yml 139 | .turbo 140 | __file_snapshots__ 141 | __fixtures__ 142 | /fixture/ 143 | -------------------------------------------------------------------------------- /packages/str-util/README.md: -------------------------------------------------------------------------------- 1 | # str-util 2 | 3 | > convert full/half width, Chinese/Japanese number ... others util helper 4 | 5 | `npm i str-util` 6 | 7 | ## Usage 8 | 9 | ```javascript 10 | import * as StrUtil from 'str-util'; 11 | ``` 12 | 13 | See more at [test](https://github.com/bluelovers/node-str-util/tree/master/test) / [docs](https://bluelovers.github.io/node-str-util/) 14 | 15 | ### FullHalf 16 | 17 | ```javascript 18 | const str = 'THE quick, BROWN\u3000fox.'; 19 | 20 | StrUtil.toFullWidth(str); 21 | //=> 'THE quick, BROWN fox.' 22 | 23 | StrUtil.toHalfWidth(str); 24 | //=> 'THE quick, BROWN fox.' 25 | 26 | console.log(StrUtil.toFullEnglish('123abcABCABC123/*-+=-0][’;/.+-*/=-09][\'";/.')); 27 | console.log(StrUtil.toHalfEnglish('123abcABCABC123/*-+=-0][’;/.+-*/=-09][\'";/.')); 28 | console.log(StrUtil.toFullNumber('123abcABCABC123/*-+=-0][’;/.+-*/=-09][\'";/.')); 29 | console.log(StrUtil.toHalfNumber('123abcABCABC123/*-+=-0][’;/.+-*/=-09][\'";/.')); 30 | ``` 31 | 32 | default 33 | ``` 34 | 0123456789 35 | 0123456789 36 | ABCDEFGHIJKLMNOPQRSTUVWXYZ 37 | ABCDEFGHIJKLMNOPQRSTUVWXYZ 38 | abcdefghijklmnopqrstuvwxyz 39 | abcdefghijklmnopqrstuvwxyz 40 |   41 | 42 | !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ 43 | !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ 44 | ``` 45 | 46 | ### 漢字 Number 47 | 48 | ```javascript 49 | zh2num('千百十七') == 1117 50 | num2zh(1117) == '千百十七' 51 | ``` 52 | 53 | ### 中日漢字 54 | 55 | ```javascript 56 | import { zh2jp } from 'str-util'; 57 | 58 | let t = '魔物解説 ランク等話 蚀蝕蝕王で触王 冒険者ギルド解説 蚀|蝕战|戦马|馬亚|亞國預中日漢字對照表' 59 | 60 | console.log(zh2jp(t)); 61 | ``` 62 | 63 | ```javascript 64 | import * as ZH2JP from 'str-util/lib/han/zh2jp'; 65 | 66 | // 沒有漢字存在時會直接返回原參數 67 | console.log(ZH2JP.zhs2jp(1)); 68 | 69 | // http://ncode.syosetu.com/n1745ct/ 70 | let t = '魔物解説 ランク等話 蚀蝕蝕王で触王 冒険者ギルド解説 蚀|蝕战|戦马|馬亚|亞國預中日漢字對照表' 71 | 72 | console.log(ZH2JP.zh2jp(t)); 73 | console.log(ZH2JP.zht2jp(t)); 74 | console.log(ZH2JP.zhs2jp(t)); 75 | 76 | console.log(ZH2JP.zht2zhs(t)); 77 | console.log(ZH2JP.zhs2zht(t)); 78 | ``` 79 | 80 | ## lib 81 | 82 | * `ascii-fullwidth-halfwidth-convert` 83 | * `string-width` 84 | * `chinese-parseint` 85 | * `japanese` 86 | -------------------------------------------------------------------------------- /packages/str-util/index.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2017/12/8/008. 3 | */ 4 | export { isFullWidth, isFullwidthCodePoint } from './lib/is-fullwidth'; 5 | export { stringWidth } from './lib/width'; 6 | import { toFullNumber, toHalfNumber, toFullEnglish, toHalfEnglish, toFullWidth, toHalfWidth } from '@lazy-cjk/fullhalf'; 7 | import stripAnsi from 'strip-ansi'; 8 | export { normalize } from '@lazy-cjk/str-util-normalize'; 9 | export { trim, ITrimOptions } from '@lazy-cjk/str-util-trim'; 10 | export { zh2jp, jp2zhs, jp2zht } from '@lazy-cjk/jp-table-convert'; 11 | export { zh2num, num2zh } from '@lazy-cjk/zh2num'; 12 | export { charCodeAt } from '@lazy-cjk/str-util-char-code-at'; 13 | export { toFullNumber, toHalfNumber, toFullEnglish, toHalfEnglish, toFullWidth, toHalfWidth }; 14 | export { stripAnsi }; 15 | declare const _default: typeof import("./index"); 16 | export default _default; 17 | -------------------------------------------------------------------------------- /packages/str-util/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2017/12/8/008. 3 | */ 4 | 5 | export { isFullWidth, isFullwidthCodePoint } from './lib/is-fullwidth'; 6 | export { stringWidth } from './lib/width'; 7 | import { toFullNumber, toHalfNumber, toFullEnglish, toHalfEnglish, toFullWidth, toHalfWidth } from '@lazy-cjk/fullhalf'; 8 | import stripAnsi from 'strip-ansi'; 9 | 10 | export { normalize } from '@lazy-cjk/str-util-normalize'; 11 | 12 | export { trim, ITrimOptions } from '@lazy-cjk/str-util-trim'; 13 | 14 | export { zh2jp, jp2zhs, jp2zht } from '@lazy-cjk/jp-table-convert'; 15 | 16 | export { zh2num, num2zh } from '@lazy-cjk/zh2num'; 17 | export { charCodeAt } from '@lazy-cjk/str-util-char-code-at'; 18 | 19 | export { toFullNumber, toHalfNumber, toFullEnglish, toHalfEnglish, toFullWidth, toHalfWidth } 20 | export { stripAnsi } 21 | 22 | export default exports as typeof import('./index'); 23 | -------------------------------------------------------------------------------- /packages/str-util/lib/fullhalf.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2017/12/8/008. 3 | */ 4 | import { toFullEnglish, toFullNumber, toFullWidth, toHalfEnglish, toHalfNumber, toHalfWidth, type IFactoryFn } from '@lazy-cjk/fullhalf'; 5 | export { toFullNumber, toHalfNumber, toFullEnglish, toHalfEnglish, toFullWidth, toHalfWidth, }; 6 | declare const _default: { 7 | toFullNumber: IFactoryFn; 8 | toHalfNumber: IFactoryFn; 9 | toFullEnglish: IFactoryFn; 10 | toHalfEnglish: IFactoryFn; 11 | toFullWidth: IFactoryFn; 12 | toHalfWidth: IFactoryFn; 13 | }; 14 | export default _default; 15 | -------------------------------------------------------------------------------- /packages/str-util/lib/fullhalf.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.toHalfWidth = exports.toFullWidth = exports.toHalfEnglish = exports.toFullEnglish = exports.toHalfNumber = exports.toFullNumber = void 0; 4 | /** 5 | * Created by user on 2017/12/8/008. 6 | */ 7 | const fullhalf_1 = require("@lazy-cjk/fullhalf"); 8 | Object.defineProperty(exports, "toFullEnglish", { enumerable: true, get: function () { return fullhalf_1.toFullEnglish; } }); 9 | Object.defineProperty(exports, "toFullNumber", { enumerable: true, get: function () { return fullhalf_1.toFullNumber; } }); 10 | Object.defineProperty(exports, "toFullWidth", { enumerable: true, get: function () { return fullhalf_1.toFullWidth; } }); 11 | Object.defineProperty(exports, "toHalfEnglish", { enumerable: true, get: function () { return fullhalf_1.toHalfEnglish; } }); 12 | Object.defineProperty(exports, "toHalfNumber", { enumerable: true, get: function () { return fullhalf_1.toHalfNumber; } }); 13 | Object.defineProperty(exports, "toHalfWidth", { enumerable: true, get: function () { return fullhalf_1.toHalfWidth; } }); 14 | exports.default = { 15 | toFullNumber: fullhalf_1.toFullNumber, 16 | toHalfNumber: fullhalf_1.toHalfNumber, 17 | toFullEnglish: fullhalf_1.toFullEnglish, 18 | toHalfEnglish: fullhalf_1.toHalfEnglish, 19 | toFullWidth: fullhalf_1.toFullWidth, 20 | toHalfWidth: fullhalf_1.toHalfWidth, 21 | }; 22 | //# sourceMappingURL=fullhalf.js.map -------------------------------------------------------------------------------- /packages/str-util/lib/fullhalf.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2017/12/8/008. 3 | */ 4 | import { 5 | toFullEnglish, 6 | toFullNumber, 7 | toFullWidth, 8 | toHalfEnglish, 9 | toHalfNumber, 10 | toHalfWidth, 11 | type IFactoryFn, 12 | } from '@lazy-cjk/fullhalf'; 13 | 14 | export { 15 | toFullNumber, 16 | toHalfNumber, 17 | 18 | toFullEnglish, 19 | toHalfEnglish, 20 | 21 | toFullWidth, 22 | toHalfWidth, 23 | } 24 | 25 | export default { 26 | toFullNumber, 27 | toHalfNumber, 28 | 29 | toFullEnglish, 30 | toHalfEnglish, 31 | 32 | toFullWidth, 33 | toHalfWidth, 34 | } 35 | -------------------------------------------------------------------------------- /packages/str-util/lib/han/table.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2017/12/24/024. 3 | * 4 | * @see https://www.jcinfo.net/tw/tools/kanji 5 | * @see http://dict.variants.moe.edu.tw/variants/rbt/japan_chinese_character_tiles.rbt?pageId=2981908 6 | * @see https://en.wikipedia.org/wiki/List_of_j%C5%8Dy%C5%8D_kanji 7 | * @see https://hanzi.unihan.com.cn/CJKCompare 8 | * @see http://www5b.biglobe.ne.jp/%7Eharigaya/variants.html 9 | */ 10 | export * from '@lazy-cjk/jp-table-comparison'; 11 | import { TABLE } from '@lazy-cjk/jp-table-comparison'; 12 | export default TABLE; 13 | -------------------------------------------------------------------------------- /packages/str-util/lib/han/table.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * Created by user on 2017/12/24/024. 4 | * 5 | * @see https://www.jcinfo.net/tw/tools/kanji 6 | * @see http://dict.variants.moe.edu.tw/variants/rbt/japan_chinese_character_tiles.rbt?pageId=2981908 7 | * @see https://en.wikipedia.org/wiki/List_of_j%C5%8Dy%C5%8D_kanji 8 | * @see https://hanzi.unihan.com.cn/CJKCompare 9 | * @see http://www5b.biglobe.ne.jp/%7Eharigaya/variants.html 10 | */ 11 | Object.defineProperty(exports, "__esModule", { value: true }); 12 | const tslib_1 = require("tslib"); 13 | tslib_1.__exportStar(require("@lazy-cjk/jp-table-comparison"), exports); 14 | const jp_table_comparison_1 = require("@lazy-cjk/jp-table-comparison"); 15 | exports.default = jp_table_comparison_1.TABLE; 16 | //# sourceMappingURL=table.js.map -------------------------------------------------------------------------------- /packages/str-util/lib/han/table.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2017/12/24/024. 3 | * 4 | * @see https://www.jcinfo.net/tw/tools/kanji 5 | * @see http://dict.variants.moe.edu.tw/variants/rbt/japan_chinese_character_tiles.rbt?pageId=2981908 6 | * @see https://en.wikipedia.org/wiki/List_of_j%C5%8Dy%C5%8D_kanji 7 | * @see https://hanzi.unihan.com.cn/CJKCompare 8 | * @see http://www5b.biglobe.ne.jp/%7Eharigaya/variants.html 9 | */ 10 | 11 | export * from '@lazy-cjk/jp-table-comparison'; 12 | import { TABLE } from '@lazy-cjk/jp-table-comparison'; 13 | export default TABLE; 14 | -------------------------------------------------------------------------------- /packages/str-util/lib/han/zh2jp.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2017/12/24/024. 3 | * 4 | * this module only do the char is exists in jp, zht, zhs 5 | * so don't use this module when u wanna fully zht <=> zhs 6 | */ 7 | export * from '@lazy-cjk/jp-table-convert'; 8 | import { zh2jp } from '@lazy-cjk/jp-table-convert'; 9 | export default zh2jp; 10 | -------------------------------------------------------------------------------- /packages/str-util/lib/han/zh2jp.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * Created by user on 2017/12/24/024. 4 | * 5 | * this module only do the char is exists in jp, zht, zhs 6 | * so don't use this module when u wanna fully zht <=> zhs 7 | */ 8 | Object.defineProperty(exports, "__esModule", { value: true }); 9 | const tslib_1 = require("tslib"); 10 | tslib_1.__exportStar(require("@lazy-cjk/jp-table-convert"), exports); 11 | const jp_table_convert_1 = require("@lazy-cjk/jp-table-convert"); 12 | exports.default = jp_table_convert_1.zh2jp; 13 | //# sourceMappingURL=zh2jp.js.map -------------------------------------------------------------------------------- /packages/str-util/lib/han/zh2jp.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2017/12/24/024. 3 | * 4 | * this module only do the char is exists in jp, zht, zhs 5 | * so don't use this module when u wanna fully zht <=> zhs 6 | */ 7 | 8 | export * from '@lazy-cjk/jp-table-convert'; 9 | import { zh2jp } from '@lazy-cjk/jp-table-convert'; 10 | export default zh2jp; 11 | -------------------------------------------------------------------------------- /packages/str-util/lib/han/zh2num.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2017/12/11/011. 3 | */ 4 | import { zh2num, num2zh } from '@lazy-cjk/zh2num'; 5 | export { zh2num, num2zh, }; 6 | declare const _default: { 7 | zh2num: typeof zh2num; 8 | num2zh: typeof num2zh; 9 | }; 10 | export default _default; 11 | -------------------------------------------------------------------------------- /packages/str-util/lib/han/zh2num.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * Created by user on 2017/12/11/011. 4 | */ 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | exports.num2zh = exports.zh2num = void 0; 7 | const zh2num_1 = require("@lazy-cjk/zh2num"); 8 | Object.defineProperty(exports, "zh2num", { enumerable: true, get: function () { return zh2num_1.zh2num; } }); 9 | Object.defineProperty(exports, "num2zh", { enumerable: true, get: function () { return zh2num_1.num2zh; } }); 10 | exports.default = { 11 | zh2num: zh2num_1.zh2num, 12 | num2zh: zh2num_1.num2zh, 13 | }; 14 | //# sourceMappingURL=zh2num.js.map -------------------------------------------------------------------------------- /packages/str-util/lib/han/zh2num.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2017/12/11/011. 3 | */ 4 | 5 | import { zh2num, num2zh } from '@lazy-cjk/zh2num'; 6 | 7 | export { 8 | zh2num, 9 | num2zh, 10 | } 11 | 12 | export default { 13 | zh2num, 14 | num2zh, 15 | } 16 | -------------------------------------------------------------------------------- /packages/str-util/lib/is-fullwidth.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2017/12/8/008. 3 | */ 4 | export declare function isFullwidthCodePoint(x: number): boolean; 5 | export declare function isFullWidth(s: T): boolean; 6 | declare const _default: typeof import("./is-fullwidth"); 7 | export default _default; 8 | -------------------------------------------------------------------------------- /packages/str-util/lib/is-fullwidth.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * Created by user on 2017/12/8/008. 4 | */ 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | exports.isFullWidth = exports.isFullwidthCodePoint = void 0; 7 | const tslib_1 = require("tslib"); 8 | const is_fullwidth_code_point_1 = tslib_1.__importDefault(require("is-fullwidth-code-point")); 9 | function isFullwidthCodePoint(x) { 10 | if (Number.isNaN(x)) { 11 | return false; 12 | } 13 | if (0 14 | || ( 15 | // https://en.wikipedia.org/wiki/Box-drawing_character 16 | 0x2500 <= x && x <= 0x257f) 17 | || ( 18 | // https://en.wikipedia.org/wiki/Block_Elements 19 | 0x2580 <= x && x <= 0x259f) 20 | || (0, is_fullwidth_code_point_1.default)(x)) { 21 | return true; 22 | } 23 | } 24 | exports.isFullwidthCodePoint = isFullwidthCodePoint; 25 | function isFullWidth(s) { 26 | // @ts-ignore 27 | return isFullwidthCodePoint((typeof s != 'number') ? s.codePointAt() : s); 28 | } 29 | exports.isFullWidth = isFullWidth; 30 | exports.default = exports; 31 | //# sourceMappingURL=is-fullwidth.js.map -------------------------------------------------------------------------------- /packages/str-util/lib/is-fullwidth.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2017/12/8/008. 3 | */ 4 | 5 | import _isFullwidthCodePoint from 'is-fullwidth-code-point'; 6 | 7 | export function isFullwidthCodePoint(x: number): boolean 8 | { 9 | if (Number.isNaN(x)) 10 | { 11 | return false; 12 | } 13 | 14 | if (0 15 | || ( 16 | // https://en.wikipedia.org/wiki/Box-drawing_character 17 | 0x2500 <= x && x <= 0x257f 18 | ) 19 | || ( 20 | // https://en.wikipedia.org/wiki/Block_Elements 21 | 0x2580 <= x && x <= 0x259f 22 | ) 23 | || _isFullwidthCodePoint(x) 24 | ) 25 | { 26 | return true; 27 | } 28 | } 29 | 30 | export function isFullWidth(s: T) 31 | { 32 | // @ts-ignore 33 | return isFullwidthCodePoint((typeof s != 'number') ? s.codePointAt() : s); 34 | } 35 | 36 | export default exports as typeof import('./is-fullwidth'); 37 | -------------------------------------------------------------------------------- /packages/str-util/lib/normalize.d.ts: -------------------------------------------------------------------------------- 1 | export { StripTable, normalize, IOptions, normalize as default, } from '@lazy-cjk/str-util-normalize'; 2 | -------------------------------------------------------------------------------- /packages/str-util/lib/normalize.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.default = exports.IOptions = exports.normalize = exports.StripTable = void 0; 4 | var str_util_normalize_1 = require("@lazy-cjk/str-util-normalize"); 5 | Object.defineProperty(exports, "StripTable", { enumerable: true, get: function () { return str_util_normalize_1.StripTable; } }); 6 | Object.defineProperty(exports, "normalize", { enumerable: true, get: function () { return str_util_normalize_1.normalize; } }); 7 | Object.defineProperty(exports, "IOptions", { enumerable: true, get: function () { return str_util_normalize_1.IOptions; } }); 8 | Object.defineProperty(exports, "default", { enumerable: true, get: function () { return str_util_normalize_1.normalize; } }); 9 | //# sourceMappingURL=normalize.js.map -------------------------------------------------------------------------------- /packages/str-util/lib/normalize.ts: -------------------------------------------------------------------------------- 1 | 2 | export { 3 | StripTable, 4 | normalize, 5 | IOptions, 6 | normalize as default, 7 | } from '@lazy-cjk/str-util-normalize'; 8 | -------------------------------------------------------------------------------- /packages/str-util/lib/trim.d.ts: -------------------------------------------------------------------------------- 1 | export { trim as default, trim, ITrimOptions } from '@lazy-cjk/str-util-trim'; 2 | -------------------------------------------------------------------------------- /packages/str-util/lib/trim.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.trim = exports.default = void 0; 4 | var str_util_trim_1 = require("@lazy-cjk/str-util-trim"); 5 | Object.defineProperty(exports, "default", { enumerable: true, get: function () { return str_util_trim_1.trim; } }); 6 | Object.defineProperty(exports, "trim", { enumerable: true, get: function () { return str_util_trim_1.trim; } }); 7 | //# sourceMappingURL=trim.js.map -------------------------------------------------------------------------------- /packages/str-util/lib/trim.ts: -------------------------------------------------------------------------------- 1 | 2 | export { trim as default, trim, ITrimOptions } from '@lazy-cjk/str-util-trim'; 3 | -------------------------------------------------------------------------------- /packages/str-util/lib/var.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2017/12/10/010. 3 | * 4 | * https://github.com/peertransfer/cjk-protector/blob/master/dist/cjk-protector.js 5 | * http://www.cnblogs.com/yitian/archive/2008/11/14/1333569.html 6 | * https://gist.github.com/kiinlam/11275992 7 | * https://github.com/Lizhooh/only-space/blob/master/index.js 8 | */ 9 | export declare const hanRegex: RegExp; 10 | export declare const katakanaRegex: RegExp; 11 | export declare const hiraganaRegex: RegExp; 12 | export declare const hangulRegex: RegExp; 13 | export declare const allRegex: RegExp[]; 14 | export declare const zhs: RegExp; 15 | export declare const zh: RegExp; 16 | export declare const Arabic: RegExp; 17 | declare const _default: typeof import("./var"); 18 | export default _default; 19 | -------------------------------------------------------------------------------- /packages/str-util/lib/var.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * Created by user on 2017/12/10/010. 4 | * 5 | * https://github.com/peertransfer/cjk-protector/blob/master/dist/cjk-protector.js 6 | * http://www.cnblogs.com/yitian/archive/2008/11/14/1333569.html 7 | * https://gist.github.com/kiinlam/11275992 8 | * https://github.com/Lizhooh/only-space/blob/master/index.js 9 | */ 10 | Object.defineProperty(exports, "__esModule", { value: true }); 11 | exports.Arabic = exports.zh = exports.zhs = exports.allRegex = exports.hangulRegex = exports.hiraganaRegex = exports.katakanaRegex = exports.hanRegex = void 0; 12 | exports.hanRegex = /[\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u3005\u3007\u3021-\u3029\u3038-\u303B\u3400-\u4DB5\u4E00-\u9FCC\uF900-\uFA6D\uFA70-\uFAD9]|[\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD87E[\uDC00-\uDE1D]/; 13 | exports.katakanaRegex = /[\u30A1-\u30FA\u30FD-\u30FF\u31F0-\u31FF\u32D0-\u32FE\u3300-\u3357\uFF66-\uFF6F\uFF71-\uFF9D]|\uD82C\uDC00/; 14 | exports.hiraganaRegex = /[\u3041-\u3096\u309D-\u309F]|\uD82C\uDC01|\uD83C\uDE00/; 15 | exports.hangulRegex = /[\u1100-\u11FF\u302E\u302F\u3131-\u318E\u3200-\u321E\u3260-\u327E\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uFFA0-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/; 16 | exports.allRegex = [exports.hanRegex, exports.katakanaRegex, exports.hiraganaRegex, exports.hangulRegex]; 17 | exports.zhs = /[\u4E00-\u9FA5]+/; 18 | exports.zh = /[\u4E00-\u9FFF]+/; 19 | exports.Arabic = /[\u0600-\u06FF\u0750-\u077F]/; 20 | //console.log(mergeRegExp([zhs]).exec('這種情況中日韩符号区。收容康熙字典部首、中日韩辅助部首、注音符号、日本假名、韩文音符,中日韩的符号、标点、带圈或带括符文数字、月份,以及日本的假名组合、单位、年号、月份、日期、时间等。A社會幫忙嗎...')); 21 | exports.default = exports; 22 | //# sourceMappingURL=var.js.map -------------------------------------------------------------------------------- /packages/str-util/lib/var.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2017/12/10/010. 3 | * 4 | * https://github.com/peertransfer/cjk-protector/blob/master/dist/cjk-protector.js 5 | * http://www.cnblogs.com/yitian/archive/2008/11/14/1333569.html 6 | * https://gist.github.com/kiinlam/11275992 7 | * https://github.com/Lizhooh/only-space/blob/master/index.js 8 | */ 9 | 10 | export const hanRegex = /[\u2E80-\u2E99\u2E9B-\u2EF3\u2F00-\u2FD5\u3005\u3007\u3021-\u3029\u3038-\u303B\u3400-\u4DB5\u4E00-\u9FCC\uF900-\uFA6D\uFA70-\uFAD9]|[\uD840-\uD868\uD86A-\uD86C][\uDC00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D]|\uD869[\uDC00-\uDED6\uDF00-\uDFFF]|\uD87E[\uDC00-\uDE1D]/; 11 | 12 | export const katakanaRegex = /[\u30A1-\u30FA\u30FD-\u30FF\u31F0-\u31FF\u32D0-\u32FE\u3300-\u3357\uFF66-\uFF6F\uFF71-\uFF9D]|\uD82C\uDC00/; 13 | 14 | export const hiraganaRegex = /[\u3041-\u3096\u309D-\u309F]|\uD82C\uDC01|\uD83C\uDE00/; 15 | 16 | export const hangulRegex = /[\u1100-\u11FF\u302E\u302F\u3131-\u318E\u3200-\u321E\u3260-\u327E\uA960-\uA97C\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uFFA0-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]/; 17 | 18 | export const allRegex = [hanRegex, katakanaRegex, hiraganaRegex, hangulRegex]; 19 | 20 | export const zhs = /[\u4E00-\u9FA5]+/; 21 | export const zh = /[\u4E00-\u9FFF]+/; 22 | 23 | export const Arabic = /[\u0600-\u06FF\u0750-\u077F]/; 24 | 25 | //console.log(mergeRegExp([zhs]).exec('這種情況中日韩符号区。收容康熙字典部首、中日韩辅助部首、注音符号、日本假名、韩文音符,中日韩的符号、标点、带圈或带括符文数字、月份,以及日本的假名组合、单位、年号、月份、日期、时间等。A社會幫忙嗎...')); 26 | 27 | export default exports as typeof import('./var'); 28 | -------------------------------------------------------------------------------- /packages/str-util/lib/width.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2017/12/8/008. 3 | */ 4 | export declare function stringWidth(str: any): number; 5 | declare const _default: typeof import("./width"); 6 | export default _default; 7 | -------------------------------------------------------------------------------- /packages/str-util/lib/width.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * Created by user on 2017/12/8/008. 4 | */ 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | exports.stringWidth = void 0; 7 | const tslib_1 = require("tslib"); 8 | const strip_ansi_1 = tslib_1.__importDefault(require("strip-ansi")); 9 | const is_fullwidth_1 = require("./is-fullwidth"); 10 | function stringWidth(str) { 11 | if (typeof str !== 'string' || str.length === 0) { 12 | return 0; 13 | } 14 | str = (0, strip_ansi_1.default)(str); 15 | let width = 0; 16 | for (let i = 0; i < str.length; i++) { 17 | const code = str.codePointAt(i); 18 | // Ignore control characters 19 | if (code <= 0x1F || (code >= 0x7F && code <= 0x9F)) { 20 | continue; 21 | } 22 | // Ignore combining characters 23 | if (code >= 0x300 && code <= 0x36F) { 24 | continue; 25 | } 26 | // Surrogates 27 | if (code > 0xFFFF) { 28 | i++; 29 | } 30 | width += (0, is_fullwidth_1.isFullwidthCodePoint)(code) ? 2 : 1; 31 | } 32 | return width; 33 | } 34 | exports.stringWidth = stringWidth; 35 | exports.default = exports; 36 | //# sourceMappingURL=width.js.map -------------------------------------------------------------------------------- /packages/str-util/lib/width.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2017/12/8/008. 3 | */ 4 | 5 | import stripAnsi from 'strip-ansi'; 6 | import { isFullwidthCodePoint } from './is-fullwidth'; 7 | 8 | export function stringWidth(str): number 9 | { 10 | if (typeof str !== 'string' || str.length === 0) { 11 | return 0; 12 | } 13 | 14 | str = stripAnsi(str); 15 | 16 | let width = 0; 17 | 18 | for (let i = 0; i < str.length; i++) { 19 | const code = str.codePointAt(i); 20 | 21 | // Ignore control characters 22 | if (code <= 0x1F || (code >= 0x7F && code <= 0x9F)) { 23 | continue; 24 | } 25 | 26 | // Ignore combining characters 27 | if (code >= 0x300 && code <= 0x36F) { 28 | continue; 29 | } 30 | 31 | // Surrogates 32 | if (code > 0xFFFF) { 33 | i++; 34 | } 35 | 36 | width += isFullwidthCodePoint(code) ? 2 : 1; 37 | } 38 | 39 | return width; 40 | } 41 | 42 | export default exports as typeof import('./width'); 43 | -------------------------------------------------------------------------------- /packages/string-indent/README.md: -------------------------------------------------------------------------------- 1 | # README.md 2 | 3 | 4 | 5 | ## install 6 | 7 | ```bash 8 | yarn add string-indent 9 | yarn-tool add string-indent 10 | yt add string-indent 11 | ``` 12 | 13 | -------------------------------------------------------------------------------- /packages/string-indent/dist/index.cjs: -------------------------------------------------------------------------------- 1 | 2 | 'use strict' 3 | 4 | if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production') { 5 | module.exports = require('./index.cjs.development.cjs') 6 | } else { 7 | module.exports = require('./index.cjs.production.min.cjs') 8 | } 9 | -------------------------------------------------------------------------------- /packages/string-indent/dist/index.cjs.development.cjs: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Object.defineProperty(exports, '__esModule', { value: true }); 4 | 5 | const REGEX_MATCH_INDENT = /^([ \t]*)((?:[\S\r\n].*|)$)/; 6 | const REGEX_MATCH_INDENT_NO_BREAK_SPACE = /^([ \t\xa0]*)((?:[\S\r\n].*|)$)/; 7 | function detectIndentLine(input, options) { 8 | const m = (options !== null && options !== void 0 && options.includeNoBreakSpace ? REGEX_MATCH_INDENT_NO_BREAK_SPACE : REGEX_MATCH_INDENT).exec(input); 9 | return { 10 | input, 11 | indent: m[1], 12 | body: m[2], 13 | bool: m[1].length > 0 14 | }; 15 | } 16 | 17 | exports.default = detectIndentLine; 18 | exports.detectIndentLine = detectIndentLine; 19 | //# sourceMappingURL=index.cjs.development.cjs.map 20 | -------------------------------------------------------------------------------- /packages/string-indent/dist/index.cjs.production.min.cjs: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | Object.defineProperty(exports, "__esModule", { 4 | value: !0 5 | }); 6 | 7 | const e = /^([ \t]*)((?:[\S\r\n].*|)$)/, t = /^([ \t\xa0]*)((?:[\S\r\n].*|)$)/; 8 | 9 | function detectIndentLine(n, d) { 10 | const c = (null != d && d.includeNoBreakSpace ? t : e).exec(n); 11 | return { 12 | input: n, 13 | indent: c[1], 14 | body: c[2], 15 | bool: c[1].length > 0 16 | }; 17 | } 18 | 19 | exports.default = detectIndentLine, exports.detectIndentLine = detectIndentLine; 20 | //# sourceMappingURL=index.cjs.production.min.cjs.map 21 | -------------------------------------------------------------------------------- /packages/string-indent/dist/index.d.ts: -------------------------------------------------------------------------------- 1 | export interface IOptions { 2 | /** 3 | * no-break space 4 | * \xa0 5 | */ 6 | includeNoBreakSpace?: boolean; 7 | } 8 | export declare function detectIndentLine(input: string, options?: IOptions): { 9 | input: string; 10 | indent: string; 11 | body: string; 12 | bool: boolean; 13 | }; 14 | 15 | export { 16 | detectIndentLine as default, 17 | }; 18 | 19 | export {}; 20 | -------------------------------------------------------------------------------- /packages/string-indent/dist/index.esm.mjs: -------------------------------------------------------------------------------- 1 | const e = /^([ \t]*)((?:[\S\r\n].*|)$)/, n = /^([ \t\xa0]*)((?:[\S\r\n].*|)$)/; 2 | 3 | function detectIndentLine(t, d) { 4 | const c = (null != d && d.includeNoBreakSpace ? n : e).exec(t); 5 | return { 6 | input: t, 7 | indent: c[1], 8 | body: c[2], 9 | bool: c[1].length > 0 10 | }; 11 | } 12 | 13 | export { detectIndentLine as default, detectIndentLine }; 14 | //# sourceMappingURL=index.esm.mjs.map 15 | -------------------------------------------------------------------------------- /packages/string-indent/src/index.ts: -------------------------------------------------------------------------------- 1 | const REGEX_MATCH_INDENT = /^([ \t]*)((?:[\S\r\n].*|)$)/; 2 | const REGEX_MATCH_INDENT_NO_BREAK_SPACE = /^([ \t\xa0]*)((?:[\S\r\n].*|)$)/; 3 | 4 | export interface IOptions 5 | { 6 | /** 7 | * no-break space 8 | * \xa0 9 | */ 10 | includeNoBreakSpace?: boolean, 11 | } 12 | 13 | export function detectIndentLine(input: string, options?: IOptions) 14 | { 15 | const m = (options?.includeNoBreakSpace ? REGEX_MATCH_INDENT_NO_BREAK_SPACE : REGEX_MATCH_INDENT).exec(input); 16 | return { 17 | input, 18 | indent: m[1], 19 | body: m[2], 20 | bool: m[1].length > 0, 21 | } 22 | } 23 | 24 | export default detectIndentLine 25 | -------------------------------------------------------------------------------- /packages/string-indent/test/__root.ts: -------------------------------------------------------------------------------- 1 | import { join } from "path"; 2 | 3 | export const __ROOT = join(__dirname, '..'); 4 | 5 | export const isWin = process.platform === "win32"; 6 | -------------------------------------------------------------------------------- /packages/string-indent/test/__snapshots__/demo.spec.ts.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[`base ' at pkg\\\\index.ts:64:6' 1`] = ` 4 | { 5 | "body": "at pkg\\index.ts:64:6", 6 | "bool": true, 7 | "indent": " ", 8 | "input": " at pkg\\index.ts:64:6", 9 | } 10 | `; 11 | 12 | exports[`base '' 1`] = ` 13 | { 14 | "body": "", 15 | "bool": false, 16 | "indent": "", 17 | "input": "", 18 | } 19 | `; 20 | 21 | exports[`base '\\n' 1`] = ` 22 | { 23 | "body": " 24 | ", 25 | "bool": false, 26 | "indent": "", 27 | "input": " 28 | ", 29 | } 30 | `; 31 | 32 | exports[`no-break space '  at pkg\\\\index.ts:64:6' 1`] = ` 33 | { 34 | "body": "at pkg\\index.ts:64:6", 35 | "bool": true, 36 | "indent": "  ", 37 | "input": "  at pkg\\index.ts:64:6", 38 | } 39 | `; 40 | 41 | exports[`no-break space ' ' 1`] = ` 42 | { 43 | "body": "", 44 | "bool": true, 45 | "indent": " ", 46 | "input": " ", 47 | } 48 | `; 49 | 50 | exports[`no-break space ' \\n' 1`] = ` 51 | { 52 | "body": " 53 | ", 54 | "bool": true, 55 | "indent": " ", 56 | "input": "  57 | ", 58 | } 59 | `; 60 | -------------------------------------------------------------------------------- /packages/string-indent/test/demo.spec.ts: -------------------------------------------------------------------------------- 1 | //@noUnusedParameters:false 2 | /// 3 | /// 4 | /// 5 | 6 | import { inspect } from 'util'; 7 | import { detectIndentLine } from '../src/index'; 8 | 9 | beforeAll(async () => 10 | { 11 | 12 | }); 13 | 14 | describe(`base`, () => 15 | { 16 | 17 | ([ 18 | [' at pkg\\index.ts:64:6'], 19 | ['\n'], 20 | [''], 21 | ] as [string, string?][]).forEach(input => { 22 | 23 | test(inspect(input[0]), () => 24 | { 25 | 26 | let actual = detectIndentLine(input[1] ?? input[0]); 27 | 28 | expect(actual).toMatchSnapshot(); 29 | 30 | }); 31 | 32 | }); 33 | 34 | }) 35 | 36 | describe(`no-break space`, () => 37 | { 38 | 39 | ([ 40 | ['\xa0 at pkg\\index.ts:64:6'], 41 | ['\xa0\n'], 42 | ['\xa0'], 43 | ] as [string, string?][]).forEach(input => 44 | { 45 | 46 | test(inspect(input[0]), () => 47 | { 48 | 49 | let actual = detectIndentLine(input[1] ?? input[0], { 50 | includeNoBreakSpace: true, 51 | }); 52 | 53 | expect(actual).toMatchSnapshot(); 54 | 55 | }); 56 | 57 | }); 58 | 59 | }) 60 | -------------------------------------------------------------------------------- /packages/string-indent/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "module": "NodeNext", 5 | "noEmit": true, 6 | "declaration": false, 7 | "noUnusedParameters": false, 8 | "allowUnusedLabels": true, 9 | "noUnusedLocals": false, 10 | "noPropertyAccessFromIndexSignature": false 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/string-indent/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@bluelovers/tsconfig/tsdx/index.json", 3 | "compilerOptions": { 4 | "importHelpers": true, 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/string-split-keep/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 mihop 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/string-split-keep/README.md: -------------------------------------------------------------------------------- 1 | # string-split-keep 2 | 3 | Split strings without applying separator after limit; Negative limit starts from the end. No regex separators. 4 | 5 | ```js 6 | var ssplit = require("string-split-keep") 7 | 8 | ssplit("word1 word2 word3", " ", 2) //["word1", "word2 word3"] 9 | ssplit("word1 word2 word3", " ", -2) //["word1 word2", "word3"] 10 | 11 | ``` 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /packages/string-split-keep/dist/index.cjs: -------------------------------------------------------------------------------- 1 | 2 | 'use strict' 3 | 4 | if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production') { 5 | module.exports = require('./index.cjs.development.cjs') 6 | } else { 7 | module.exports = require('./index.cjs.production.min.cjs') 8 | } 9 | -------------------------------------------------------------------------------- /packages/string-split-keep/dist/index.cjs.development.cjs: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | Object.defineProperty(exports, '__esModule', { value: true }); 4 | 5 | function stringSplitWithLimit(str, separator, limit) { 6 | if (!limit || separator === undefined) return str.split(separator, limit); 7 | if (!separator.length) return limit > 0 ? _splitStart_noSep(str, limit) : _splitEnd_noSep(str, -limit); 8 | return limit > 0 ? _splitStart(str, separator, limit, 0, []) : _splitEnd(str, separator, -limit, str.length, []); 9 | } 10 | function _splitStart_noSep(str, lim) { 11 | const ret = []; 12 | lim = Math.min(lim, str.length) - 1; 13 | for (let i = 0; i < lim; ++i) ret.push(str[i]); 14 | ret.push(str.slice(lim)); 15 | return ret; 16 | } 17 | function _splitEnd_noSep(str, lim) { 18 | const ret = []; 19 | lim = Math.min(lim, str.length); 20 | const firstSlice = str.length - lim + 1; 21 | ret.push(str.slice(0, firstSlice)); 22 | for (let i = firstSlice; i < str.length; ++i) ret.push(str[i]); 23 | return ret; 24 | } 25 | function _splitStart(str, sep, lim, cur, acc) { 26 | const index = str.indexOf(sep, cur); 27 | if (index === -1 || acc.length + 1 === lim) { 28 | acc.push(str.slice(cur)); 29 | return acc; 30 | } 31 | acc.push(str.slice(cur, index)); 32 | return _splitStart(str, sep, lim, index + sep.length, acc); 33 | } 34 | function _splitEnd(str, sep, lim, cur, acc) { 35 | const index = str.lastIndexOf(sep, cur); 36 | if (cur === -1 || index === -1 || acc.length + 1 === lim) { 37 | acc.unshift(str.slice(0, cur + 1)); 38 | return acc; 39 | } 40 | acc.unshift(str.slice(index + sep.length, cur + 1)); 41 | return _splitEnd(str, sep, lim, index - 1, acc); 42 | } 43 | 44 | exports._splitEnd = _splitEnd; 45 | exports._splitEnd_noSep = _splitEnd_noSep; 46 | exports._splitStart = _splitStart; 47 | exports._splitStart_noSep = _splitStart_noSep; 48 | exports.default = stringSplitWithLimit; 49 | exports.stringSplitWithLimit = stringSplitWithLimit; 50 | //# sourceMappingURL=index.cjs.development.cjs.map 51 | -------------------------------------------------------------------------------- /packages/string-split-keep/dist/index.cjs.production.min.cjs: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | function stringSplitWithLimit(t, i, n) { 4 | return n && void 0 !== i ? i.length ? n > 0 ? _splitStart(t, i, n, 0, []) : _splitEnd(t, i, -n, t.length, []) : n > 0 ? _splitStart_noSep(t, n) : _splitEnd_noSep(t, -n) : t.split(i, n); 5 | } 6 | 7 | function _splitStart_noSep(t, i) { 8 | const n = []; 9 | i = Math.min(i, t.length) - 1; 10 | for (let s = 0; s < i; ++s) n.push(t[s]); 11 | return n.push(t.slice(i)), n; 12 | } 13 | 14 | function _splitEnd_noSep(t, i) { 15 | const n = []; 16 | i = Math.min(i, t.length); 17 | const s = t.length - i + 1; 18 | n.push(t.slice(0, s)); 19 | for (let i = s; i < t.length; ++i) n.push(t[i]); 20 | return n; 21 | } 22 | 23 | function _splitStart(t, i, n, s, e) { 24 | const l = t.indexOf(i, s); 25 | return -1 === l || e.length + 1 === n ? (e.push(t.slice(s)), e) : (e.push(t.slice(s, l)), 26 | _splitStart(t, i, n, l + i.length, e)); 27 | } 28 | 29 | function _splitEnd(t, i, n, s, e) { 30 | const l = t.lastIndexOf(i, s); 31 | return -1 === s || -1 === l || e.length + 1 === n ? (e.unshift(t.slice(0, s + 1)), 32 | e) : (e.unshift(t.slice(l + i.length, s + 1)), _splitEnd(t, i, n, l - 1, e)); 33 | } 34 | 35 | Object.defineProperty(exports, "__esModule", { 36 | value: !0 37 | }), exports._splitEnd = _splitEnd, exports._splitEnd_noSep = _splitEnd_noSep, exports._splitStart = _splitStart, 38 | exports._splitStart_noSep = _splitStart_noSep, exports.default = stringSplitWithLimit, 39 | exports.stringSplitWithLimit = stringSplitWithLimit; 40 | //# sourceMappingURL=index.cjs.production.min.cjs.map 41 | -------------------------------------------------------------------------------- /packages/string-split-keep/dist/index.d.ts: -------------------------------------------------------------------------------- 1 | export declare function stringSplitWithLimit(str: string, separator?: string, limit?: number): string[]; 2 | export declare function _splitStart_noSep(str: string, lim: number): string[]; 3 | export declare function _splitEnd_noSep(str: string, lim: number): string[]; 4 | export declare function _splitStart(str: string, sep: string, lim: number, cur: number, acc: string[]): string[]; 5 | export declare function _splitEnd(str: string, sep: string, lim: number, cur: number, acc: string[]): string[]; 6 | 7 | export { 8 | stringSplitWithLimit as default, 9 | }; 10 | 11 | export {}; 12 | -------------------------------------------------------------------------------- /packages/string-split-keep/dist/index.esm.mjs: -------------------------------------------------------------------------------- 1 | function stringSplitWithLimit(t, n, i) { 2 | return i && void 0 !== n ? n.length ? i > 0 ? _splitStart(t, n, i, 0, []) : _splitEnd(t, n, -i, t.length, []) : i > 0 ? _splitStart_noSep(t, i) : _splitEnd_noSep(t, -i) : t.split(n, i); 3 | } 4 | 5 | function _splitStart_noSep(t, n) { 6 | const i = []; 7 | n = Math.min(n, t.length) - 1; 8 | for (let s = 0; s < n; ++s) i.push(t[s]); 9 | return i.push(t.slice(n)), i; 10 | } 11 | 12 | function _splitEnd_noSep(t, n) { 13 | const i = []; 14 | n = Math.min(n, t.length); 15 | const s = t.length - n + 1; 16 | i.push(t.slice(0, s)); 17 | for (let n = s; n < t.length; ++n) i.push(t[n]); 18 | return i; 19 | } 20 | 21 | function _splitStart(t, n, i, s, l) { 22 | const e = t.indexOf(n, s); 23 | return -1 === e || l.length + 1 === i ? (l.push(t.slice(s)), l) : (l.push(t.slice(s, e)), 24 | _splitStart(t, n, i, e + n.length, l)); 25 | } 26 | 27 | function _splitEnd(t, n, i, s, l) { 28 | const e = t.lastIndexOf(n, s); 29 | return -1 === s || -1 === e || l.length + 1 === i ? (l.unshift(t.slice(0, s + 1)), 30 | l) : (l.unshift(t.slice(e + n.length, s + 1)), _splitEnd(t, n, i, e - 1, l)); 31 | } 32 | 33 | export { _splitEnd, _splitEnd_noSep, _splitStart, _splitStart_noSep, stringSplitWithLimit as default, stringSplitWithLimit }; 34 | //# sourceMappingURL=index.esm.mjs.map 35 | -------------------------------------------------------------------------------- /packages/string-split-keep/src/index.ts: -------------------------------------------------------------------------------- 1 | "use strict" 2 | 3 | export function stringSplitWithLimit(str: string, separator?: string, limit?: number): string[] 4 | { 5 | if (!limit || separator === undefined) return str.split(separator, limit) 6 | if (!separator.length) return limit > 0 ? _splitStart_noSep(str, limit) : _splitEnd_noSep(str, -limit) 7 | return limit > 0 ? _splitStart(str, separator, limit, 0, []) : _splitEnd(str, separator, -limit, str.length, []) 8 | } 9 | 10 | export default stringSplitWithLimit 11 | 12 | export function _splitStart_noSep(str: string, lim: number) 13 | { 14 | const ret: string[] = []; 15 | lim = Math.min(lim, str.length) - 1 16 | for (let i = 0; i < lim; ++i) ret.push(str[i]) 17 | ret.push(str.slice(lim)) 18 | return ret 19 | } 20 | 21 | export function _splitEnd_noSep(str: string, lim: number) 22 | { 23 | const ret: string[] = []; 24 | lim = Math.min(lim, str.length) 25 | const firstSlice = str.length - lim + 1; 26 | ret.push(str.slice(0, firstSlice)) 27 | for (let i = firstSlice; i < str.length; ++i) ret.push(str[i]) 28 | return ret 29 | } 30 | 31 | export function _splitStart(str: string, sep: string, lim: number, cur: number, acc: string[]): string[] 32 | { 33 | const index = str.indexOf(sep, cur); 34 | if (index === -1 || acc.length + 1 === lim) 35 | { 36 | acc.push(str.slice(cur)) 37 | return acc 38 | } 39 | acc.push(str.slice(cur, index)) 40 | return _splitStart(str, sep, lim, index + sep.length, acc) 41 | } 42 | 43 | export function _splitEnd(str: string, sep: string, lim: number, cur: number, acc: string[]): string[] 44 | { 45 | const index = str.lastIndexOf(sep, cur); 46 | if (cur === -1 || index === -1 || acc.length + 1 === lim) 47 | { 48 | acc.unshift(str.slice(0, cur + 1)) 49 | return acc 50 | } 51 | acc.unshift(str.slice(index + sep.length, cur + 1)) 52 | return _splitEnd(str, sep, lim, index - 1, acc) 53 | } 54 | -------------------------------------------------------------------------------- /packages/string-split-keep/test/__root.ts: -------------------------------------------------------------------------------- 1 | import { join } from "path"; 2 | 3 | export const __root = join(__dirname, '..'); 4 | 5 | export const isWin = process.platform === "win32"; 6 | -------------------------------------------------------------------------------- /packages/string-split-keep/test/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "../tsconfig.json", 3 | "compilerOptions": { 4 | "module": "node12", 5 | "noEmit": true, 6 | "declaration": false, 7 | "noUnusedParameters": false, 8 | "allowUnusedLabels": true, 9 | "noUnusedLocals": false, 10 | "noPropertyAccessFromIndexSignature": false 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/string-split-keep/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@bluelovers/tsconfig/tsdx/index.json", 3 | "compilerOptions": { 4 | "importHelpers": true, 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /packages/uni-string/.npmignore: -------------------------------------------------------------------------------- 1 | /.pnp 2 | .pnp.js 3 | .idea 4 | ~ci.list.txt 5 | ~ci.log.txt 6 | ~ci.errors.txt 7 | *.stackdump 8 | *.bak 9 | *.old 10 | *.log 11 | tsconfig.json 12 | package-lock.json 13 | test 14 | .github 15 | .gitkeep 16 | /.*/ 17 | /.* 18 | tests 19 | /~* 20 | __test__ 21 | __tests__ 22 | node_modules 23 | /node_modules/ 24 | **/node_modules/ 25 | *.ts 26 | !*.d.ts 27 | /bin/**/*.d.ts 28 | /bin/*.d.ts 29 | 30 | !*.d.mts 31 | /bin/**/*.d.mts 32 | /bin/*.d.mts 33 | 34 | !*.d.cts 35 | /bin/**/*.d.cts 36 | /bin/*.d.cts 37 | 38 | !/src/**/*.ts 39 | !/src/**/*.cts 40 | !/src/**/*.mts 41 | !/src/**/*.tsx 42 | 43 | /src/**/*.d.ts 44 | /src/**/*.js 45 | /src/**/*.d.cts 46 | /src/**/*.d.mts 47 | /src/**/*.cjs 48 | /src/**/*.mjs 49 | /src/**/*.jsx 50 | 51 | *.tgz 52 | /tsconfig.json.tpl 53 | yarn-error.log 54 | .git 55 | yarn.lock 56 | .env.local 57 | .env.*.local 58 | npm-debug.log* 59 | yarn-debug.log* 60 | yarn-error.log* 61 | .vscode 62 | *.suo 63 | *.ntvs* 64 | *.njsproj 65 | *.sln 66 | *.sw? 67 | *.vue.js 68 | *.vue.d.ts 69 | *.vue.js.map 70 | .nyc_output 71 | coverage 72 | /*.tpl 73 | webpack.config.js 74 | vue.config.js 75 | /jestconfig.json 76 | /tslint.json 77 | .git 78 | webpack.*.config.js 79 | webpack.*.config.d.ts 80 | webpack.*.config.js.map 81 | webpack.*.config.ts 82 | karma.conf.js 83 | /_config.yml 84 | intellij-style-guide.xml 85 | jest.config.js 86 | *.tsbuildinfo 87 | tsconfig.*.json 88 | tsconfig.esm.json.tpl 89 | /package.d.ts 90 | .mocharc.yml 91 | jest.config.js 92 | jest.config.* 93 | /jest-preset.* 94 | /report.*.json 95 | now.json 96 | /Makefile 97 | *.spec.d.ts 98 | *.spec.js 99 | *.spec.ts 100 | 101 | *.spec.d.cts 102 | *.spec.cjs 103 | *.spec.cts 104 | 105 | *.spec.d.mts 106 | *.spec.mjs 107 | *.spec.mts 108 | 109 | *.spec.d.tsx 110 | *.spec.tsx 111 | 112 | __mocks__ 113 | __tests__ 114 | __snapshots__ 115 | *.snap 116 | npm-shrinkwrap.json 117 | /example/ 118 | *.stat 119 | .vercel 120 | tsdx.config.js 121 | /report.json 122 | 123 | /_*/ 124 | _snowpack 125 | 126 | /snowpack.config.js 127 | web_modules 128 | cz-adapter 129 | 130 | tsc-multi.json.tpl 131 | tsc-multi.json 132 | 133 | changelog-option.js 134 | 135 | bin/tsconfig.json 136 | bin/tsconfig.*.json 137 | 138 | .yarnrc.yml 139 | .turbo 140 | __file_snapshots__ 141 | __fixtures__ 142 | /fixture/ 143 | -------------------------------------------------------------------------------- /packages/uni-string/README.md: -------------------------------------------------------------------------------- 1 | # uni-string 2 | 3 | > Unicode-aware String object 4 | 5 | `npm install uni-string` 6 | 7 | ## api 8 | 9 | * see [API](src/core.d.ts) 10 | * [MDN String](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String) 11 | 12 | ## demo 13 | 14 | ```ts 15 | import UString from 'packages/uni-string/src/index'; 16 | 17 | const UString = require('packages/uni-string/src/index') 18 | ``` 19 | 20 | ```ts 21 | console.log(UString.support); 22 | 23 | let t = (new UString('♥️𠬠典')).padStart(10, '𠬠'); 24 | 25 | t = t.concat('\n♥️𠬠典そこで彼らは\'",オリーブ山と呼ばれる山からエルサレムに帰った。'); 26 | 27 | console.dir(t); 28 | 29 | let t2 = new UString(t); 30 | 31 | console.log(t2); 32 | 33 | //console.log(666, t2.substr(-9, 3)); 34 | console.log(666, t2.indexOf('𠬠典', 2)); 35 | console.log(666, t2.endsWith('𠬠典')); 36 | 37 | let t3 = new UString('👩‍👩‍👧‍👦'); 38 | console.log(t3.size(), t3.split('')); 39 | ``` 40 | 41 | ```ts 42 | console.log('length', t2.length); 43 | console.log('charLength', t2.charLength); 44 | console.log('size()', t2.size()); 45 | 46 | //length 70 47 | //charLength 49 48 | //size() 49 49 | ``` 50 | 51 | ## UString.support 52 | 53 | ```ts 54 | { 55 | split: true, 56 | substr: true, 57 | substring: true, 58 | indexOf: true, 59 | includes: true, 60 | slice: true, 61 | charAt: true, 62 | startsWith: true, 63 | endsWith: true, 64 | padEnd: true, 65 | padStart: true } 66 | ``` 67 | -------------------------------------------------------------------------------- /packages/uni-string/dist/index.cjs: -------------------------------------------------------------------------------- 1 | 2 | 'use strict' 3 | 4 | if (typeof process !== 'undefined' && process.env.NODE_ENV !== 'production') { 5 | module.exports = require('./index.cjs.development.cjs') 6 | } else { 7 | module.exports = require('./index.cjs.production.min.cjs') 8 | } 9 | -------------------------------------------------------------------------------- /packages/uni-string/src/index.cts: -------------------------------------------------------------------------------- 1 | // @ts-ignore 2 | import { UString } from './index.ts'; 3 | // @ts-ignore 4 | export = UString; 5 | -------------------------------------------------------------------------------- /packages/uni-string/test/demo.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2018/3/16/016. 3 | */ 4 | 5 | import UString from '../src'; 6 | 7 | console.log(UString.support); 8 | 9 | let t = (new UString('♥️𠬠典')).padStart(10, '𠬠'); 10 | 11 | t = t.concat('\n♥️𠬠典そこで彼らは\'"\'👩‍👩‍👧‍👦\',オリーブ山と呼ばれる山からエルサレムに帰った。'); 12 | 13 | console.dir(t); 14 | 15 | let t2 = new UString(t); 16 | 17 | console.log('length', t2.length); 18 | console.log('charLength', t2.charLength); 19 | console.log('size()', t2.size()); 20 | 21 | console.log(t2); 22 | 23 | //console.log(666, t2.substr(-9, 3)); 24 | console.log(666, t2.indexOf('𠬠典', 2)); 25 | console.log(666, t2.endsWith('𠬠典')); 26 | 27 | 28 | let t3 = new UString('👩‍👩‍👧‍👦'); 29 | console.log(t3.size(), t3.split('')); 30 | -------------------------------------------------------------------------------- /packages/uni-string/test/unsafe.spec.ts: -------------------------------------------------------------------------------- 1 | import UString from '../src'; 2 | import { unsafeChinese } from 'cjk-conv/lib/zh/data/unsafe'; 3 | 4 | const unsafeChineseString = unsafeChinese.join(''); 5 | 6 | describe(`unsafe chinese, every thing should not change`, () => 7 | { 8 | 9 | unsafeChinese 10 | .forEach((input) => 11 | { 12 | 13 | // @ts-ignore 14 | it(` ${input} `, () => 15 | { 16 | let sc = new UString(input); 17 | 18 | let actual = input.codePointAt(0); 19 | let expected = String.fromCodePoint(actual); 20 | 21 | expect(sc.size()).toBe(1); 22 | 23 | expect(input).toEqual(expected) 24 | 25 | }); 26 | 27 | }) 28 | ; 29 | 30 | }) 31 | 32 | it(`unsafeChineseString`, () => 33 | { 34 | 35 | let sc = new UString(unsafeChineseString).split(''); 36 | 37 | expect(sc).toHaveLength(unsafeChinese.length); 38 | 39 | // @ts-ignore 40 | expect(sc.sort()).toEqual(unsafeChinese.sort()) 41 | 42 | }) 43 | -------------------------------------------------------------------------------- /packages/uni-string/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@bluelovers/tsconfig/tsdx/index.json", 3 | "compilerOptions": { 4 | "importHelpers": true, 5 | "noUnusedParameters": false, 6 | "noUnusedLocals": false, 7 | "skipLibCheck": true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /packages/zero-width/.eslintignore: -------------------------------------------------------------------------------- 1 | 2 | 3 | /test/ 4 | __test__ 5 | __tests__ 6 | node_modules 7 | /node_modules/ 8 | **/node_modules/ 9 | tests 10 | .idea 11 | .nyc_output 12 | coverage 13 | 14 | *.js 15 | *.d.ts 16 | 17 | *.spec.js 18 | *.test.js 19 | 20 | *.spec.ts 21 | *.test.ts 22 | 23 | bin/**/* 24 | 25 | *.tsbuildinfo 26 | 27 | -------------------------------------------------------------------------------- /packages/zero-width/.npmignore: -------------------------------------------------------------------------------- 1 | /.pnp 2 | .pnp.js 3 | .idea 4 | ~ci.list.txt 5 | ~ci.log.txt 6 | ~ci.errors.txt 7 | *.stackdump 8 | *.bak 9 | *.old 10 | *.log 11 | tsconfig.json 12 | package-lock.json 13 | test 14 | .github 15 | .gitkeep 16 | /.*/ 17 | /.* 18 | tests 19 | /~* 20 | __test__ 21 | __tests__ 22 | node_modules 23 | /node_modules/ 24 | **/node_modules/ 25 | *.ts 26 | !*.d.ts 27 | /bin/**/*.d.ts 28 | /bin/*.d.ts 29 | 30 | !*.d.mts 31 | /bin/**/*.d.mts 32 | /bin/*.d.mts 33 | 34 | !*.d.cts 35 | /bin/**/*.d.cts 36 | /bin/*.d.cts 37 | 38 | !/src/**/*.ts 39 | !/src/**/*.cts 40 | !/src/**/*.mts 41 | !/src/**/*.tsx 42 | 43 | /src/**/*.d.ts 44 | /src/**/*.js 45 | /src/**/*.d.cts 46 | /src/**/*.d.mts 47 | /src/**/*.cjs 48 | /src/**/*.mjs 49 | /src/**/*.jsx 50 | 51 | *.tgz 52 | /tsconfig.json.tpl 53 | yarn-error.log 54 | .git 55 | yarn.lock 56 | .env.local 57 | .env.*.local 58 | npm-debug.log* 59 | yarn-debug.log* 60 | yarn-error.log* 61 | .vscode 62 | *.suo 63 | *.ntvs* 64 | *.njsproj 65 | *.sln 66 | *.sw? 67 | *.vue.js 68 | *.vue.d.ts 69 | *.vue.js.map 70 | .nyc_output 71 | coverage 72 | /*.tpl 73 | webpack.config.js 74 | vue.config.js 75 | /jestconfig.json 76 | /tslint.json 77 | .git 78 | webpack.*.config.js 79 | webpack.*.config.d.ts 80 | webpack.*.config.js.map 81 | webpack.*.config.ts 82 | karma.conf.js 83 | /_config.yml 84 | intellij-style-guide.xml 85 | jest.config.js 86 | *.tsbuildinfo 87 | tsconfig.*.json 88 | tsconfig.esm.json.tpl 89 | /package.d.ts 90 | .mocharc.yml 91 | jest.config.js 92 | jest.config.* 93 | /jest-preset.* 94 | /report.*.json 95 | now.json 96 | /Makefile 97 | *.spec.d.ts 98 | *.spec.js 99 | *.spec.ts 100 | 101 | *.spec.d.cts 102 | *.spec.cjs 103 | *.spec.cts 104 | 105 | *.spec.d.mts 106 | *.spec.mjs 107 | *.spec.mts 108 | 109 | *.spec.d.tsx 110 | *.spec.tsx 111 | 112 | __mocks__ 113 | __tests__ 114 | __snapshots__ 115 | *.snap 116 | npm-shrinkwrap.json 117 | /example/ 118 | *.stat 119 | .vercel 120 | tsdx.config.js 121 | /report.json 122 | 123 | /_*/ 124 | _snowpack 125 | 126 | /snowpack.config.js 127 | web_modules 128 | cz-adapter 129 | 130 | tsc-multi.json.tpl 131 | tsc-multi.json 132 | 133 | changelog-option.js 134 | 135 | bin/tsconfig.json 136 | bin/tsconfig.*.json 137 | 138 | .yarnrc.yml 139 | .turbo 140 | __file_snapshots__ 141 | __fixtures__ 142 | /fixture/ 143 | -------------------------------------------------------------------------------- /packages/zero-width/README.md: -------------------------------------------------------------------------------- 1 | # README.md 2 | 3 | remove zero-width and some other util about space 4 | 5 | ## install 6 | 7 | ``` 8 | yarn add zero-width 9 | ``` 10 | 11 | ```ts 12 | let os = [ 13 | '\udb40\udd00\n\r\b\t\v\u00a0  \u0009', 14 | ENUM_ZERO_WIDTH.SPACE, 15 | ENUM_ZERO_WIDTH.NO_BREAK_SPACE, 16 | ENUM_ZERO_WIDTH.RIGHT_TO_LEFT_MARK, 17 | ENUM_ZERO_WIDTH.LEFT_TO_RIGHT_MARK, 18 | ].join(''); 19 | 20 | let ns = removeZeroWidth(os); 21 | 22 | console.dir({ 23 | os, 24 | ns, 25 | os_len: os.length, 26 | ns_len: ns.length, 27 | }); 28 | ``` 29 | 30 | => 31 | 32 | ```json5 33 | { 34 | os: '󠄀\n\r\b\t\u000b  \t', 35 | ns: '\n\r\b\t\u000b  \t', 36 | os_len: 15, 37 | ns_len: 9 38 | } 39 | ``` 40 | -------------------------------------------------------------------------------- /packages/zero-width/index.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2020/6/6. 3 | */ 4 | export * from './lib'; 5 | import { removeZeroWidth } from './lib'; 6 | export default removeZeroWidth; 7 | -------------------------------------------------------------------------------- /packages/zero-width/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * Created by user on 2020/6/6. 4 | */ 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | const tslib_1 = require("tslib"); 7 | tslib_1.__exportStar(require("./lib"), exports); 8 | const lib_1 = require("./lib"); 9 | exports.default = lib_1.removeZeroWidth; 10 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /packages/zero-width/index.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2020/6/6. 3 | */ 4 | 5 | export * from './lib'; 6 | import { removeZeroWidth } from './lib'; 7 | 8 | export default removeZeroWidth 9 | -------------------------------------------------------------------------------- /packages/zero-width/lib/index.d.ts: -------------------------------------------------------------------------------- 1 | export declare function existsZeroWidth(str: string): boolean; 2 | export declare function removeVariationSelectors(str: string): string; 3 | export declare function removeZeroWidth(str: string, unsafe?: boolean): string; 4 | export declare function trimWithZeroWidth(str: string): string; 5 | export declare function removeBom(str: string, unsafe?: boolean): string; 6 | export declare function nbspToSpace(str: string): string; 7 | export default removeZeroWidth; 8 | -------------------------------------------------------------------------------- /packages/zero-width/lib/index.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.nbspToSpace = exports.removeBom = exports.trimWithZeroWidth = exports.removeZeroWidth = exports.removeVariationSelectors = exports.existsZeroWidth = void 0; 4 | const re_1 = require("./re"); 5 | function existsZeroWidth(str) { 6 | return re_1.reZeroWidthAll.test(str); 7 | } 8 | exports.existsZeroWidth = existsZeroWidth; 9 | function removeVariationSelectors(str) { 10 | return str.replace(re_1.reVariationSelectorsAll, ''); 11 | } 12 | exports.removeVariationSelectors = removeVariationSelectors; 13 | function removeZeroWidth(str, unsafe) { 14 | if (unsafe) { 15 | return str.replace(re_1.reZeroWidthAll, ''); 16 | } 17 | return str 18 | .replace(re_1.reZeroWidthAllSafe, ''); 19 | } 20 | exports.removeZeroWidth = removeZeroWidth; 21 | function trimWithZeroWidth(str) { 22 | return str 23 | .replace(re_1.reZeroWidthTrim, ''); 24 | } 25 | exports.trimWithZeroWidth = trimWithZeroWidth; 26 | function removeBom(str, unsafe) { 27 | if (unsafe) { 28 | return str.replace(re_1.reBomUnsafe, ''); 29 | } 30 | return str.replace(re_1.reBomStrict, ''); 31 | } 32 | exports.removeBom = removeBom; 33 | function nbspToSpace(str) { 34 | return str.replace(re_1.reNBSP, " " /* ENUM_SPACE.SPACE */); 35 | } 36 | exports.nbspToSpace = nbspToSpace; 37 | exports.default = removeZeroWidth; 38 | //# sourceMappingURL=index.js.map -------------------------------------------------------------------------------- /packages/zero-width/lib/index.ts: -------------------------------------------------------------------------------- 1 | import { 2 | reBomStrict, 3 | reBomUnsafe, 4 | reNBSP, 5 | reVariationSelectorsAll, 6 | reZeroWidthAll, reZeroWidthAllSafe, 7 | reZeroWidthTrim, 8 | } from './re'; 9 | import { ENUM_SPACE } from './const'; 10 | 11 | export function existsZeroWidth(str: string) 12 | { 13 | return reZeroWidthAll.test(str) 14 | } 15 | 16 | export function removeVariationSelectors(str: string) 17 | { 18 | return str.replace(reVariationSelectorsAll, '') 19 | } 20 | 21 | export function removeZeroWidth(str: string, unsafe?: boolean) 22 | { 23 | if (unsafe) 24 | { 25 | return str.replace(reZeroWidthAll, '') 26 | } 27 | 28 | return str 29 | .replace(reZeroWidthAllSafe, '') 30 | ; 31 | } 32 | 33 | export function trimWithZeroWidth(str: string) 34 | { 35 | return str 36 | .replace(reZeroWidthTrim, '') 37 | ; 38 | } 39 | 40 | export function removeBom(str: string, unsafe?: boolean) 41 | { 42 | if (unsafe) 43 | { 44 | return str.replace(reBomUnsafe, '') 45 | } 46 | 47 | return str.replace(reBomStrict, '') 48 | } 49 | 50 | export function nbspToSpace(str: string) 51 | { 52 | return str.replace(reNBSP, ENUM_SPACE.SPACE) 53 | } 54 | 55 | export default removeZeroWidth 56 | -------------------------------------------------------------------------------- /packages/zero-width/lib/re.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * do not edit this file 3 | * source file at test/scripts/src 4 | */ 5 | export declare const reVariationSelectors: RegExp; 6 | export declare const reVariationSelectorsSupplement: RegExp; 7 | export declare const reVariationSelectorsAll: RegExp; 8 | export declare const reZeroWidth: RegExp; 9 | export declare const reZeroWidth2: RegExp; 10 | export declare const reZeroWidthAllSafe: RegExp; 11 | export declare const reZeroWidthAll: RegExp; 12 | export declare const reNBSP: RegExp; 13 | export declare const reNewLine: RegExp; 14 | export declare const reRegExpSpaceWithoutNewLine: RegExp; 15 | export declare const reRegExpSpaceWithoutNewLinePlus: RegExp; 16 | export declare const reRegExpSpace: RegExp; 17 | export declare const reRegExpSpacePlus: RegExp; 18 | export declare const reControlCodes: RegExp; 19 | export declare const reZeroWidthWithSpaceWithoutNewLine: RegExp; 20 | export declare const reZeroWidthWithSpace: RegExp; 21 | export declare const _reZeroWidthTrimWithoutNewLine: RegExp; 22 | export declare const _reZeroWidthTrim: RegExp; 23 | export declare const reZeroWidthTrimWithoutNewLine: RegExp; 24 | export declare const reZeroWidthTrim: RegExp; 25 | export declare const reBomStrict: RegExp; 26 | export declare const reBomUnsafe: RegExp; 27 | -------------------------------------------------------------------------------- /packages/zero-width/lib/stat.d.ts: -------------------------------------------------------------------------------- 1 | export declare function reportZeroWidth(str: string): Record; 2 | export declare function reportZeroWidthWithSpace(str: string): Record; 3 | /** 4 | * @private 5 | */ 6 | export declare function _report(str: string, re: RegExp): Record; 7 | export declare function _toKey(k: string): string; 8 | export default reportZeroWidthWithSpace; 9 | -------------------------------------------------------------------------------- /packages/zero-width/lib/stat.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports._toKey = exports._report = exports.reportZeroWidthWithSpace = exports.reportZeroWidth = void 0; 4 | const regexp_helper_core_1 = require("regexp-helper-core"); 5 | const re_1 = require("./re"); 6 | function reportZeroWidth(str) { 7 | return _report(str, re_1.reZeroWidthAll); 8 | } 9 | exports.reportZeroWidth = reportZeroWidth; 10 | function reportZeroWidthWithSpace(str) { 11 | return _report(str, re_1.reZeroWidthWithSpace); 12 | } 13 | exports.reportZeroWidthWithSpace = reportZeroWidthWithSpace; 14 | /** 15 | * @private 16 | */ 17 | function _report(str, re) { 18 | let stat = {}; 19 | str.replace(re, (s) => { 20 | stat[s] = (stat[s] |= 0) + 1; 21 | return ''; 22 | }); 23 | stat = Object.entries(stat) 24 | .reduce((a, [k, n]) => { 25 | a[_toKey(k)] = n; 26 | return a; 27 | }, {}); 28 | return stat; 29 | } 30 | exports._report = _report; 31 | function _toKey(k) { 32 | let k2; 33 | switch (k) { 34 | case "\t" /* ENUM_SPACE.TAB */: 35 | k2 = '\\t'; 36 | break; 37 | case "\v" /* ENUM_SPACE.VERTICAL_TABULATION */: 38 | k2 = '\\v'; 39 | break; 40 | case "\n" /* ENUM_SPACE.NEW_LINE */: 41 | k2 = '\\n'; 42 | break; 43 | case "\r" /* ENUM_SPACE.CARRIAGE_RETURN */: 44 | k2 = '\\r'; 45 | break; 46 | default: 47 | k2 = (0, regexp_helper_core_1.unicodeEscape)(k, null, null, true); 48 | break; 49 | } 50 | if (k2 === k) { 51 | try { 52 | k2 = new RegExp(k, 'u').source; 53 | } 54 | catch (e) { 55 | } 56 | } 57 | return k2; 58 | } 59 | exports._toKey = _toKey; 60 | exports.default = reportZeroWidthWithSpace; 61 | //# sourceMappingURL=stat.js.map -------------------------------------------------------------------------------- /packages/zero-width/lib/stat.ts: -------------------------------------------------------------------------------- 1 | import { unicodeEscape, toHex } from 'regexp-helper-core'; 2 | import { reVariationSelectorsAll, reZeroWidthAll, reZeroWidthWithSpace } from './re'; 3 | import { ENUM_SPACE } from './const'; 4 | 5 | export function reportZeroWidth(str: string) 6 | { 7 | return _report(str, reZeroWidthAll); 8 | } 9 | 10 | export function reportZeroWidthWithSpace(str: string) 11 | { 12 | return _report(str, reZeroWidthWithSpace); 13 | } 14 | 15 | /** 16 | * @private 17 | */ 18 | export function _report(str: string, re: RegExp) 19 | { 20 | let stat = {} as Record; 21 | 22 | str.replace(re, (s) => { 23 | 24 | stat[s] = (stat[s] |= 0) + 1; 25 | 26 | return ''; 27 | }); 28 | 29 | stat = Object.entries(stat) 30 | .reduce((a, [k, n]) => { 31 | a[_toKey(k)] = n; 32 | return a; 33 | }, {}) 34 | ; 35 | 36 | return stat; 37 | } 38 | 39 | export function _toKey(k: string) 40 | { 41 | let k2: string; 42 | 43 | switch (k) 44 | { 45 | case ENUM_SPACE.TAB: 46 | k2 = '\\t'; 47 | break; 48 | case ENUM_SPACE.VERTICAL_TABULATION: 49 | k2 = '\\v'; 50 | break; 51 | case ENUM_SPACE.NEW_LINE: 52 | k2 = '\\n'; 53 | break; 54 | case ENUM_SPACE.CARRIAGE_RETURN: 55 | k2 = '\\r'; 56 | break; 57 | default: 58 | k2 = unicodeEscape(k, null, null, true); 59 | break; 60 | } 61 | 62 | if (k2 === k) 63 | { 64 | try 65 | { 66 | k2 = new RegExp(k, 'u').source 67 | } 68 | catch (e) 69 | { 70 | 71 | } 72 | } 73 | 74 | return k2 75 | } 76 | 77 | export default reportZeroWidthWithSpace 78 | -------------------------------------------------------------------------------- /packages/zero-width/lib/util.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2019/8/12. 3 | */ 4 | /** 5 | * simple merge, not real regexp merge 6 | * @private 7 | */ 8 | export declare function _regexpMerge(re: (string | RegExp)[]): RegExp; 9 | -------------------------------------------------------------------------------- /packages/zero-width/lib/util.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * Created by user on 2019/8/12. 4 | */ 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | exports._regexpMerge = void 0; 7 | /** 8 | * simple merge, not real regexp merge 9 | * @private 10 | */ 11 | function _regexpMerge(re) { 12 | return new RegExp('[' + re.map(r => (typeof r === 'string' ? r : r.source).replace(/^\[/, '').replace(/\]$/, '')) 13 | .join('') + ']', 'ug'); 14 | } 15 | exports._regexpMerge = _regexpMerge; 16 | //# sourceMappingURL=util.js.map -------------------------------------------------------------------------------- /packages/zero-width/lib/util.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2019/8/12. 3 | */ 4 | 5 | /** 6 | * simple merge, not real regexp merge 7 | * @private 8 | */ 9 | export function _regexpMerge(re: (string | RegExp)[]) 10 | { 11 | return new RegExp('[' + re.map(r => (typeof r === 'string' ? r : r.source).replace(/^\[/, '').replace(/\]$/, '')) 12 | .join('') + ']', 'ug') 13 | } 14 | -------------------------------------------------------------------------------- /packages/zero-width/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "zero-width", 3 | "version": "1.0.29", 4 | "description": "remove zero-width and some other util about space", 5 | "keywords": [ 6 | "check", 7 | "es2018", 8 | "esnext", 9 | "flag", 10 | "flags", 11 | "helper", 12 | "is", 13 | "pattern", 14 | "re", 15 | "regex", 16 | "regexp", 17 | "regular expression", 18 | "space", 19 | "support", 20 | "supported", 21 | "unicode", 22 | "util", 23 | "valid", 24 | "variation-selectors", 25 | "zero-width" 26 | ], 27 | "homepage": "https://github.com/bluelovers/ws-string/tree/master/packages/zero-width#readme", 28 | "bugs": { 29 | "url": "https://github.com/bluelovers/ws-string/issues" 30 | }, 31 | "repository": { 32 | "type": "git", 33 | "url": "git+https://github.com/bluelovers/ws-string.git", 34 | "directory": "packages/zero-width" 35 | }, 36 | "license": "ISC", 37 | "author": "bluelovers", 38 | "main": "index.js", 39 | "directories": { 40 | "lib": "lib", 41 | "test": "test" 42 | }, 43 | "scripts": { 44 | "coverage": "yarn run test -- --coverage", 45 | "pretest": "yarn run build", 46 | "test": "jest", 47 | "test:jest": "jest --passWithNoTests", 48 | "test:jest:coverage": "yarn run test:jest -- --coverage", 49 | "test:jest:snapshot": "yarn run test:jest -- -u", 50 | "test:snapshot": "yarn run test -- -u", 51 | "test:tsd": "ynpx tsd", 52 | "build": "ts-node test/scripts/build-re.ts && ynpx build-ts-file -- ./lib/re.ts", 53 | "npm:publish": "npm publish", 54 | "npm:publish:lerna": "npx lerna publish --yes --cd-version patch", 55 | "preversion": "yarn run test", 56 | "prepublish:lockfile": "npx sync-lockfile .", 57 | "postpublish": "yarn run postpublishOnly:add", 58 | "postpublish_": "git commit -m \"chore(release): publish\" .", 59 | "postpublishOnly:add": "npx yarn-tool root run postpublishOnly:add zero-width", 60 | "ncu": "npx yarn-tool ncu -u", 61 | "sort-package-json": "npx yarn-tool sort", 62 | "tsc:showConfig": "ynpx get-current-tsconfig -p" 63 | }, 64 | "dependencies": { 65 | "regexp-helper-core": "^2.0.8", 66 | "tslib": "^2" 67 | }, 68 | "gitHead": "952f3f53bed3e2bf3ccaec50c46702f127ff4e7f" 69 | } 70 | -------------------------------------------------------------------------------- /packages/zero-width/test/scripts/build-re.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2019/8/12. 3 | */ 4 | 5 | import * as reSource from './src/re'; 6 | import regexpClassToObject from 'regexp-class-to-regenerate'; 7 | import fs from 'fs-extra'; 8 | import path from 'path'; 9 | 10 | let data = Object.entries(reSource) 11 | // @ts-ignore 12 | .reduce((a, [k, v]: [keyof typeof reSource, RegExp]) => { 13 | 14 | if (v instanceof RegExp) 15 | { 16 | try 17 | { 18 | // @ts-ignore 19 | a[k] = regexpClassToObject(v).toRegExp(); 20 | } 21 | catch (e) 22 | { 23 | console.warn({ 24 | k, 25 | v, 26 | message: e.message, 27 | }); 28 | 29 | a[k] = v; 30 | } 31 | } 32 | 33 | return a 34 | }, {} as Record); 35 | 36 | 37 | let txt = Object.entries(data) 38 | // @ts-ignore 39 | .map(([k, v]: [keyof typeof reSource, RegExp]) => { 40 | return `export const ${k} = ${v.toString()};`; 41 | }).join('\n\n'); 42 | 43 | let notice = `/** 44 | * do not edit this file 45 | * source file at test/scripts/src 46 | */`; 47 | 48 | fs.outputFileSync(path.join(__dirname, '../..', 'lib', 're.ts'), `${notice}\n\n${txt}\n\n`); 49 | 50 | -------------------------------------------------------------------------------- /script/run/postpublish-add.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2020/5/11. 3 | */ 4 | export {}; 5 | -------------------------------------------------------------------------------- /script/run/postpublish-add.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * Created by user on 2020/5/11. 4 | */ 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | const tslib_1 = require("tslib"); 7 | const add_to_postpublish_task_1 = require("../util/add-to-postpublish-task"); 8 | const logger_1 = tslib_1.__importDefault(require("debug-color2/logger")); 9 | let argv = process.argv.slice(2); 10 | logger_1.default.dir(argv); 11 | if (argv.length) { 12 | argv.forEach(module_name => (0, add_to_postpublish_task_1.add)(module_name)); 13 | } 14 | //# sourceMappingURL=postpublish-add.js.map -------------------------------------------------------------------------------- /script/run/postpublish-add.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2020/5/11. 3 | */ 4 | 5 | import { add } from "../util/add-to-postpublish-task" 6 | import console from 'debug-color2/logger' 7 | 8 | let argv = process.argv.slice(2); 9 | 10 | console.dir(argv) 11 | 12 | if (argv.length) 13 | { 14 | argv.forEach(module_name => add(module_name)); 15 | } 16 | -------------------------------------------------------------------------------- /script/run/postpublish-subtree.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2020/5/11. 3 | */ 4 | export {}; 5 | -------------------------------------------------------------------------------- /script/run/postpublish-subtree.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | /** 3 | * Created by user on 2020/5/11. 4 | */ 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | const tslib_1 = require("tslib"); 7 | const bluebird_1 = tslib_1.__importDefault(require("@bluelovers/fast-glob/bluebird")); 8 | const path_1 = require("path"); 9 | const __root_ws_1 = tslib_1.__importDefault(require("../../__root_ws")); 10 | const fs_extra_1 = require("fs-extra"); 11 | const git_subtree_push_1 = require("../util/git-subtree-push"); 12 | bluebird_1.default 13 | .async([ 14 | '**/*', 15 | ], { 16 | cwd: (0, path_1.join)(__root_ws_1.default, 'temp', 'subtree'), 17 | absolute: true, 18 | }) 19 | .map(file => (0, fs_extra_1.readFile)(file, 'utf8')) 20 | .mapSeries(async (module_name) => { 21 | return (0, git_subtree_push_1.gitSubtreePush)(module_name); 22 | }); 23 | //# sourceMappingURL=postpublish-subtree.js.map -------------------------------------------------------------------------------- /script/run/postpublish-subtree.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2020/5/11. 3 | */ 4 | 5 | import FastGlob from '@bluelovers/fast-glob/bluebird'; 6 | import { join } from "path"; 7 | import __root_ws from '../../__root_ws'; 8 | import { readFile } from 'fs-extra'; 9 | import console from 'debug-color2/logger' 10 | import { gitSubtreePush } from '../util/git-subtree-push'; 11 | 12 | FastGlob 13 | .async([ 14 | '**/*', 15 | ], { 16 | cwd: join(__root_ws, 'temp', 'subtree'), 17 | absolute: true, 18 | }) 19 | .map(file => readFile(file, 'utf8')) 20 | .mapSeries(async (module_name) => 21 | { 22 | return gitSubtreePush(module_name) 23 | }) 24 | ; 25 | -------------------------------------------------------------------------------- /script/util/add-to-postpublish-task.d.ts: -------------------------------------------------------------------------------- 1 | export declare function name(name: string): string; 2 | export declare function add(module_name: string): void; 3 | export declare function del(module_name: string): void; 4 | export default add; 5 | -------------------------------------------------------------------------------- /script/util/add-to-postpublish-task.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.del = exports.add = exports.name = void 0; 4 | const tslib_1 = require("tslib"); 5 | const fs_extra_1 = require("fs-extra"); 6 | const debug_color2_1 = tslib_1.__importDefault(require("debug-color2")); 7 | const create_cache_name_1 = tslib_1.__importDefault(require("./create-cache-name")); 8 | function name(name) { 9 | return (0, create_cache_name_1.default)('subtree', `${name}`); 10 | } 11 | exports.name = name; 12 | function add(module_name) { 13 | let file = name(module_name); 14 | debug_color2_1.default.debug(`[subtree:script]`, `add`, module_name); 15 | (0, fs_extra_1.outputFileSync)(file, module_name); 16 | } 17 | exports.add = add; 18 | function del(module_name) { 19 | let file = name(module_name); 20 | debug_color2_1.default.debug(`[subtree:script]`, `del`, module_name); 21 | (0, fs_extra_1.unlinkSync)(file); 22 | } 23 | exports.del = del; 24 | exports.default = add; 25 | //# sourceMappingURL=add-to-postpublish-task.js.map -------------------------------------------------------------------------------- /script/util/add-to-postpublish-task.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2020/5/11. 3 | */ 4 | import __root_ws from '../../__root_ws'; 5 | import { join } from 'path'; 6 | import { outputFileSync, ensureFileSync, unlinkSync } from 'fs-extra'; 7 | import console from 'debug-color2'; 8 | import createCacheName from './create-cache-name'; 9 | 10 | export function name(name: string) 11 | { 12 | return createCacheName('subtree', `${name}`) 13 | } 14 | 15 | export function add(module_name: string) 16 | { 17 | let file = name(module_name); 18 | console.debug(`[subtree:script]`, `add`, module_name); 19 | outputFileSync(file, module_name); 20 | } 21 | 22 | export function del(module_name: string) 23 | { 24 | let file = name(module_name); 25 | console.debug(`[subtree:script]`, `del`, module_name); 26 | unlinkSync(file); 27 | } 28 | 29 | export default add 30 | -------------------------------------------------------------------------------- /script/util/create-cache-name.d.ts: -------------------------------------------------------------------------------- 1 | export declare function createCacheName(prefixPath: string, name: string): string; 2 | export default createCacheName; 3 | -------------------------------------------------------------------------------- /script/util/create-cache-name.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.createCacheName = void 0; 4 | const tslib_1 = require("tslib"); 5 | const path_1 = require("path"); 6 | const __root_ws_1 = tslib_1.__importDefault(require("../../__root_ws")); 7 | function createCacheName(prefixPath, name) { 8 | name = name 9 | .replace(/[^\-_\w\d]/g, '__'); 10 | return (0, path_1.join)(__root_ws_1.default, 'temp', prefixPath, `${name}`); 11 | } 12 | exports.createCacheName = createCacheName; 13 | exports.default = createCacheName; 14 | //# sourceMappingURL=create-cache-name.js.map -------------------------------------------------------------------------------- /script/util/create-cache-name.ts: -------------------------------------------------------------------------------- 1 | import { join } from "path"; 2 | import __root_ws from '../../__root_ws'; 3 | 4 | export function createCacheName(prefixPath: string, name: string) 5 | { 6 | name = name 7 | .replace(/[^\-_\w\d]/g, '__') 8 | ; 9 | 10 | return join(__root_ws, 'temp', prefixPath, `${name}`) 11 | } 12 | 13 | export default createCacheName 14 | -------------------------------------------------------------------------------- /script/util/git-subtree-push.d.ts: -------------------------------------------------------------------------------- 1 | export declare function gitSubtreePush(module_name: 'runes2' | string): Promise; 2 | -------------------------------------------------------------------------------- /script/util/git-subtree-push.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | Object.defineProperty(exports, "__esModule", { value: true }); 3 | exports.gitSubtreePush = void 0; 4 | const tslib_1 = require("tslib"); 5 | const logger_1 = tslib_1.__importDefault(require("debug-color2/logger")); 6 | const __root_ws_1 = tslib_1.__importDefault(require("../../__root_ws")); 7 | const fs_extra_1 = require("fs-extra"); 8 | const create_cache_name_1 = tslib_1.__importDefault(require("./create-cache-name")); 9 | const subtree_1 = require("@git-lazy/subtree"); 10 | async function gitSubtreePush(module_name) { 11 | let _ok = true; 12 | let options = { 13 | name: module_name, 14 | prefix: `packages/${module_name}`, 15 | cwd: __root_ws_1.default, 16 | }; 17 | switch (module_name) { 18 | case 'runes2': 19 | options.remote = `https://github.com/bluelovers/runes.git`; 20 | options.branch = 'develop'; 21 | break; 22 | default: 23 | _ok = false; 24 | break; 25 | } 26 | if (_ok) { 27 | await (0, subtree_1.subtreePush)(options); 28 | } 29 | let file = (0, create_cache_name_1.default)('subtree', module_name); 30 | if ((0, fs_extra_1.pathExistsSync)(file)) { 31 | (_ok ? logger_1.default : logger_1.default.red).debug(`[subtree:script]`, `del`, module_name); 32 | (0, fs_extra_1.unlinkSync)(file); 33 | } 34 | } 35 | exports.gitSubtreePush = gitSubtreePush; 36 | //# sourceMappingURL=git-subtree-push.js.map -------------------------------------------------------------------------------- /script/util/git-subtree-push.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by user on 2020/5/13. 3 | */ 4 | import { crossSpawnGitAsync } from '@git-lazy/spawn' 5 | import console from 'debug-color2/logger' 6 | import __root_ws from '../../__root_ws'; 7 | import { unlinkSync, pathExistsSync } from 'fs-extra'; 8 | import { name } from './add-to-postpublish-task'; 9 | import createCacheName from './create-cache-name'; 10 | import { subtreePush, IOptionsCommon } from '@git-lazy/subtree'; 11 | 12 | export async function gitSubtreePush(module_name: 'runes2' | string) 13 | { 14 | let _ok: boolean = true; 15 | 16 | let options: IOptionsCommon = { 17 | name: module_name, 18 | prefix: `packages/${module_name}`, 19 | cwd: __root_ws, 20 | } as any; 21 | 22 | switch (module_name) 23 | { 24 | case 'runes2': 25 | options.remote = `https://github.com/bluelovers/runes.git`; 26 | options.branch = 'develop'; 27 | break; 28 | default: 29 | _ok = false; 30 | break; 31 | } 32 | 33 | if (_ok) 34 | { 35 | await subtreePush(options); 36 | } 37 | 38 | let file = createCacheName('subtree', module_name); 39 | if (pathExistsSync(file)) 40 | { 41 | 42 | (_ok ? console : console.red).debug(`[subtree:script]`, `del`, module_name); 43 | unlinkSync(file); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@bluelovers/tsconfig/esm/mapfile", 3 | "compilerOptions": { 4 | "strictBindCallApply": true, 5 | "importHelpers": true 6 | } 7 | } 8 | --------------------------------------------------------------------------------