diff --git a/.github/workflows/merge-checks.yml b/.github/workflows/merge-checks.yml index 3b7b1e98..3c529fa2 100644 --- a/.github/workflows/merge-checks.yml +++ b/.github/workflows/merge-checks.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Build, Test, and Lint - uses: remedyred/check-action@v1.2.7 + uses: remedyred/check-action@v1.2.8 with: SCRIPTS: ci GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/pr-checks.yml b/.github/workflows/pr-checks.yml index 907a46ed..4e4abe32 100644 --- a/.github/workflows/pr-checks.yml +++ b/.github/workflows/pr-checks.yml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Build, Test, and Lint - uses: remedyred/check-action@v1.2.7 + uses: remedyred/check-action@v1.2.8 with: SCRIPTS: pr GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6743caa8..a0adbd05 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,7 +21,7 @@ jobs: contents: write steps: - name: Build, Test, and Lint - uses: remedyred/check-action@v1.2.7 + uses: remedyred/check-action@v1.2.8 with: SCRIPTS: pr NO_BAIL: true diff --git a/README.md b/README.md index 3dea6cd4..6eb6c284 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,6 @@ - [@snickbit/dates](#snickbit-dates) - [@snickbit/model](#snickbit-model) - [@snickbit/node-utilities](#snickbit-node-utilities) - - [@snickbit/plural](#snickbit-plural) - [@snickbit/queue](#snickbit-queue) - [@snickbit/spinner](#snickbit-spinner) - [@snickbit/upwords](#snickbit-upwords) @@ -104,20 +103,6 @@ Simple object modeling library based on [object-path](https://github.com/marioca This is a collection of helper functions for Node.js. Some of these are just wrappers of other libraries with more intuitive APIs. -
-

- - @snickbit/plural - -

-
- -- Pluralizes strings -- Singularizes strings -- Written in TypeScript -- Zero dependencies - -

diff --git a/clis/snickbit/package.json b/clis/snickbit/package.json index 9378e2a7..54becaa7 100644 --- a/clis/snickbit/package.json +++ b/clis/snickbit/package.json @@ -1,6 +1,6 @@ { "name": "snickbit", - "version": "1.0.29", + "version": "1.0.30", "description": "My personal npx business card", "license": "MIT", "main": "./bin/snickbit.js", @@ -25,8 +25,8 @@ }, "dependencies": { "@snickbit/node-cli": "^3.0.27", - "@snickbit/node-utilities": "^4.7.8", - "@snickbit/out": "^2.1.4", + "@snickbit/node-utilities": "^4.7.10", + "@snickbit/out": "^2.2.0", "ansi-styles-template": "1.0.0", "figlet": "1.6.0", "is-email": "1.0.2", diff --git a/packages/node-utilities/tsconfig.json b/clis/snickbit/tsconfig.json similarity index 100% rename from packages/node-utilities/tsconfig.json rename to clis/snickbit/tsconfig.json diff --git a/package.json b/package.json index 10da9ecf..b0b530fd 100644 --- a/package.json +++ b/package.json @@ -23,9 +23,10 @@ "testEnvironment": "node" }, "devDependencies": { - "@snickbit/eslint-config": "1.5.3", + "@snickbit/eslint-config": "1.5.4", "@snickbit/readmes": "0.0.28", - "@snickbit/semantic-release": "1.6.6", + "@snickbit/semantic-release": "1.6.7", + "@types/jest": "29.5.3", "eslint": "8.45.0", "husky": "8.0.3", "jest": "29.6.1", diff --git a/packages/controller/package.json b/packages/controller/package.json index 21591b5a..e55a4959 100644 --- a/packages/controller/package.json +++ b/packages/controller/package.json @@ -1,6 +1,6 @@ { "name": "@snickbit/controller", - "version": "1.0.15", + "version": "1.0.17", "description": "Minimal state management using an extendable controller class", "license": "MIT", "exports": { @@ -28,7 +28,7 @@ ] }, "dependencies": { - "@snickbit/utilities": "3.11.4", + "@snickbit/utilities": "3.12.0", "mitt": "~3.0.1" }, "devDependencies": { diff --git a/packages/cycle/package.json b/packages/cycle/package.json index 8d63e48e..624da6a0 100644 --- a/packages/cycle/package.json +++ b/packages/cycle/package.json @@ -1,6 +1,6 @@ { "name": "@snickbit/cycle", - "version": "1.0.25", + "version": "1.0.27", "description": "Helper function and class to cycle through an array of values", "license": "MIT", "exports": { @@ -33,7 +33,7 @@ "testEnvironment": "node" }, "dependencies": { - "@snickbit/utilities": "3.11.4" + "@snickbit/utilities": "3.12.0" }, "devDependencies": { "@types/jest": "29.5.3", diff --git a/packages/dates/package.json b/packages/dates/package.json index eb84c35a..e7584d81 100644 --- a/packages/dates/package.json +++ b/packages/dates/package.json @@ -1,6 +1,6 @@ { "name": "@snickbit/dates", - "version": "1.0.78", + "version": "1.0.80", "description": "Extended Date and Time functionality for Dayjs", "license": "MIT", "exports": { @@ -33,7 +33,7 @@ }, "dependencies": { "@snickbit/plural": "1.0.19", - "@snickbit/utilities": "3.11.4", + "@snickbit/utilities": "3.12.0", "dayjs": "1.11.9" }, "devDependencies": { diff --git a/packages/model/package.json b/packages/model/package.json index c8323ec0..8f94b498 100644 --- a/packages/model/package.json +++ b/packages/model/package.json @@ -1,6 +1,6 @@ { "name": "@snickbit/model", - "version": "1.0.81", + "version": "1.0.82", "description": "Simple object modeling library", "license": "MIT", "exports": { @@ -32,8 +32,8 @@ "testEnvironment": "node" }, "dependencies": { - "@snickbit/out": "^2.1.4", - "@snickbit/utilities": "^3.11.1", + "@snickbit/out": "^2.2.0", + "@snickbit/utilities": "^3.11.4", "object-path": "^0.11.8" }, "devDependencies": { diff --git a/packages/node-utilities/CHANGELOG.md b/packages/node-utilities/CHANGELOG.md deleted file mode 100644 index 53287b7a..00000000 --- a/packages/node-utilities/CHANGELOG.md +++ /dev/null @@ -1,232 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. See -[Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -## @snickbit/node-utilities [4.7.0](https://github.com/remedyred/snickbit.js/compare/@snickbit/node-utilities@4.6.0...@snickbit/node-utilities@4.7.0) (2023-03-03) - - -### Features - -* create spinner package ([#118](https://github.com/remedyred/snickbit.js/issues/118)) ([ad7d670](https://github.com/remedyred/snickbit.js/commit/ad7d6704044bb67b74d63b2a5615514d99c5ce9a)) - - -### Bug Fixes - -* improve text and option configurations ([22a0ae8](https://github.com/remedyred/snickbit.js/commit/22a0ae8c2a33437c6c64181352689aad3047798f)) -* remove depcheck ([#119](https://github.com/remedyred/snickbit.js/issues/119)) ([0fb970f](https://github.com/remedyred/snickbit.js/commit/0fb970fe23d85f4e678fbdca577c877b059a86fb)) -* set Spinnies text correctly during init ([c84f510](https://github.com/remedyred/snickbit.js/commit/c84f510c31f73eb2a0f221aad5ea16b86e051205)) -* update options during start ([5e8146c](https://github.com/remedyred/snickbit.js/commit/5e8146c7c082f95aa02afae474d6a9224312499c)) -* use pick to check for spinner existence. ([b95a26a](https://github.com/remedyred/snickbit.js/commit/b95a26abfbef5966b8701f438aa7bb62922b63be)) - - - -### Dependencies - -* **@snickbit/utilities:** upgraded to 3.4.19 - -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -## [4.4.7](https://github.com/snickbit/snickbit.js/compare/@snickbit/node-utilities@4.4.6...@snickbit/node-utilities@4.4.7) (2022-08-19) - -**Note:** Version bump only for package @snickbit/node-utilities - -## [4.4.6](https://github.com/snickbit/snickbit.js/compare/@snickbit/node-utilities@4.4.5...@snickbit/node-utilities@4.4.6) (2022-08-13) - -### Bug Fixes - -* **files:** deprecate *FileJson methods in favor of *FileJSON naming convention ([#18](https://github.com/snickbit/snickbit.js/issues/18)) ([50ee50b](https://github.com/snickbit/snickbit.js/commit/50ee50b8974f43399371d31bec522790b78d1433)) - -## [4.4.5](https://github.com/snickbit/snickbit.js/compare/@snickbit/node-utilities@4.4.4...@snickbit/node-utilities@4.4.5) (2022-08-11) - -**Note:** Version bump only for package @snickbit/node-utilities - -## [4.4.4](https://github.com/snickbit/snickbit.js/compare/@snickbit/node-utilities@4.4.3...@snickbit/node-utilities@4.4.4) (2022-08-06) - -### Bug Fixes - -* replace let with const ([1d5c624](https://github.com/snickbit/snickbit.js/commit/1d5c6248acdc7d9e4d46ba94c03af1932d9a5c76)) - -## [4.4.3](https://github.com/snickbit/snickbit.js/compare/@snickbit/node-utilities@4.4.2...@snickbit/node-utilities@4.4.3) (2022-08-05) - -**Note:** Version bump only for package @snickbit/node-utilities - -# @snickbit/node-utilities - -## 4.4.1 - -### Patch Changes - -- [c05c0f2](https://github.com/snickbit/snickbit.js/commit/c05c0f2) **docs**: update -- [f0acbda](https://github.com/snickbit/snickbit.js/commit/f0acbda) **fix**: better handling of select/choices - -## 4.4.0 - -### Minor Changes - -- [31a276c](https://github.com/snickbit/snickbit.js/commit/31a276c) **docs**: update -- [10309c2](https://github.com/snickbit/snickbit.js/commit/10309c2) **style**: lint -- [d334fe5](https://github.com/snickbit/snickbit.js/commit/d334fe5) **fix**: add generic to unparsed import -- [e7d156f](https://github.com/snickbit/snickbit.js/commit/e7d156f) **docs**: update -- [4dac598](https://github.com/snickbit/snickbit.js/commit/4dac598) **docs**: export MultiProgressBars type -- [288c368](https://github.com/snickbit/snickbit.js/commit/288c368) **docs**: update jsdoc comments -- [a4e1453](https://github.com/snickbit/snickbit.js/commit/a4e1453) **fix**: overhaul prompt types for better type checking, add better error handling -- [e2cf7c4](https://github.com/snickbit/snickbit.js/commit/e2cf7c4) **feat**: replace Args and Results generics with single type generic -- [de624fe](https://github.com/snickbit/snickbit.js/commit/de624fe) **fix**: improve confirm handling - -## 4.3.15 - -### Patch Changes - -- [ad55cdf](https://github.com/snickbit/snickbit.js/commit/ad55cdf) **fix**: migrate to @snickbit/indexer -- [c5a5cf2](https://github.com/snickbit/snickbit.js/commit/c5a5cf2) **chore**: bump dependencies -- [dadd932](https://github.com/snickbit/snickbit.js/commit/dadd932) **chore**: bump dependencies - -## 4.3.14 - -### Patch Changes - -- [d3f318a](https://github.com/snickbit/snickbit.js/commit/d3f318a) **fix**: only use provided name if it's an import definition -- [1a64c84](https://github.com/snickbit/snickbit.js/commit/1a64c84) **fix**: use consistent variable names -- [9bf343e](https://github.com/snickbit/snickbit.js/commit/9bf343e) **chore**: bump deps - -## 4.3.13 - -### Patch Changes - -- [92870a6](https://github.com/snickbit/snickbit.js/commit/92870a6) **docs**: update -- [0773345](https://github.com/snickbit/snickbit.js/commit/0773345) **fix**: use any import type -- [9ddfa01](https://github.com/snickbit/snickbit.js/commit/9ddfa01) **fix**: use any import type -- [3737b24](https://github.com/snickbit/snickbit.js/commit/3737b24) **fix**: verify handler is callable -- [662adad](https://github.com/snickbit/snickbit.js/commit/662adad) **fix**: add generics to typings -- [93dc29b](https://github.com/snickbit/snickbit.js/commit/93dc29b) **fix**: remove useless loop -- [2cde981](https://github.com/snickbit/snickbit.js/commit/2cde981) **fix**: add promises to import methods -- [4e14fd9](https://github.com/snickbit/snickbit.js/commit/4e14fd9) **fix**: improve import parsing -- [ae04845](https://github.com/snickbit/snickbit.js/commit/ae04845) **feat**: add aliases to imports - -## 4.3.10 - -### Patch Changes - -- [66624f1](https://github.com/snickbit/snickbit.js/commit/66624f1) **chore**: update dependencies -- [f7e55ec](https://github.com/snickbit/snickbit.js/commit/f7e55ec) **docs**: update -- [550b1d0](https://github.com/snickbit/snickbit.js/commit/550b1d0) **style**: lint - -## 4.3.7 - -### Patch Changes - -- [ca07e6b](https://github.com/snickbit/snickbit.js/commit/ca07e6b) **style**: heavy code restyling -- [5665547](https://github.com/snickbit/snickbit.js/commit/5665547) **chore**: bump dependencies -- [195670f](https://github.com/snickbit/snickbit.js/commit/195670f) **docs**: update - -## 4.3.5 - -### Patch Changes - -- [48718e0](https://github.com/snickbit/snickbit.js/commit/48718e0) **docs**: update -- [ae72619](https://github.com/snickbit/snickbit.js/commit/ae72619) **build**: remove nx -- [1bc9f98](https://github.com/snickbit/snickbit.js/commit/1bc9f98) **fix**: merge defaultCliProgressConfig when sending to cli-progress -- [c57a457](https://github.com/snickbit/snickbit.js/commit/c57a457) **fix**: make CLIProgressOptions partial -- [ff43f0d](https://github.com/snickbit/snickbit.js/commit/ff43f0d) **style**: sort package.json -- [769e3b9](https://github.com/snickbit/snickbit.js/commit/769e3b9) **style**: relint - -## 4.3.4 - -### Patch Changes - -- [4ca542a](https://github.com/snickbit/snickbit.js/commit/4ca542a) **build**: switch to pnpm for running - -## 4.3.3 - -### Patch Changes - -- [7e02502](https://github.com/snickbit/snickbit.js/commit/7e02502) **chore**(dep): update dependencies -- [da8a0b3](https://github.com/snickbit/snickbit.js/commit/da8a0b3) **style**: reformat -- [3d9b594](https://github.com/snickbit/snickbit.js/commit/3d9b594) **fix**: make spinner options optional -- [f207683](https://github.com/snickbit/snickbit.js/commit/f207683) **fix**(progress): make tick value optional - -## 4.3.2 - -### Patch Changes - -- [2590641](https://github.com/snickbit/snickbit.js/commit/2590641) **fix**: export MultiProgressChild -- [d4a042e](https://github.com/snickbit/snickbit.js/commit/d4a042e) **chore**: update dependencies - -## 4.3.1 - -### Patch Changes - -- [30b4883](https://github.com/snickbit/snickbit.js/commit/30b4883) **docs**: update -- [9d308cd](https://github.com/snickbit/snickbit.js/commit/9d308cd) **feat**: add helper method for setting message -- [1fc998a](https://github.com/snickbit/snickbit.js/commit/1fc998a) **feat**: add set method to set current value of progress bar - -## 4.3.0 - -### Minor Changes - -- [f50e3a9](https://github.com/snickbit/snickbit.js/commit/f50e3a9) **docs**: update -- [29c0d61](https://github.com/snickbit/snickbit.js/commit/29c0d61) **fix**: add MultiProgressChildConfig type definition and re-declare the options -- [8ab4a9e](https://github.com/snickbit/snickbit.js/commit/8ab4a9e) **fix**: simplify ProgressOptions type definition -- [ccca54c](https://github.com/snickbit/snickbit.js/commit/ccca54c) **feat**: autostart progress by default, add option to disable -- [cf54186](https://github.com/snickbit/snickbit.js/commit/cf54186) **fix**: cleanup code and adjust type definitions -- [c0d828f](https://github.com/snickbit/snickbit.js/commit/c0d828f) **feat**: expand tick method with overloads -- [c6f76f8](https://github.com/snickbit/snickbit.js/commit/c6f76f8) **build**: add dev watcher scripts with source maps - -## 4.2.33 - -### Patch Changes - -- [0c63eaf](https://github.com/snickbit/snickbit.js/commit/0c63eaf) **build**: migrate to nx -- [9447fbc](https://github.com/snickbit/snickbit.js/commit/9447fbc) **feat**(node-utilities): add descriptions to parsed imports -- [c808d21](https://github.com/snickbit/snickbit.js/commit/c808d21) **feat**(node-utilities): adjust type definition for parseImports -- [6c92d3f](https://github.com/snickbit/snickbit.js/commit/6c92d3f) **fix**(node-utilities): parseImports return type -- [9e06203](https://github.com/snickbit/snickbit.js/commit/9e06203) **feat**(node-utilities): export isImport and isImportDefinition helpers -- [447e7b0](https://github.com/snickbit/snickbit.js/commit/447e7b0) **docs**: update chore: update dependencies chore: adjust configurations - -## 4.2.32 - -### Patch Changes - -- [e670dbc](https://github.com/snickbit/snickbit.js/commit/e670dbc) **feat**: add bufferStream and makeBuffer helper functions, previously from @snickbit/utilities -- [a1b37df](https://github.com/snickbit/snickbit.js/commit/a1b37df) **chore**: update dependencies -- [b61521a](https://github.com/snickbit/snickbit.js/commit/b61521a) **chore**: update build config -- [67a87da](https://github.com/snickbit/snickbit.js/commit/67a87da) **docs**: update - -## 4.2.31 - -### Patch Changes - -- [8a65a3c](https://github.com/snickbit/snickbit.js/commit/8a65a3c) **chore**: update dependencies - -## 4.2.30 - -### Patch Changes - -- [c7fb5bc](https://github.com/snickbit/snickbit.js/commit/c7fb5bc) **docs**: update -- [ef3ba51](https://github.com/snickbit/snickbit.js/commit/ef3ba51) **chore**: update build config -- [164874d](https://github.com/snickbit/snickbit.js/commit/164874d) **chore**: update build config - -## 4.2.29 - -### Patch Changes - -- [d37a724](https://github.com/snickbit/snickbit.js/commit/d37a724) **fix**(node-utilities): remove debugging log -- [3925c24](https://github.com/snickbit/snickbit.js/commit/3925c24) **feat**(node-utilities): add CTRL+C support to prompts -- [18226ec](https://github.com/snickbit/snickbit.js/commit/18226ec) **fix**(node-utilities): correct prompts types -- [9d53930](https://github.com/snickbit/snickbit.js/commit/9d53930) **fix**(node-utilities): missing progress message - -## 4.2.28 - -### Patch Changes - -- 7af5524: chore: update config - -## 4.2.16 - -### Patch Changes - -- 4dd2074: First public release diff --git a/packages/node-utilities/README.md b/packages/node-utilities/README.md deleted file mode 100644 index 171afbbc..00000000 --- a/packages/node-utilities/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# @snickbit/node-utilities - - - -This is a collection of helper functions for Node.js. Some of these are just wrappers of other libraries with more intuitive APIs. - - - -## Installation - -```bash -yarn add @snickbit/node-utilities -``` - -```bash -npm add @snickbit/node-utilities -``` - -## Documentation - -### [API Docs](./docs/README.md) - -### [CHANGELOG](CHANGELOG.md) - -## License - -Copyright (c) 2022 - **Nicholas Lowe** aka **Snickbit** - -[MIT License](../../LICENSE) diff --git a/packages/node-utilities/docs/README.md b/packages/node-utilities/docs/README.md deleted file mode 100644 index d271844c..00000000 --- a/packages/node-utilities/docs/README.md +++ /dev/null @@ -1,916 +0,0 @@ -# @snickbit/node-utilities - -## Table of contents - -### Progress Classes - -- [MultiProgress](classes/MultiProgress.md) -- [MultiProgressChild](classes/MultiProgressChild.md) -- [Progress](classes/Progress.md) - -### Spinner Classes - -- [Spinner](classes/Spinner.md) - -### Files Interfaces - -- [FindUpOptions](interfaces/FindUpOptions.md) - -### Imports Interfaces - -- [ImportDefinition](interfaces/ImportDefinition.md) -- [ParsedImport](interfaces/ParsedImport.md) - -### Modules Interfaces - -- [AutoCompleteQuestion](interfaces/AutoCompleteQuestion.md) -- [CLIProgressOptions](interfaces/CLIProgressOptions.md) -- [MultiProgressChildConfig](interfaces/MultiProgressChildConfig.md) -- [UnparsedImport](interfaces/UnparsedImport.md) - -### Progress Interfaces - -- [ProgressConfig](interfaces/ProgressConfig.md) - -### Prompts Interfaces - -- [AutoCompleteMultiSelectQuestion](interfaces/AutoCompleteMultiSelectQuestion.md) -- [ChoiceDefinition](interfaces/ChoiceDefinition.md) -- [ConfirmQuestion](interfaces/ConfirmQuestion.md) -- [DateQuestion](interfaces/DateQuestion.md) -- [InvisibleQuestion](interfaces/InvisibleQuestion.md) -- [ListQuestion](interfaces/ListQuestion.md) -- [MultiSelectQuestion](interfaces/MultiSelectQuestion.md) -- [NumberQuestion](interfaces/NumberQuestion.md) -- [PasswordQuestion](interfaces/PasswordQuestion.md) -- [PromptState](interfaces/PromptState.md) -- [PromptTypeMethod](interfaces/PromptTypeMethod.md) -- [PromptsLocales](interfaces/PromptsLocales.md) -- [SelectQuestion](interfaces/SelectQuestion.md) -- [TextQuestion](interfaces/TextQuestion.md) -- [ToggleQuestion](interfaces/ToggleQuestion.md) - -### Spinner Interfaces - -- [SpinnerConfig](interfaces/SpinnerConfig.md) - -### Imports Type Aliases - -- [ImportRecords](README.md#importrecords) -- [RecordOfImportRecords](README.md#recordofimportrecords) - -### Modules Type Aliases - -- [ImportMethod](README.md#importmethod) -- [MultiProgressChildOptions](README.md#multiprogresschildoptions) -- [ParsedImportRecords](README.md#parsedimportrecords) -- [ProgressOptions](README.md#progressoptions) -- [ProgressPayload](README.md#progresspayload) -- [RawImports](README.md#rawimports) - -### Progress Type Aliases - -- [MultiProgressBars](README.md#multiprogressbars) - -### Prompts Type Aliases - -- [AnswerTypes](README.md#answertypes) -- [Answers](README.md#answers) -- [ChoiceOption](README.md#choiceoption) -- [ChoiceRecords](README.md#choicerecords) -- [PromptType](README.md#prompttype) -- [PromptsMethod](README.md#promptsmethod) -- [Question](README.md#question) -- [QuestionRecords](README.md#questionrecords) - -### Spinner Type Aliases - -- [SpinnerOptions](README.md#spinneroptions) - -### Environment Variables - -- [app\_data\_dir](README.md#app_data_dir) -- [bashrc\_path](README.md#bashrc_path) -- [home\_dir](README.md#home_dir) -- [is\_wsl](README.md#is_wsl) -- [platform](README.md#platform) -- [temp\_dir](README.md#temp_dir) -- [user\_config\_dir](README.md#user_config_dir) -- [user\_data\_dir](README.md#user_data_dir) -- [verbose](README.md#verbose) - -### Before Exit Functions - -- [beforeExit](README.md#beforeexit) - -### Buffer Functions - -- [bufferStream](README.md#bufferstream) -- [makeBuffer](README.md#makebuffer) - -### Environment Functions - -- [interpolateEnv](README.md#interpolateenv) -- [isBundledElectronApp](README.md#isbundledelectronapp) -- [isElectronApp](README.md#iselectronapp) - -### Files Functions - -- [fileExists](README.md#fileexists) -- [findUp](README.md#findup) -- [getFile](README.md#getfile) -- [getFileJSON](README.md#getfilejson) -- [getFileJson](README.md#getfilejson-1) -- [isDirectory](README.md#isdirectory) -- [mkdir](README.md#mkdir) -- [saveFile](README.md#savefile) -- [saveFileJSON](README.md#savefilejson) -- [saveFileJson](README.md#savefilejson-1) -- [unlink](README.md#unlink) - -### Imports Functions - -- [isImport](README.md#isimport) -- [isImportDefinition](README.md#isimportdefinition) -- [parseImports](README.md#parseimports) - -### Progress Functions - -- [multiprogress](README.md#multiprogress) -- [progress](README.md#progress) - -### Prompts Functions - -- [ask](README.md#ask) -- [confirm](README.md#confirm) -- [prompt](README.md#prompt) - -### Spinner Functions - -- [spinner](README.md#spinner) - -## Imports Type Aliases - -### ImportRecords - -Ƭ **ImportRecords**<`I`\>: `Record`<`string`, `I` \| [`ImportDefinition`](interfaces/ImportDefinition.md)<`I`\>\> - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `I` | extends [`ImportMethod`](README.md#importmethod) = [`ImportMethod`](README.md#importmethod) | - -___ - -### RecordOfImportRecords - -Ƭ **RecordOfImportRecords**<`I`\>: `Record`<`string`, [`ImportRecords`](README.md#importrecords)<`I`\>\> - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `I` | extends [`ImportMethod`](README.md#importmethod) = [`ImportMethod`](README.md#importmethod) | - -___ - -## Modules Type Aliases - -### ImportMethod - -Ƭ **ImportMethod**<`Args`, `Results`\>: (...`args`: `Args`[]) => `Promise`<`Results`\> \| `Results` - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `Args` | `any` | -| `Results` | `any` | - -#### Type declaration - -▸ (`...args`): `Promise`<`Results`\> \| `Results` - -##### Parameters - -| Name | Type | -| :------ | :------ | -| `...args` | `Args`[] | - -##### Returns - -`Promise`<`Results`\> \| `Results` - -___ - -### MultiProgressChildOptions - -Ƭ **MultiProgressChildOptions**: `Partial`<[`MultiProgressChildConfig`](interfaces/MultiProgressChildConfig.md)\> - -___ - -### ParsedImportRecords - -Ƭ **ParsedImportRecords**<`I`\>: `Record`<`string`, [`ParsedImport`](interfaces/ParsedImport.md)<`I`\>\> - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `I` | extends [`ImportMethod`](README.md#importmethod) = [`ImportMethod`](README.md#importmethod) | - -___ - -### ProgressOptions - -Ƭ **ProgressOptions**: `Partial`<[`ProgressConfig`](interfaces/ProgressConfig.md)\> - -___ - -### ProgressPayload - -Ƭ **ProgressPayload**: `Record`<`string`, `any`\> - -___ - -### RawImports - -Ƭ **RawImports**<`I`\>: [`ImportRecords`](README.md#importrecords)<`I`\> \| [`RecordOfImportRecords`](README.md#recordofimportrecords)<`I`\> \| `any` - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `I` | extends [`ImportMethod`](README.md#importmethod) = [`ImportMethod`](README.md#importmethod) | - -___ - -## Progress Type Aliases - -### MultiProgressBars - -Ƭ **MultiProgressBars**: `Record`<`string`, [`MultiProgressChild`](classes/MultiProgressChild.md)\> - -___ - -## Prompts Type Aliases - -### AnswerTypes - -Ƭ **AnswerTypes**: `Date` \| `boolean` \| `number` \| `string` - -___ - -### Answers - -Ƭ **Answers**: `Record`<`string`, `string`\> - -___ - -### ChoiceOption - -Ƭ **ChoiceOption**: [`ChoiceDefinition`](interfaces/ChoiceDefinition.md) \| `string` - -___ - -### ChoiceRecords - -Ƭ **ChoiceRecords**: `Record`<`string`, [`ChoiceOption`](README.md#choiceoption)\> - -___ - -### PromptType - -Ƭ **PromptType**: ``"autocomplete"`` \| ``"autocompleteMultiselect"`` \| ``"confirm"`` \| ``"date"`` \| ``"invisible"`` \| ``"list"`` \| ``"multiselect"`` \| ``"number"`` \| ``"password"`` \| ``"select"`` \| ``"text"`` \| ``"toggle"`` - -___ - -### PromptsMethod - -Ƭ **PromptsMethod**: (`prev`: `string`, `answers`: [`Answers`](README.md#answers), `previousQuestion`: [`Question`](README.md#question)) => `Promise`<`string`\> \| `string` - -#### Type declaration - -▸ (`prev`, `answers`, `previousQuestion`): `Promise`<`string`\> \| `string` - -##### Parameters - -| Name | Type | -| :------ | :------ | -| `prev` | `string` | -| `answers` | [`Answers`](README.md#answers) | -| `previousQuestion` | [`Question`](README.md#question) | - -##### Returns - -`Promise`<`string`\> \| `string` - -___ - -### Question - -Ƭ **Question**: [`AutoCompleteMultiSelectQuestion`](interfaces/AutoCompleteMultiSelectQuestion.md) \| [`AutoCompleteQuestion`](interfaces/AutoCompleteQuestion.md) \| [`ConfirmQuestion`](interfaces/ConfirmQuestion.md) \| [`DateQuestion`](interfaces/DateQuestion.md) \| [`InvisibleQuestion`](interfaces/InvisibleQuestion.md) \| [`ListQuestion`](interfaces/ListQuestion.md) \| [`MultiSelectQuestion`](interfaces/MultiSelectQuestion.md) \| [`NumberQuestion`](interfaces/NumberQuestion.md) \| [`PasswordQuestion`](interfaces/PasswordQuestion.md) \| [`SelectQuestion`](interfaces/SelectQuestion.md) \| [`TextQuestion`](interfaces/TextQuestion.md) \| [`ToggleQuestion`](interfaces/ToggleQuestion.md) - -___ - -### QuestionRecords - -Ƭ **QuestionRecords**: `Record`<`string`, [`Question`](README.md#question)\> - -___ - -## Spinner Type Aliases - -### SpinnerOptions - -Ƭ **SpinnerOptions**: `Partial`<[`SpinnerConfig`](interfaces/SpinnerConfig.md)\> - -## Environment Variables - -### app\_data\_dir - -• `Const` **app\_data\_dir**: `string` - -___ - -### bashrc\_path - -• `Const` **bashrc\_path**: `string` - -___ - -### home\_dir - -• `Const` **home\_dir**: `string` - -___ - -### is\_wsl - -• `Const` **is\_wsl**: `boolean` = `isWsl` - -___ - -### platform - -• `Const` **platform**: `string` - -___ - -### temp\_dir - -• `Const` **temp\_dir**: `string` - -___ - -### user\_config\_dir - -• `Const` **user\_config\_dir**: `string` - -___ - -### user\_data\_dir - -• `Const` **user\_data\_dir**: `string` = `app_data_dir` - -___ - -### verbose - -• `Const` **verbose**: `number` - -## Before Exit Functions - -### beforeExit - -▸ **beforeExit**(`callback`): `void` - -Add a function to be called before the process exits. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `callback` | () => `void` | - -#### Returns - -`void` - -___ - -## Buffer Functions - -### bufferStream - -▸ **bufferStream**(`readable`): `Promise`<`Buffer`\> - -Make a buffer from a file stream - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `readable` | `Readable` | - -#### Returns - -`Promise`<`Buffer`\> - -___ - -### makeBuffer - -▸ **makeBuffer**(`content`): `Buffer` - -Make a buffer from a string. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `content` | `string` | - -#### Returns - -`Buffer` - -___ - -## Environment Functions - -### interpolateEnv - -▸ **interpolateEnv**(`str`, `defaultValues?`): `string` - -interpolate string with env variables, optionally pass an object of default values - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `str` | `string` | -| `defaultValues` | `Record`<`string`, `string`\> | - -#### Returns - -`string` - -___ - -### isBundledElectronApp - -▸ **isBundledElectronApp**(): `boolean` - -Check if the current process is a bundled Electron app. - -#### Returns - -`boolean` - -___ - -### isElectronApp - -▸ **isElectronApp**(): `boolean` - -Check if the current process is a Electron app - -#### Returns - -`boolean` - -___ - -## Files Functions - -### fileExists - -▸ **fileExists**(`filepath`): `boolean` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `filepath` | `PathLike` | - -#### Returns - -`boolean` - -___ - -### findUp - -▸ **findUp**(`name`, `options?`): `any` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `name` | `PathLike` | -| `options?` | `string` \| `boolean` \| `Partial`<[`FindUpOptions`](interfaces/FindUpOptions.md)\> | - -#### Returns - -`any` - -___ - -### getFile - -▸ **getFile**(`filepath`, `fallback?`): `any` - -Get file content - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `filepath` | `PathLike` | -| `fallback?` | `any` | - -#### Returns - -`any` - -___ - -### getFileJSON - -▸ **getFileJSON**(`filepath`, `fallback?`): `any` - -Get JSON from file - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `filepath` | `PathLike` | -| `fallback?` | `any` | - -#### Returns - -`any` - -___ - -### getFileJson - -▸ **getFileJson**(`filepath`, `fallback?`): `any` - -Get JSON from file - -**`Deprecated`** - -use getFileJSON instead - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `filepath` | `PathLike` | -| `fallback?` | `any` | - -#### Returns - -`any` - -___ - -### isDirectory - -▸ **isDirectory**(`filepath`): `boolean` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `filepath` | `PathLike` | - -#### Returns - -`boolean` - -___ - -### mkdir - -▸ **mkdir**(`dir_path`, `recursive?`): `void` - -Make a directory - -#### Parameters - -| Name | Type | Default value | -| :------ | :------ | :------ | -| `dir_path` | `PathLike` | `undefined` | -| `recursive` | `boolean` | `true` | - -#### Returns - -`void` - -___ - -### saveFile - -▸ **saveFile**(`filepath`, `content`, `options?`): `void` - -Save file to disk - -#### Parameters - -| Name | Type | Default value | -| :------ | :------ | :------ | -| `filepath` | `PathOrFileDescriptor` | `undefined` | -| `content` | `string` \| `ArrayBufferView` | `undefined` | -| `options` | `WriteFileOptions` | `'utf8'` | - -#### Returns - -`void` - -___ - -### saveFileJSON - -▸ **saveFileJSON**(`filepath`, `content`, `options?`): `void` - -Save file to disk as JSON - -#### Parameters - -| Name | Type | Default value | -| :------ | :------ | :------ | -| `filepath` | `PathOrFileDescriptor` | `undefined` | -| `content` | `any` | `undefined` | -| `options` | `WriteFileOptions` | `'utf8'` | - -#### Returns - -`void` - -___ - -### saveFileJson - -▸ **saveFileJson**(`filepath`, `content`, `options?`): `void` - -Save file to disk as JSON - -**`Deprecated`** - -use saveFileJSON instead - -#### Parameters - -| Name | Type | Default value | -| :------ | :------ | :------ | -| `filepath` | `PathOrFileDescriptor` | `undefined` | -| `content` | `any` | `undefined` | -| `options` | `WriteFileOptions` | `'utf8'` | - -#### Returns - -`void` - -___ - -### unlink - -▸ **unlink**(`filepath`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `filepath` | `PathLike` | - -#### Returns - -`void` - -___ - -## Imports Functions - -### isImport - -▸ **isImport**(`data`): `boolean` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `data` | `any` | - -#### Returns - -`boolean` - -___ - -### isImportDefinition - -▸ **isImportDefinition**(`data`): `any` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `data` | `any` | - -#### Returns - -`any` - -___ - -### parseImports - -▸ **parseImports**<`I`\>(`imports`, `parent?`): [`ParsedImportRecords`](README.md#parsedimportrecords)<`I`\> - -Parse imports from `import * as name from 'path'` statements into a more manageable format. - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `I` | extends [`ImportMethod`](README.md#importmethod)<`any`, `any`\> = [`ImportMethod`](README.md#importmethod)<`any`, `any`\> | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `imports` | `any` | -| `parent?` | `string` | - -#### Returns - -[`ParsedImportRecords`](README.md#parsedimportrecords)<`I`\> - -___ - -## Progress Functions - -### multiprogress - -▸ **multiprogress**(`options?`): [`MultiProgress`](classes/MultiProgress.md) - -Multi-Progress bar. Uses cli-progress to create multiple progress bars. - -**`See`** - -https://github.com/npkgz/cli-progress - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `options?` | `Partial`<[`ProgressConfig`](interfaces/ProgressConfig.md)\> | - -#### Returns - -[`MultiProgress`](classes/MultiProgress.md) - -___ - -### progress - -▸ **progress**(`options?`): [`Progress`](classes/Progress.md) - -Progress bar. Uses cli-progress to create multiple progress bars. - -**`See`** - -https://github.com/npkgz/cli-progress - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `options?` | `Partial`<[`ProgressConfig`](interfaces/ProgressConfig.md)\> | - -#### Returns - -[`Progress`](classes/Progress.md) - -___ - -## Prompts Functions - -### ask - -▸ **ask**(`question`, `defaultAnswer?`): `Promise`<`any`\> - -Prompt the user for input using Prompts. - -**`See`** - -https://github.com/terkelg/prompts - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `question` | `string` | -| `defaultAnswer?` | `string` \| `boolean` | - -#### Returns - -`Promise`<`any`\> - -▸ **ask**(`question`, `options?`): `Promise`<`any`\> - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `question` | `string` | -| `options?` | `Partial`<[`Question`](README.md#question)\> | - -#### Returns - -`Promise`<`any`\> - -___ - -### confirm - -▸ **confirm**(`question`, `defaultAnswer?`): `Promise`<`boolean`\> - -Prompt the user for confirmation using Prompts. - -**`See`** - -https://github.com/terkelg/prompts - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `question` | `string` | -| `defaultAnswer?` | `boolean` | - -#### Returns - -`Promise`<`boolean`\> - -▸ **confirm**(`question`, `options?`): `Promise`<`boolean`\> - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `question` | `string` | -| `options?` | `Partial`<[`Question`](README.md#question)\> | - -#### Returns - -`Promise`<`boolean`\> - -___ - -### prompt - -▸ **prompt**(`questions`): `Promise`<[`Answers`](README.md#answers)\> - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `questions` | [`QuestionRecords`](README.md#questionrecords) \| [`Question`](README.md#question)[] | - -#### Returns - -`Promise`<[`Answers`](README.md#answers)\> - -___ - -## Spinner Functions - -### spinner - -▸ **spinner**(`options?`): [`Spinner`](classes/Spinner.md) - -Spinner. Uses nanospinner to show spinners in the terminal. - -**`See`** - -https://github.com/usmanyunusov/nanospinner - -**`Deprecated`** - -use @snickbit/spinner instead - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `options?` | `string` \| `Partial`<[`SpinnerConfig`](interfaces/SpinnerConfig.md)\> | - -#### Returns - -[`Spinner`](classes/Spinner.md) diff --git a/packages/node-utilities/docs/classes/MultiProgress.md b/packages/node-utilities/docs/classes/MultiProgress.md deleted file mode 100644 index 67ba92d2..00000000 --- a/packages/node-utilities/docs/classes/MultiProgress.md +++ /dev/null @@ -1,392 +0,0 @@ -# Class: MultiProgress - -Multi-Progress bar. Uses cli-progress to create multiple progress bars. - -**`See`** - -https://github.com/npkgz/cli-progress - -## Hierarchy - -- [`Progress`](Progress.md) - - ↳ **`MultiProgress`** - -## Table of contents - -### Constructors - -- [constructor](MultiProgress.md#constructor) - -### Properties - -- [bar](MultiProgress.md#bar) -- [bars](MultiProgress.md#bars) -- [id](MultiProgress.md#id) -- [multibar](MultiProgress.md#multibar) -- [options](MultiProgress.md#options) -- [out](MultiProgress.md#out) - -### Methods - -- [create](MultiProgress.md#create) -- [eta](MultiProgress.md#eta) -- [fail](MultiProgress.md#fail) -- [finish](MultiProgress.md#finish) -- [message](MultiProgress.md#message) -- [remove](MultiProgress.md#remove) -- [set](MultiProgress.md#set) -- [setTotal](MultiProgress.md#settotal) -- [start](MultiProgress.md#start) -- [stop](MultiProgress.md#stop) -- [tick](MultiProgress.md#tick) -- [update](MultiProgress.md#update) - -## Constructors - -### constructor - -• **new MultiProgress**(`options?`) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `options?` | `Partial`<[`ProgressConfig`](../interfaces/ProgressConfig.md)\> | - -#### Overrides - -[Progress](Progress.md).[constructor](Progress.md#constructor) - -## Properties - -### bar - -• **bar**: `SingleBar` - -#### Inherited from - -[Progress](Progress.md).[bar](Progress.md#bar) - -___ - -### bars - -• **bars**: [`MultiProgressBars`](../README.md#multiprogressbars) - -___ - -### id - -• **id**: `string` - -___ - -### multibar - -• **multibar**: `MultiBar` - -___ - -### options - -• **options**: [`ProgressConfig`](../interfaces/ProgressConfig.md) - -#### Inherited from - -[Progress](Progress.md).[options](Progress.md#options) - -___ - -### out - -• **out**: `Out` - -#### Inherited from - -[Progress](Progress.md).[out](Progress.md#out) - -## Methods - -### create - -▸ **create**(`options?`): [`MultiProgressChild`](MultiProgressChild.md) - -Create a child progress bar - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `options?` | `Partial`<[`ProgressConfig`](../interfaces/ProgressConfig.md)\> | - -#### Returns - -[`MultiProgressChild`](MultiProgressChild.md) - -___ - -### eta - -▸ **eta**(): `string` \| `number` - -Get the ETA - -#### Returns - -`string` \| `number` - -#### Inherited from - -[Progress](Progress.md).[eta](Progress.md#eta) - -___ - -### fail - -▸ **fail**(`...messages`): [`MultiProgress`](MultiProgress.md) - -Fail and stop the progress bar - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `...messages` | `any`[] | - -#### Returns - -[`MultiProgress`](MultiProgress.md) - -#### Inherited from - -[Progress](Progress.md).[fail](Progress.md#fail) - -___ - -### finish - -▸ **finish**(`...messages`): [`MultiProgress`](MultiProgress.md) - -Succeed and stop the progress bar - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `...messages` | `any`[] | - -#### Returns - -[`MultiProgress`](MultiProgress.md) - -#### Inherited from - -[Progress](Progress.md).[finish](Progress.md#finish) - -___ - -### message - -▸ **message**(`message`): [`MultiProgress`](MultiProgress.md) - -Set the progress bar message - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `message` | `string` | - -#### Returns - -[`MultiProgress`](MultiProgress.md) - -#### Inherited from - -[Progress](Progress.md).[message](Progress.md#message) - -___ - -### remove - -▸ **remove**(`instance`): [`MultiProgress`](MultiProgress.md) - -Remove a child progress bar - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `instance` | [`MultiProgressChild`](MultiProgressChild.md) | - -#### Returns - -[`MultiProgress`](MultiProgress.md) - -___ - -### set - -▸ **set**(`value`, `payload?`): `void` - -Set the progress bar current value - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `number` | -| `payload?` | [`ProgressPayload`](../README.md#progresspayload) | - -#### Returns - -`void` - -#### Inherited from - -[Progress](Progress.md).[set](Progress.md#set) - -___ - -### setTotal - -▸ **setTotal**(`total`): [`MultiProgress`](MultiProgress.md) - -Set the progress bar total - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `total` | `number` | - -#### Returns - -[`MultiProgress`](MultiProgress.md) - -#### Inherited from - -[Progress](Progress.md).[setTotal](Progress.md#settotal) - -___ - -### start - -▸ **start**(`options?`): [`MultiProgress`](MultiProgress.md) - -Start the progress bar - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `options?` | `Partial`<[`ProgressConfig`](../interfaces/ProgressConfig.md)\> | - -#### Returns - -[`MultiProgress`](MultiProgress.md) - -#### Inherited from - -[Progress](Progress.md).[start](Progress.md#start) - -___ - -### stop - -▸ **stop**(`...messages`): [`MultiProgress`](MultiProgress.md) - -Stop all child progress bars - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `...messages` | `any`[] | - -#### Returns - -[`MultiProgress`](MultiProgress.md) - -#### Overrides - -[Progress](Progress.md).[stop](Progress.md#stop) - -___ - -### tick - -▸ **tick**(`payload`): [`MultiProgress`](MultiProgress.md) - -Tick the progress - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `payload` | [`ProgressPayload`](../README.md#progresspayload) | - -#### Returns - -[`MultiProgress`](MultiProgress.md) - -#### Inherited from - -[Progress](Progress.md).[tick](Progress.md#tick) - -▸ **tick**(`value?`, `payload?`): [`MultiProgress`](MultiProgress.md) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value?` | `number` | -| `payload?` | [`ProgressPayload`](../README.md#progresspayload) | - -#### Returns - -[`MultiProgress`](MultiProgress.md) - -#### Inherited from - -[Progress](Progress.md).[tick](Progress.md#tick) - -▸ **tick**(`message`, `payload?`): [`MultiProgress`](MultiProgress.md) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `message` | `string` | -| `payload?` | [`ProgressPayload`](../README.md#progresspayload) | - -#### Returns - -[`MultiProgress`](MultiProgress.md) - -#### Inherited from - -[Progress](Progress.md).[tick](Progress.md#tick) - -___ - -### update - -▸ **update**(`payload?`): [`MultiProgress`](MultiProgress.md) - -Update the progress bar - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `payload?` | [`ProgressPayload`](../README.md#progresspayload) | - -#### Returns - -[`MultiProgress`](MultiProgress.md) - -#### Inherited from - -[Progress](Progress.md).[update](Progress.md#update) diff --git a/packages/node-utilities/docs/classes/MultiProgressChild.md b/packages/node-utilities/docs/classes/MultiProgressChild.md deleted file mode 100644 index aa4437b7..00000000 --- a/packages/node-utilities/docs/classes/MultiProgressChild.md +++ /dev/null @@ -1,316 +0,0 @@ -# Class: MultiProgressChild - -Multi-progress child bar - -## Hierarchy - -- [`Progress`](Progress.md) - - ↳ **`MultiProgressChild`** - -## Table of contents - -### Properties - -- [bar](MultiProgressChild.md#bar) -- [id](MultiProgressChild.md#id) -- [options](MultiProgressChild.md#options) -- [out](MultiProgressChild.md#out) - -### Methods - -- [eta](MultiProgressChild.md#eta) -- [fail](MultiProgressChild.md#fail) -- [finish](MultiProgressChild.md#finish) -- [message](MultiProgressChild.md#message) -- [set](MultiProgressChild.md#set) -- [setTotal](MultiProgressChild.md#settotal) -- [start](MultiProgressChild.md#start) -- [stop](MultiProgressChild.md#stop) -- [tick](MultiProgressChild.md#tick) -- [update](MultiProgressChild.md#update) - -## Properties - -### bar - -• **bar**: `SingleBar` - -#### Inherited from - -[Progress](Progress.md).[bar](Progress.md#bar) - -___ - -### id - -• **id**: `string` - -___ - -### options - -• **options**: [`MultiProgressChildConfig`](../interfaces/MultiProgressChildConfig.md) - -#### Overrides - -[Progress](Progress.md).[options](Progress.md#options) - -___ - -### out - -• **out**: `Out` - -#### Inherited from - -[Progress](Progress.md).[out](Progress.md#out) - -## Methods - -### eta - -▸ **eta**(): `string` \| `number` - -Get the ETA - -#### Returns - -`string` \| `number` - -#### Inherited from - -[Progress](Progress.md).[eta](Progress.md#eta) - -___ - -### fail - -▸ **fail**(`...messages`): [`MultiProgressChild`](MultiProgressChild.md) - -Fail and stop the progress bar - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `...messages` | `any`[] | - -#### Returns - -[`MultiProgressChild`](MultiProgressChild.md) - -#### Inherited from - -[Progress](Progress.md).[fail](Progress.md#fail) - -___ - -### finish - -▸ **finish**(`...messages`): [`MultiProgressChild`](MultiProgressChild.md) - -Succeed and stop the progress bar - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `...messages` | `any`[] | - -#### Returns - -[`MultiProgressChild`](MultiProgressChild.md) - -#### Inherited from - -[Progress](Progress.md).[finish](Progress.md#finish) - -___ - -### message - -▸ **message**(`message`): [`MultiProgressChild`](MultiProgressChild.md) - -Set the progress bar message - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `message` | `string` | - -#### Returns - -[`MultiProgressChild`](MultiProgressChild.md) - -#### Inherited from - -[Progress](Progress.md).[message](Progress.md#message) - -___ - -### set - -▸ **set**(`value`, `payload?`): `void` - -Set the progress bar current value - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `number` | -| `payload?` | [`ProgressPayload`](../README.md#progresspayload) | - -#### Returns - -`void` - -#### Inherited from - -[Progress](Progress.md).[set](Progress.md#set) - -___ - -### setTotal - -▸ **setTotal**(`total`): [`MultiProgressChild`](MultiProgressChild.md) - -Set the progress bar total - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `total` | `number` | - -#### Returns - -[`MultiProgressChild`](MultiProgressChild.md) - -#### Inherited from - -[Progress](Progress.md).[setTotal](Progress.md#settotal) - -___ - -### start - -▸ **start**(`options?`): [`MultiProgressChild`](MultiProgressChild.md) - -Start the progress bar - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `options?` | `Partial`<[`ProgressConfig`](../interfaces/ProgressConfig.md)\> | - -#### Returns - -[`MultiProgressChild`](MultiProgressChild.md) - -#### Inherited from - -[Progress](Progress.md).[start](Progress.md#start) - -___ - -### stop - -▸ **stop**(`...messages`): [`MultiProgressChild`](MultiProgressChild.md) - -Stop the progress bar - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `...messages` | `any`[] | - -#### Returns - -[`MultiProgressChild`](MultiProgressChild.md) - -#### Inherited from - -[Progress](Progress.md).[stop](Progress.md#stop) - -___ - -### tick - -▸ **tick**(`payload`): [`MultiProgressChild`](MultiProgressChild.md) - -Tick the progress - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `payload` | [`ProgressPayload`](../README.md#progresspayload) | - -#### Returns - -[`MultiProgressChild`](MultiProgressChild.md) - -#### Inherited from - -[Progress](Progress.md).[tick](Progress.md#tick) - -▸ **tick**(`value?`, `payload?`): [`MultiProgressChild`](MultiProgressChild.md) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value?` | `number` | -| `payload?` | [`ProgressPayload`](../README.md#progresspayload) | - -#### Returns - -[`MultiProgressChild`](MultiProgressChild.md) - -#### Inherited from - -[Progress](Progress.md).[tick](Progress.md#tick) - -▸ **tick**(`message`, `payload?`): [`MultiProgressChild`](MultiProgressChild.md) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `message` | `string` | -| `payload?` | [`ProgressPayload`](../README.md#progresspayload) | - -#### Returns - -[`MultiProgressChild`](MultiProgressChild.md) - -#### Inherited from - -[Progress](Progress.md).[tick](Progress.md#tick) - -___ - -### update - -▸ **update**(`payload?`): [`MultiProgressChild`](MultiProgressChild.md) - -Update the progress bar - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `payload?` | [`ProgressPayload`](../README.md#progresspayload) | - -#### Returns - -[`MultiProgressChild`](MultiProgressChild.md) - -#### Inherited from - -[Progress](Progress.md).[update](Progress.md#update) diff --git a/packages/node-utilities/docs/classes/Progress.md b/packages/node-utilities/docs/classes/Progress.md deleted file mode 100644 index 439e3635..00000000 --- a/packages/node-utilities/docs/classes/Progress.md +++ /dev/null @@ -1,271 +0,0 @@ -# Class: Progress - -Progress bar. Uses cli-progress and @snickbit/out to output progress. - -**`See`** - -https://github.com/npkgz/cli-progress - -## Hierarchy - -- **`Progress`** - - ↳ [`MultiProgress`](MultiProgress.md) - - ↳ [`MultiProgressChild`](MultiProgressChild.md) - -## Table of contents - -### Constructors - -- [constructor](Progress.md#constructor) - -### Properties - -- [bar](Progress.md#bar) -- [options](Progress.md#options) -- [out](Progress.md#out) - -### Methods - -- [eta](Progress.md#eta) -- [fail](Progress.md#fail) -- [finish](Progress.md#finish) -- [message](Progress.md#message) -- [set](Progress.md#set) -- [setTotal](Progress.md#settotal) -- [start](Progress.md#start) -- [stop](Progress.md#stop) -- [tick](Progress.md#tick) -- [update](Progress.md#update) - -## Constructors - -### constructor - -• **new Progress**(`options?`) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `options?` | `Partial`<[`ProgressConfig`](../interfaces/ProgressConfig.md)\> | - -## Properties - -### bar - -• **bar**: `SingleBar` - -___ - -### options - -• **options**: [`ProgressConfig`](../interfaces/ProgressConfig.md) - -___ - -### out - -• **out**: `Out` - -## Methods - -### eta - -▸ **eta**(): `string` \| `number` - -Get the ETA - -#### Returns - -`string` \| `number` - -___ - -### fail - -▸ **fail**(`...messages`): [`Progress`](Progress.md) - -Fail and stop the progress bar - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `...messages` | `any`[] | - -#### Returns - -[`Progress`](Progress.md) - -___ - -### finish - -▸ **finish**(`...messages`): [`Progress`](Progress.md) - -Succeed and stop the progress bar - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `...messages` | `any`[] | - -#### Returns - -[`Progress`](Progress.md) - -___ - -### message - -▸ **message**(`message`): [`Progress`](Progress.md) - -Set the progress bar message - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `message` | `string` | - -#### Returns - -[`Progress`](Progress.md) - -___ - -### set - -▸ **set**(`value`, `payload?`): `void` - -Set the progress bar current value - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `number` | -| `payload?` | [`ProgressPayload`](../README.md#progresspayload) | - -#### Returns - -`void` - -___ - -### setTotal - -▸ **setTotal**(`total`): [`Progress`](Progress.md) - -Set the progress bar total - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `total` | `number` | - -#### Returns - -[`Progress`](Progress.md) - -___ - -### start - -▸ **start**(`options?`): [`Progress`](Progress.md) - -Start the progress bar - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `options?` | `Partial`<[`ProgressConfig`](../interfaces/ProgressConfig.md)\> | - -#### Returns - -[`Progress`](Progress.md) - -___ - -### stop - -▸ **stop**(`...messages`): [`Progress`](Progress.md) - -Stop the progress bar - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `...messages` | `any`[] | - -#### Returns - -[`Progress`](Progress.md) - -___ - -### tick - -▸ **tick**(`payload`): [`Progress`](Progress.md) - -Tick the progress - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `payload` | [`ProgressPayload`](../README.md#progresspayload) | - -#### Returns - -[`Progress`](Progress.md) - -▸ **tick**(`value?`, `payload?`): [`Progress`](Progress.md) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value?` | `number` | -| `payload?` | [`ProgressPayload`](../README.md#progresspayload) | - -#### Returns - -[`Progress`](Progress.md) - -▸ **tick**(`message`, `payload?`): [`Progress`](Progress.md) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `message` | `string` | -| `payload?` | [`ProgressPayload`](../README.md#progresspayload) | - -#### Returns - -[`Progress`](Progress.md) - -___ - -### update - -▸ **update**(`payload?`): [`Progress`](Progress.md) - -Update the progress bar - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `payload?` | [`ProgressPayload`](../README.md#progresspayload) | - -#### Returns - -[`Progress`](Progress.md) diff --git a/packages/node-utilities/docs/classes/Spinner.md b/packages/node-utilities/docs/classes/Spinner.md deleted file mode 100644 index ca886109..00000000 --- a/packages/node-utilities/docs/classes/Spinner.md +++ /dev/null @@ -1,189 +0,0 @@ -# Class: Spinner - -Spinner. Uses nanospinner to show spinners in the terminal. - -**`See`** - -https://github.com/usmanyunusov/nanospinner - -**`Deprecated`** - -use @snickbit/spinner instead - -## Table of contents - -### Constructors - -- [constructor](Spinner.md#constructor) - -### Properties - -- [out](Spinner.md#out) -- [preload\_message](Spinner.md#preload_message) -- [spinner](Spinner.md#spinner) - -### Methods - -- [error](Spinner.md#error) -- [fail](Spinner.md#fail) -- [finish](Spinner.md#finish) -- [start](Spinner.md#start) -- [stop](Spinner.md#stop) -- [text](Spinner.md#text) -- [update](Spinner.md#update) - -## Constructors - -### constructor - -• **new Spinner**(`options?`) - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `options?` | `string` \| `Partial`<[`SpinnerConfig`](../interfaces/SpinnerConfig.md)\> | - -## Properties - -### out - -• **out**: `Out` - -___ - -### preload\_message - -• **preload\_message**: `string` = `''` - -___ - -### spinner - -• **spinner**: `any` - -## Methods - -### error - -▸ **error**(`options?`): [`Spinner`](Spinner.md) - -Error and stop the spinner - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `options?` | `string` \| `Partial`<[`SpinnerConfig`](../interfaces/SpinnerConfig.md)\> | - -#### Returns - -[`Spinner`](Spinner.md) - -___ - -### fail - -▸ **fail**(`options?`): [`Spinner`](Spinner.md) - -Fail and stop the spinner - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `options?` | `string` \| `Partial`<[`SpinnerConfig`](../interfaces/SpinnerConfig.md)\> | - -#### Returns - -[`Spinner`](Spinner.md) - -___ - -### finish - -▸ **finish**(`options?`): [`Spinner`](Spinner.md) - -Succeed and stop the spinner - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `options?` | `string` \| `Partial`<[`SpinnerConfig`](../interfaces/SpinnerConfig.md)\> | - -#### Returns - -[`Spinner`](Spinner.md) - -___ - -### start - -▸ **start**(`options?`): [`Spinner`](Spinner.md) - -Start the spinner - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `options?` | `string` \| `Partial`<[`SpinnerConfig`](../interfaces/SpinnerConfig.md)\> | - -#### Returns - -[`Spinner`](Spinner.md) - -___ - -### stop - -▸ **stop**(`options?`): [`Spinner`](Spinner.md) - -Stop the spinner - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `options?` | `string` \| `Partial`<[`SpinnerConfig`](../interfaces/SpinnerConfig.md)\> | - -#### Returns - -[`Spinner`](Spinner.md) - -___ - -### text - -▸ **text**(`message`): [`Spinner`](Spinner.md) - -Set the spinner text - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `message` | `string` | - -#### Returns - -[`Spinner`](Spinner.md) - -___ - -### update - -▸ **update**(`options`): [`Spinner`](Spinner.md) - -Update the spinner - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `options` | `string` \| `Partial`<[`SpinnerConfig`](../interfaces/SpinnerConfig.md)\> | - -#### Returns - -[`Spinner`](Spinner.md) diff --git a/packages/node-utilities/docs/interfaces/AutoCompleteMultiSelectQuestion.md b/packages/node-utilities/docs/interfaces/AutoCompleteMultiSelectQuestion.md deleted file mode 100644 index 37215c4b..00000000 --- a/packages/node-utilities/docs/interfaces/AutoCompleteMultiSelectQuestion.md +++ /dev/null @@ -1,197 +0,0 @@ -# Interface: AutoCompleteMultiSelectQuestion - -## Hierarchy - -- `Omit`<[`MultiSelectQuestion`](MultiSelectQuestion.md), ``"type"``\> - - ↳ **`AutoCompleteMultiSelectQuestion`** - -## Table of contents - -### Properties - -- [choices](AutoCompleteMultiSelectQuestion.md#choices) -- [format](AutoCompleteMultiSelectQuestion.md#format) -- [hint](AutoCompleteMultiSelectQuestion.md#hint) -- [instructions](AutoCompleteMultiSelectQuestion.md#instructions) -- [max](AutoCompleteMultiSelectQuestion.md#max) -- [message](AutoCompleteMultiSelectQuestion.md#message) -- [min](AutoCompleteMultiSelectQuestion.md#min) -- [name](AutoCompleteMultiSelectQuestion.md#name) -- [optionsPerPage](AutoCompleteMultiSelectQuestion.md#optionsperpage) -- [stdin](AutoCompleteMultiSelectQuestion.md#stdin) -- [stdout](AutoCompleteMultiSelectQuestion.md#stdout) -- [type](AutoCompleteMultiSelectQuestion.md#type) -- [warn](AutoCompleteMultiSelectQuestion.md#warn) - -### Methods - -- [onRender](AutoCompleteMultiSelectQuestion.md#onrender) -- [onState](AutoCompleteMultiSelectQuestion.md#onstate) - -## Properties - -### choices - -• **choices**: [`ChoiceDefinition`](ChoiceDefinition.md) \| [`ChoiceOption`](../README.md#choiceoption)[] - -#### Inherited from - -Omit.choices - -___ - -### format - -• **format**: [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -Omit.format - -___ - -### hint - -• **hint**: `string` - -#### Inherited from - -Omit.hint - -___ - -### instructions - -• **instructions**: `string` \| `boolean` - -#### Inherited from - -Omit.instructions - -___ - -### max - -• **max**: `number` - -#### Inherited from - -Omit.max - -___ - -### message - -• **message**: `string` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -Omit.message - -___ - -### min - -• **min**: `number` - -#### Inherited from - -Omit.min - -___ - -### name - -• **name**: `string` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -Omit.name - -___ - -### optionsPerPage - -• **optionsPerPage**: `number` - -#### Inherited from - -Omit.optionsPerPage - -___ - -### stdin - -• **stdin**: `internal` - -#### Inherited from - -Omit.stdin - -___ - -### stdout - -• **stdout**: `internal` - -#### Inherited from - -Omit.stdout - -___ - -### type - -• **type**: ``"autocompleteMultiselect"`` \| [`PromptTypeMethod`](PromptTypeMethod.md)<``"autocompleteMultiselect"``\> - -___ - -### warn - -• **warn**: `string` - -#### Inherited from - -Omit.warn - -## Methods - -### onRender - -▸ **onRender**(`this`, `kluer`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `this` | `prompts` | -| `kluer` | `any` | - -#### Returns - -`void` - -#### Inherited from - -Omit.onRender - -___ - -### onState - -▸ **onState**(`state`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `state` | [`PromptState`](PromptState.md) | - -#### Returns - -`void` - -#### Inherited from - -Omit.onState diff --git a/packages/node-utilities/docs/interfaces/AutoCompleteQuestion.md b/packages/node-utilities/docs/interfaces/AutoCompleteQuestion.md deleted file mode 100644 index 3cd4178a..00000000 --- a/packages/node-utilities/docs/interfaces/AutoCompleteQuestion.md +++ /dev/null @@ -1,183 +0,0 @@ -# Interface: AutoCompleteQuestion - -## Hierarchy - -- `BaseQuestion`<`number` \| `string`\> - -- `QuestionChoices` - - ↳ **`AutoCompleteQuestion`** - -## Table of contents - -### Properties - -- [choices](AutoCompleteQuestion.md#choices) -- [clearFirst](AutoCompleteQuestion.md#clearfirst) -- [fallback](AutoCompleteQuestion.md#fallback) -- [format](AutoCompleteQuestion.md#format) -- [initial](AutoCompleteQuestion.md#initial) -- [limit](AutoCompleteQuestion.md#limit) -- [message](AutoCompleteQuestion.md#message) -- [name](AutoCompleteQuestion.md#name) -- [stdin](AutoCompleteQuestion.md#stdin) -- [stdout](AutoCompleteQuestion.md#stdout) -- [type](AutoCompleteQuestion.md#type) - -### Methods - -- [onRender](AutoCompleteQuestion.md#onrender) -- [onState](AutoCompleteQuestion.md#onstate) -- [suggest](AutoCompleteQuestion.md#suggest) - -## Properties - -### choices - -• **choices**: [`ChoiceDefinition`](ChoiceDefinition.md) \| [`ChoiceOption`](../README.md#choiceoption)[] - -#### Inherited from - -QuestionChoices.choices - -___ - -### clearFirst - -• **clearFirst**: `boolean` - -___ - -### fallback - -• **fallback**: `string` - -___ - -### format - -• **format**: [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.format - -___ - -### initial - -• **initial**: `string` \| `number` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.initial - -___ - -### limit - -• **limit**: `number` - -___ - -### message - -• **message**: `string` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.message - -___ - -### name - -• **name**: `string` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.name - -___ - -### stdin - -• **stdin**: `internal` - -#### Inherited from - -BaseQuestion.stdin - -___ - -### stdout - -• **stdout**: `internal` - -#### Inherited from - -BaseQuestion.stdout - -___ - -### type - -• **type**: ``"autocomplete"`` \| [`PromptTypeMethod`](PromptTypeMethod.md)<``"autocomplete"``\> - -## Methods - -### onRender - -▸ **onRender**(`this`, `kluer`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `this` | `prompts` | -| `kluer` | `any` | - -#### Returns - -`void` - -#### Inherited from - -BaseQuestion.onRender - -___ - -### onState - -▸ **onState**(`state`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `state` | [`PromptState`](PromptState.md) | - -#### Returns - -`void` - -#### Inherited from - -BaseQuestion.onState - -___ - -### suggest - -▸ **suggest**(`input`, `choices`): `Promise`<`string`[]\> - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `input` | `any` | -| `choices` | `any` | - -#### Returns - -`Promise`<`string`[]\> diff --git a/packages/node-utilities/docs/interfaces/CLIProgressOptions.md b/packages/node-utilities/docs/interfaces/CLIProgressOptions.md deleted file mode 100644 index 34703915..00000000 --- a/packages/node-utilities/docs/interfaces/CLIProgressOptions.md +++ /dev/null @@ -1,77 +0,0 @@ -# Interface: CLIProgressOptions - -## Table of contents - -### Properties - -- [barCompleteChar](CLIProgressOptions.md#barcompletechar) -- [barIncompleteChar](CLIProgressOptions.md#barincompletechar) -- [etaBuffer](CLIProgressOptions.md#etabuffer) -- [format](CLIProgressOptions.md#format) -- [fps](CLIProgressOptions.md#fps) -- [hideCursor](CLIProgressOptions.md#hidecursor) -- [linewrap](CLIProgressOptions.md#linewrap) - -### Methods - -- [formatValue](CLIProgressOptions.md#formatvalue) - -## Properties - -### barCompleteChar - -• **barCompleteChar**: `string` - -___ - -### barIncompleteChar - -• **barIncompleteChar**: `string` - -___ - -### etaBuffer - -• **etaBuffer**: `number` - -___ - -### format - -• **format**: `any` - -___ - -### fps - -• **fps**: `number` - -___ - -### hideCursor - -• **hideCursor**: `boolean` - -___ - -### linewrap - -• **linewrap**: `string` - -## Methods - -### formatValue - -▸ `Optional` **formatValue**(`v`, `options`, `type`): `any` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `v` | `any` | -| `options` | `any` | -| `type` | `any` | - -#### Returns - -`any` diff --git a/packages/node-utilities/docs/interfaces/ChoiceDefinition.md b/packages/node-utilities/docs/interfaces/ChoiceDefinition.md deleted file mode 100644 index 63472531..00000000 --- a/packages/node-utilities/docs/interfaces/ChoiceDefinition.md +++ /dev/null @@ -1,20 +0,0 @@ -# Interface: ChoiceDefinition - -## Table of contents - -### Properties - -- [title](ChoiceDefinition.md#title) -- [value](ChoiceDefinition.md#value) - -## Properties - -### title - -• **title**: `string` - -___ - -### value - -• **value**: `any` diff --git a/packages/node-utilities/docs/interfaces/ConfirmQuestion.md b/packages/node-utilities/docs/interfaces/ConfirmQuestion.md deleted file mode 100644 index 2cb3274c..00000000 --- a/packages/node-utilities/docs/interfaces/ConfirmQuestion.md +++ /dev/null @@ -1,144 +0,0 @@ -# Interface: ConfirmQuestion - -## Hierarchy - -- `BaseQuestion`<`boolean`\> - -- `QuestionChoices` - - ↳ **`ConfirmQuestion`** - -## Table of contents - -### Properties - -- [choices](ConfirmQuestion.md#choices) -- [format](ConfirmQuestion.md#format) -- [initial](ConfirmQuestion.md#initial) -- [message](ConfirmQuestion.md#message) -- [name](ConfirmQuestion.md#name) -- [stdin](ConfirmQuestion.md#stdin) -- [stdout](ConfirmQuestion.md#stdout) -- [type](ConfirmQuestion.md#type) - -### Methods - -- [onRender](ConfirmQuestion.md#onrender) -- [onState](ConfirmQuestion.md#onstate) - -## Properties - -### choices - -• **choices**: [`ChoiceDefinition`](ChoiceDefinition.md) \| [`ChoiceOption`](../README.md#choiceoption)[] - -#### Inherited from - -QuestionChoices.choices - -___ - -### format - -• **format**: [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.format - -___ - -### initial - -• **initial**: `boolean` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.initial - -___ - -### message - -• **message**: `string` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.message - -___ - -### name - -• **name**: `string` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.name - -___ - -### stdin - -• **stdin**: `internal` - -#### Inherited from - -BaseQuestion.stdin - -___ - -### stdout - -• **stdout**: `internal` - -#### Inherited from - -BaseQuestion.stdout - -___ - -### type - -• **type**: ``"confirm"`` \| [`PromptTypeMethod`](PromptTypeMethod.md)<``"confirm"``\> - -## Methods - -### onRender - -▸ **onRender**(`this`, `kluer`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `this` | `prompts` | -| `kluer` | `any` | - -#### Returns - -`void` - -#### Inherited from - -BaseQuestion.onRender - -___ - -### onState - -▸ **onState**(`state`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `state` | [`PromptState`](PromptState.md) | - -#### Returns - -`void` - -#### Inherited from - -BaseQuestion.onState diff --git a/packages/node-utilities/docs/interfaces/DateQuestion.md b/packages/node-utilities/docs/interfaces/DateQuestion.md deleted file mode 100644 index 3dae88e0..00000000 --- a/packages/node-utilities/docs/interfaces/DateQuestion.md +++ /dev/null @@ -1,169 +0,0 @@ -# Interface: DateQuestion - -## Hierarchy - -- `BaseQuestion`<`Date`\> - -- `QuestionMinMax` - - ↳ **`DateQuestion`** - -## Table of contents - -### Properties - -- [format](DateQuestion.md#format) -- [initial](DateQuestion.md#initial) -- [locales](DateQuestion.md#locales) -- [mask](DateQuestion.md#mask) -- [max](DateQuestion.md#max) -- [message](DateQuestion.md#message) -- [min](DateQuestion.md#min) -- [name](DateQuestion.md#name) -- [stdin](DateQuestion.md#stdin) -- [stdout](DateQuestion.md#stdout) -- [type](DateQuestion.md#type) - -### Methods - -- [onRender](DateQuestion.md#onrender) -- [onState](DateQuestion.md#onstate) - -## Properties - -### format - -• **format**: [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.format - -___ - -### initial - -• **initial**: `Date` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.initial - -___ - -### locales - -• **locales**: [`PromptsLocales`](PromptsLocales.md) - -___ - -### mask - -• **mask**: `string` - -___ - -### max - -• **max**: `number` - -#### Inherited from - -QuestionMinMax.max - -___ - -### message - -• **message**: `string` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.message - -___ - -### min - -• **min**: `number` - -#### Inherited from - -QuestionMinMax.min - -___ - -### name - -• **name**: `string` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.name - -___ - -### stdin - -• **stdin**: `internal` - -#### Inherited from - -BaseQuestion.stdin - -___ - -### stdout - -• **stdout**: `internal` - -#### Inherited from - -BaseQuestion.stdout - -___ - -### type - -• **type**: ``"date"`` \| [`PromptTypeMethod`](PromptTypeMethod.md)<``"date"``\> - -## Methods - -### onRender - -▸ **onRender**(`this`, `kluer`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `this` | `prompts` | -| `kluer` | `any` | - -#### Returns - -`void` - -#### Inherited from - -BaseQuestion.onRender - -___ - -### onState - -▸ **onState**(`state`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `state` | [`PromptState`](PromptState.md) | - -#### Returns - -`void` - -#### Inherited from - -BaseQuestion.onState diff --git a/packages/node-utilities/docs/interfaces/FindUpOptions.md b/packages/node-utilities/docs/interfaces/FindUpOptions.md deleted file mode 100644 index 99090534..00000000 --- a/packages/node-utilities/docs/interfaces/FindUpOptions.md +++ /dev/null @@ -1,20 +0,0 @@ -# Interface: FindUpOptions - -## Table of contents - -### Properties - -- [cwd](FindUpOptions.md#cwd) -- [distance](FindUpOptions.md#distance) - -## Properties - -### cwd - -• **cwd**: `string` - -___ - -### distance - -• **distance**: `number` diff --git a/packages/node-utilities/docs/interfaces/ImportDefinition.md b/packages/node-utilities/docs/interfaces/ImportDefinition.md deleted file mode 100644 index 0dfa2249..00000000 --- a/packages/node-utilities/docs/interfaces/ImportDefinition.md +++ /dev/null @@ -1,68 +0,0 @@ -# Interface: ImportDefinition - -## Type parameters - -| Name | Type | -| :------ | :------ | -| `I` | extends [`ImportMethod`](../README.md#importmethod) = [`ImportMethod`](../README.md#importmethod) | -| `Args` | `any` | -| `Results` | `any` | - -## Hierarchy - -- [`ImportMethod`](../README.md#importmethod)<`Args`, `Results`\> - - ↳ **`ImportDefinition`** - -## Callable - -### ImportDefinition - -▸ **ImportDefinition**(`...args`): `Results` \| `Promise`<`Results`\> - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `...args` | `Args`[] | - -#### Returns - -`Results` \| `Promise`<`Results`\> - -## Indexable - -▪ [key: `string`]: `any` - -## Table of contents - -### Properties - -- [aliases](ImportDefinition.md#aliases) -- [default](ImportDefinition.md#default) -- [description](ImportDefinition.md#description) -- [name](ImportDefinition.md#name) - -## Properties - -### aliases - -• `Optional` **aliases**: `string`[] - -___ - -### default - -• **default**: `I` \| [`ImportMethod`](../README.md#importmethod)<`Args`, `Results`\> \| [`ImportDefinition`](ImportDefinition.md)<[`ImportMethod`](../README.md#importmethod)<`any`, `any`\>, `any`, `any`\>[] \| [`ImportDefinition`](ImportDefinition.md)<`I`, `any`, `any`\> - -___ - -### description - -• `Optional` **description**: `string` - -___ - -### name - -• `Optional` **name**: `string` diff --git a/packages/node-utilities/docs/interfaces/InvisibleQuestion.md b/packages/node-utilities/docs/interfaces/InvisibleQuestion.md deleted file mode 100644 index 02c09ca7..00000000 --- a/packages/node-utilities/docs/interfaces/InvisibleQuestion.md +++ /dev/null @@ -1,131 +0,0 @@ -# Interface: InvisibleQuestion - -## Hierarchy - -- `BaseQuestion` - - ↳ **`InvisibleQuestion`** - -## Table of contents - -### Properties - -- [format](InvisibleQuestion.md#format) -- [initial](InvisibleQuestion.md#initial) -- [message](InvisibleQuestion.md#message) -- [name](InvisibleQuestion.md#name) -- [stdin](InvisibleQuestion.md#stdin) -- [stdout](InvisibleQuestion.md#stdout) -- [type](InvisibleQuestion.md#type) - -### Methods - -- [onRender](InvisibleQuestion.md#onrender) -- [onState](InvisibleQuestion.md#onstate) - -## Properties - -### format - -• **format**: [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.format - -___ - -### initial - -• **initial**: `string` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.initial - -___ - -### message - -• **message**: `string` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.message - -___ - -### name - -• **name**: `string` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.name - -___ - -### stdin - -• **stdin**: `internal` - -#### Inherited from - -BaseQuestion.stdin - -___ - -### stdout - -• **stdout**: `internal` - -#### Inherited from - -BaseQuestion.stdout - -___ - -### type - -• **type**: ``"invisible"`` \| [`PromptTypeMethod`](PromptTypeMethod.md)<``"invisible"``\> - -## Methods - -### onRender - -▸ **onRender**(`this`, `kluer`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `this` | `prompts` | -| `kluer` | `any` | - -#### Returns - -`void` - -#### Inherited from - -BaseQuestion.onRender - -___ - -### onState - -▸ **onState**(`state`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `state` | [`PromptState`](PromptState.md) | - -#### Returns - -`void` - -#### Inherited from - -BaseQuestion.onState diff --git a/packages/node-utilities/docs/interfaces/ListQuestion.md b/packages/node-utilities/docs/interfaces/ListQuestion.md deleted file mode 100644 index 4fb5a324..00000000 --- a/packages/node-utilities/docs/interfaces/ListQuestion.md +++ /dev/null @@ -1,138 +0,0 @@ -# Interface: ListQuestion - -## Hierarchy - -- `BaseQuestion` - - ↳ **`ListQuestion`** - -## Table of contents - -### Properties - -- [format](ListQuestion.md#format) -- [initial](ListQuestion.md#initial) -- [message](ListQuestion.md#message) -- [name](ListQuestion.md#name) -- [separator](ListQuestion.md#separator) -- [stdin](ListQuestion.md#stdin) -- [stdout](ListQuestion.md#stdout) -- [type](ListQuestion.md#type) - -### Methods - -- [onRender](ListQuestion.md#onrender) -- [onState](ListQuestion.md#onstate) - -## Properties - -### format - -• **format**: [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.format - -___ - -### initial - -• **initial**: `string` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.initial - -___ - -### message - -• **message**: `string` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.message - -___ - -### name - -• **name**: `string` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.name - -___ - -### separator - -• **separator**: `string` - -___ - -### stdin - -• **stdin**: `internal` - -#### Inherited from - -BaseQuestion.stdin - -___ - -### stdout - -• **stdout**: `internal` - -#### Inherited from - -BaseQuestion.stdout - -___ - -### type - -• **type**: ``"list"`` \| [`PromptTypeMethod`](PromptTypeMethod.md)<``"list"``\> - -## Methods - -### onRender - -▸ **onRender**(`this`, `kluer`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `this` | `prompts` | -| `kluer` | `any` | - -#### Returns - -`void` - -#### Inherited from - -BaseQuestion.onRender - -___ - -### onState - -▸ **onState**(`state`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `state` | [`PromptState`](PromptState.md) | - -#### Returns - -`void` - -#### Inherited from - -BaseQuestion.onState diff --git a/packages/node-utilities/docs/interfaces/MultiProgressChildConfig.md b/packages/node-utilities/docs/interfaces/MultiProgressChildConfig.md deleted file mode 100644 index 06bf1277..00000000 --- a/packages/node-utilities/docs/interfaces/MultiProgressChildConfig.md +++ /dev/null @@ -1,114 +0,0 @@ -# Interface: MultiProgressChildConfig - -## Hierarchy - -- [`ProgressConfig`](ProgressConfig.md) - - ↳ **`MultiProgressChildConfig`** - -## Table of contents - -### Properties - -- [autoStart](MultiProgressChildConfig.md#autostart) -- [config](MultiProgressChildConfig.md#config) -- [current](MultiProgressChildConfig.md#current) -- [id](MultiProgressChildConfig.md#id) -- [message](MultiProgressChildConfig.md#message) -- [name](MultiProgressChildConfig.md#name) -- [out](MultiProgressChildConfig.md#out) -- [parent](MultiProgressChildConfig.md#parent) -- [total](MultiProgressChildConfig.md#total) -- [valueFormat](MultiProgressChildConfig.md#valueformat) - -## Properties - -### autoStart - -• **autoStart**: `boolean` - -#### Inherited from - -[ProgressConfig](ProgressConfig.md).[autoStart](ProgressConfig.md#autostart) - -___ - -### config - -• **config**: `Partial`<[`CLIProgressOptions`](CLIProgressOptions.md)\> - -#### Inherited from - -[ProgressConfig](ProgressConfig.md).[config](ProgressConfig.md#config) - -___ - -### current - -• **current**: `number` - -#### Inherited from - -[ProgressConfig](ProgressConfig.md).[current](ProgressConfig.md#current) - -___ - -### id - -• **id**: `string` - -___ - -### message - -• **message**: `string` - -#### Inherited from - -[ProgressConfig](ProgressConfig.md).[message](ProgressConfig.md#message) - -___ - -### name - -• `Optional` **name**: `string` - -#### Inherited from - -[ProgressConfig](ProgressConfig.md).[name](ProgressConfig.md#name) - -___ - -### out - -• `Optional` **out**: `Out` - -#### Inherited from - -[ProgressConfig](ProgressConfig.md).[out](ProgressConfig.md#out) - -___ - -### parent - -• **parent**: `string` - -___ - -### total - -• **total**: `number` - -#### Inherited from - -[ProgressConfig](ProgressConfig.md).[total](ProgressConfig.md#total) - -___ - -### valueFormat - -• **valueFormat**: `string` - -#### Inherited from - -[ProgressConfig](ProgressConfig.md).[valueFormat](ProgressConfig.md#valueformat) diff --git a/packages/node-utilities/docs/interfaces/MultiSelectQuestion.md b/packages/node-utilities/docs/interfaces/MultiSelectQuestion.md deleted file mode 100644 index 0bfab1c4..00000000 --- a/packages/node-utilities/docs/interfaces/MultiSelectQuestion.md +++ /dev/null @@ -1,195 +0,0 @@ -# Interface: MultiSelectQuestion - -## Hierarchy - -- `Omit`<`BaseQuestion`, ``"initial"``\> - -- `QuestionMinMax` - -- `QuestionHints` - -- `QuestionChoices` - - ↳ **`MultiSelectQuestion`** - -## Table of contents - -### Properties - -- [choices](MultiSelectQuestion.md#choices) -- [format](MultiSelectQuestion.md#format) -- [hint](MultiSelectQuestion.md#hint) -- [instructions](MultiSelectQuestion.md#instructions) -- [max](MultiSelectQuestion.md#max) -- [message](MultiSelectQuestion.md#message) -- [min](MultiSelectQuestion.md#min) -- [name](MultiSelectQuestion.md#name) -- [optionsPerPage](MultiSelectQuestion.md#optionsperpage) -- [stdin](MultiSelectQuestion.md#stdin) -- [stdout](MultiSelectQuestion.md#stdout) -- [type](MultiSelectQuestion.md#type) -- [warn](MultiSelectQuestion.md#warn) - -### Methods - -- [onRender](MultiSelectQuestion.md#onrender) -- [onState](MultiSelectQuestion.md#onstate) - -## Properties - -### choices - -• **choices**: [`ChoiceDefinition`](ChoiceDefinition.md) \| [`ChoiceOption`](../README.md#choiceoption)[] - -#### Inherited from - -QuestionChoices.choices - -___ - -### format - -• **format**: [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -Omit.format - -___ - -### hint - -• **hint**: `string` - -#### Inherited from - -QuestionHints.hint - -___ - -### instructions - -• **instructions**: `string` \| `boolean` - -___ - -### max - -• **max**: `number` - -#### Inherited from - -QuestionMinMax.max - -___ - -### message - -• **message**: `string` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -Omit.message - -___ - -### min - -• **min**: `number` - -#### Inherited from - -QuestionMinMax.min - -___ - -### name - -• **name**: `string` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -Omit.name - -___ - -### optionsPerPage - -• **optionsPerPage**: `number` - -___ - -### stdin - -• **stdin**: `internal` - -#### Inherited from - -Omit.stdin - -___ - -### stdout - -• **stdout**: `internal` - -#### Inherited from - -Omit.stdout - -___ - -### type - -• **type**: ``"multiselect"`` \| [`PromptTypeMethod`](PromptTypeMethod.md)<``"multiselect"``\> - -___ - -### warn - -• **warn**: `string` - -#### Inherited from - -QuestionHints.warn - -## Methods - -### onRender - -▸ **onRender**(`this`, `kluer`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `this` | `prompts` | -| `kluer` | `any` | - -#### Returns - -`void` - -#### Inherited from - -Omit.onRender - -___ - -### onState - -▸ **onState**(`state`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `state` | [`PromptState`](PromptState.md) | - -#### Returns - -`void` - -#### Inherited from - -Omit.onState diff --git a/packages/node-utilities/docs/interfaces/NumberQuestion.md b/packages/node-utilities/docs/interfaces/NumberQuestion.md deleted file mode 100644 index a50902e6..00000000 --- a/packages/node-utilities/docs/interfaces/NumberQuestion.md +++ /dev/null @@ -1,152 +0,0 @@ -# Interface: NumberQuestion - -## Hierarchy - -- `BaseQuestion`<`number`\> - - ↳ **`NumberQuestion`** - -## Table of contents - -### Properties - -- [float](NumberQuestion.md#float) -- [format](NumberQuestion.md#format) -- [increment](NumberQuestion.md#increment) -- [initial](NumberQuestion.md#initial) -- [message](NumberQuestion.md#message) -- [name](NumberQuestion.md#name) -- [round](NumberQuestion.md#round) -- [stdin](NumberQuestion.md#stdin) -- [stdout](NumberQuestion.md#stdout) -- [type](NumberQuestion.md#type) - -### Methods - -- [onRender](NumberQuestion.md#onrender) -- [onState](NumberQuestion.md#onstate) - -## Properties - -### float - -• **float**: `boolean` - -___ - -### format - -• **format**: [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.format - -___ - -### increment - -• **increment**: `number` - -___ - -### initial - -• **initial**: `number` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.initial - -___ - -### message - -• **message**: `string` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.message - -___ - -### name - -• **name**: `string` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.name - -___ - -### round - -• **round**: `number` - -___ - -### stdin - -• **stdin**: `internal` - -#### Inherited from - -BaseQuestion.stdin - -___ - -### stdout - -• **stdout**: `internal` - -#### Inherited from - -BaseQuestion.stdout - -___ - -### type - -• **type**: ``"number"`` \| [`PromptTypeMethod`](PromptTypeMethod.md)<``"number"``\> - -## Methods - -### onRender - -▸ **onRender**(`this`, `kluer`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `this` | `prompts` | -| `kluer` | `any` | - -#### Returns - -`void` - -#### Inherited from - -BaseQuestion.onRender - -___ - -### onState - -▸ **onState**(`state`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `state` | [`PromptState`](PromptState.md) | - -#### Returns - -`void` - -#### Inherited from - -BaseQuestion.onState diff --git a/packages/node-utilities/docs/interfaces/ParsedImport.md b/packages/node-utilities/docs/interfaces/ParsedImport.md deleted file mode 100644 index c2828e66..00000000 --- a/packages/node-utilities/docs/interfaces/ParsedImport.md +++ /dev/null @@ -1,40 +0,0 @@ -# Interface: ParsedImport - -## Type parameters - -| Name | Type | -| :------ | :------ | -| `I` | extends [`ImportMethod`](../README.md#importmethod) = [`ImportMethod`](../README.md#importmethod) | - -## Table of contents - -### Properties - -- [aliases](ParsedImport.md#aliases) -- [description](ParsedImport.md#description) -- [handler](ParsedImport.md#handler) -- [name](ParsedImport.md#name) - -## Properties - -### aliases - -• **aliases**: `string`[] - -___ - -### description - -• `Optional` **description**: `string` - -___ - -### handler - -• **handler**: `I` - -___ - -### name - -• **name**: `string` diff --git a/packages/node-utilities/docs/interfaces/PasswordQuestion.md b/packages/node-utilities/docs/interfaces/PasswordQuestion.md deleted file mode 100644 index 612fa9ea..00000000 --- a/packages/node-utilities/docs/interfaces/PasswordQuestion.md +++ /dev/null @@ -1,131 +0,0 @@ -# Interface: PasswordQuestion - -## Hierarchy - -- `BaseQuestion` - - ↳ **`PasswordQuestion`** - -## Table of contents - -### Properties - -- [format](PasswordQuestion.md#format) -- [initial](PasswordQuestion.md#initial) -- [message](PasswordQuestion.md#message) -- [name](PasswordQuestion.md#name) -- [stdin](PasswordQuestion.md#stdin) -- [stdout](PasswordQuestion.md#stdout) -- [type](PasswordQuestion.md#type) - -### Methods - -- [onRender](PasswordQuestion.md#onrender) -- [onState](PasswordQuestion.md#onstate) - -## Properties - -### format - -• **format**: [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.format - -___ - -### initial - -• **initial**: `string` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.initial - -___ - -### message - -• **message**: `string` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.message - -___ - -### name - -• **name**: `string` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.name - -___ - -### stdin - -• **stdin**: `internal` - -#### Inherited from - -BaseQuestion.stdin - -___ - -### stdout - -• **stdout**: `internal` - -#### Inherited from - -BaseQuestion.stdout - -___ - -### type - -• **type**: ``"password"`` \| [`PromptTypeMethod`](PromptTypeMethod.md)<``"password"``\> - -## Methods - -### onRender - -▸ **onRender**(`this`, `kluer`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `this` | `prompts` | -| `kluer` | `any` | - -#### Returns - -`void` - -#### Inherited from - -BaseQuestion.onRender - -___ - -### onState - -▸ **onState**(`state`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `state` | [`PromptState`](PromptState.md) | - -#### Returns - -`void` - -#### Inherited from - -BaseQuestion.onState diff --git a/packages/node-utilities/docs/interfaces/ProgressConfig.md b/packages/node-utilities/docs/interfaces/ProgressConfig.md deleted file mode 100644 index b7bc5cb9..00000000 --- a/packages/node-utilities/docs/interfaces/ProgressConfig.md +++ /dev/null @@ -1,68 +0,0 @@ -# Interface: ProgressConfig - -## Hierarchy - -- **`ProgressConfig`** - - ↳ [`MultiProgressChildConfig`](MultiProgressChildConfig.md) - -## Table of contents - -### Properties - -- [autoStart](ProgressConfig.md#autostart) -- [config](ProgressConfig.md#config) -- [current](ProgressConfig.md#current) -- [message](ProgressConfig.md#message) -- [name](ProgressConfig.md#name) -- [out](ProgressConfig.md#out) -- [total](ProgressConfig.md#total) -- [valueFormat](ProgressConfig.md#valueformat) - -## Properties - -### autoStart - -• **autoStart**: `boolean` - -___ - -### config - -• **config**: `Partial`<[`CLIProgressOptions`](CLIProgressOptions.md)\> - -___ - -### current - -• **current**: `number` - -___ - -### message - -• **message**: `string` - -___ - -### name - -• `Optional` **name**: `string` - -___ - -### out - -• `Optional` **out**: `Out` - -___ - -### total - -• **total**: `number` - -___ - -### valueFormat - -• **valueFormat**: `string` diff --git a/packages/node-utilities/docs/interfaces/PromptState.md b/packages/node-utilities/docs/interfaces/PromptState.md deleted file mode 100644 index 467c0119..00000000 --- a/packages/node-utilities/docs/interfaces/PromptState.md +++ /dev/null @@ -1,13 +0,0 @@ -# Interface: PromptState - -## Table of contents - -### Properties - -- [aborted](PromptState.md#aborted) - -## Properties - -### aborted - -• **aborted**: `boolean` diff --git a/packages/node-utilities/docs/interfaces/PromptTypeMethod.md b/packages/node-utilities/docs/interfaces/PromptTypeMethod.md deleted file mode 100644 index f32e40c9..00000000 --- a/packages/node-utilities/docs/interfaces/PromptTypeMethod.md +++ /dev/null @@ -1,25 +0,0 @@ -# Interface: PromptTypeMethod - -## Type parameters - -| Name | Type | -| :------ | :------ | -| `P` | [`PromptType`](../README.md#prompttype) | - -## Callable - -### PromptTypeMethod - -▸ **PromptTypeMethod**(`prev`, `answers`, `previousQuestion`): `P` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `prev` | `string` | -| `answers` | [`Answers`](../README.md#answers) | -| `previousQuestion` | [`Question`](../README.md#question) | - -#### Returns - -`P` diff --git a/packages/node-utilities/docs/interfaces/PromptsLocales.md b/packages/node-utilities/docs/interfaces/PromptsLocales.md deleted file mode 100644 index dedcd178..00000000 --- a/packages/node-utilities/docs/interfaces/PromptsLocales.md +++ /dev/null @@ -1,34 +0,0 @@ -# Interface: PromptsLocales - -## Table of contents - -### Properties - -- [months](PromptsLocales.md#months) -- [monthsShort](PromptsLocales.md#monthsshort) -- [weekdays](PromptsLocales.md#weekdays) -- [weekdaysShort](PromptsLocales.md#weekdaysshort) - -## Properties - -### months - -• **months**: `string`[] - -___ - -### monthsShort - -• **monthsShort**: `string`[] - -___ - -### weekdays - -• **weekdays**: `string`[] - -___ - -### weekdaysShort - -• **weekdaysShort**: `string`[] diff --git a/packages/node-utilities/docs/interfaces/SelectQuestion.md b/packages/node-utilities/docs/interfaces/SelectQuestion.md deleted file mode 100644 index 375f7cd7..00000000 --- a/packages/node-utilities/docs/interfaces/SelectQuestion.md +++ /dev/null @@ -1,168 +0,0 @@ -# Interface: SelectQuestion - -## Hierarchy - -- `BaseQuestion`<`number` \| `string`\> - -- `QuestionHints` - -- `QuestionChoices` - - ↳ **`SelectQuestion`** - -## Table of contents - -### Properties - -- [choices](SelectQuestion.md#choices) -- [format](SelectQuestion.md#format) -- [hint](SelectQuestion.md#hint) -- [initial](SelectQuestion.md#initial) -- [message](SelectQuestion.md#message) -- [name](SelectQuestion.md#name) -- [stdin](SelectQuestion.md#stdin) -- [stdout](SelectQuestion.md#stdout) -- [type](SelectQuestion.md#type) -- [warn](SelectQuestion.md#warn) - -### Methods - -- [onRender](SelectQuestion.md#onrender) -- [onState](SelectQuestion.md#onstate) - -## Properties - -### choices - -• **choices**: [`ChoiceDefinition`](ChoiceDefinition.md) \| [`ChoiceOption`](../README.md#choiceoption)[] - -#### Inherited from - -QuestionChoices.choices - -___ - -### format - -• **format**: [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.format - -___ - -### hint - -• **hint**: `string` - -#### Inherited from - -QuestionHints.hint - -___ - -### initial - -• **initial**: `string` \| `number` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.initial - -___ - -### message - -• **message**: `string` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.message - -___ - -### name - -• **name**: `string` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.name - -___ - -### stdin - -• **stdin**: `internal` - -#### Inherited from - -BaseQuestion.stdin - -___ - -### stdout - -• **stdout**: `internal` - -#### Inherited from - -BaseQuestion.stdout - -___ - -### type - -• **type**: ``"select"`` \| [`PromptTypeMethod`](PromptTypeMethod.md)<``"select"``\> - -___ - -### warn - -• **warn**: `string` - -#### Inherited from - -QuestionHints.warn - -## Methods - -### onRender - -▸ **onRender**(`this`, `kluer`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `this` | `prompts` | -| `kluer` | `any` | - -#### Returns - -`void` - -#### Inherited from - -BaseQuestion.onRender - -___ - -### onState - -▸ **onState**(`state`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `state` | [`PromptState`](PromptState.md) | - -#### Returns - -`void` - -#### Inherited from - -BaseQuestion.onState diff --git a/packages/node-utilities/docs/interfaces/SpinnerConfig.md b/packages/node-utilities/docs/interfaces/SpinnerConfig.md deleted file mode 100644 index f516371d..00000000 --- a/packages/node-utilities/docs/interfaces/SpinnerConfig.md +++ /dev/null @@ -1,48 +0,0 @@ -# Interface: SpinnerConfig - -## Table of contents - -### Properties - -- [color](SpinnerConfig.md#color) -- [frames](SpinnerConfig.md#frames) -- [interval](SpinnerConfig.md#interval) -- [mark](SpinnerConfig.md#mark) -- [stream](SpinnerConfig.md#stream) -- [text](SpinnerConfig.md#text) - -## Properties - -### color - -• **color**: `string` - -___ - -### frames - -• **frames**: `string`[] - -___ - -### interval - -• **interval**: `number` - -___ - -### mark - -• **mark**: `string` - -___ - -### stream - -• **stream**: `any` - -___ - -### text - -• **text**: `string` diff --git a/packages/node-utilities/docs/interfaces/TextQuestion.md b/packages/node-utilities/docs/interfaces/TextQuestion.md deleted file mode 100644 index ae14dc4d..00000000 --- a/packages/node-utilities/docs/interfaces/TextQuestion.md +++ /dev/null @@ -1,138 +0,0 @@ -# Interface: TextQuestion - -## Hierarchy - -- `BaseQuestion` - - ↳ **`TextQuestion`** - -## Table of contents - -### Properties - -- [format](TextQuestion.md#format) -- [initial](TextQuestion.md#initial) -- [message](TextQuestion.md#message) -- [name](TextQuestion.md#name) -- [stdin](TextQuestion.md#stdin) -- [stdout](TextQuestion.md#stdout) -- [style](TextQuestion.md#style) -- [type](TextQuestion.md#type) - -### Methods - -- [onRender](TextQuestion.md#onrender) -- [onState](TextQuestion.md#onstate) - -## Properties - -### format - -• **format**: [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.format - -___ - -### initial - -• **initial**: `string` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.initial - -___ - -### message - -• **message**: `string` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.message - -___ - -### name - -• **name**: `string` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.name - -___ - -### stdin - -• **stdin**: `internal` - -#### Inherited from - -BaseQuestion.stdin - -___ - -### stdout - -• **stdout**: `internal` - -#### Inherited from - -BaseQuestion.stdout - -___ - -### style - -• **style**: ``"default"`` \| ``"invisible"`` \| ``"password"`` \| ``"emoji"`` - -___ - -### type - -• **type**: ``"text"`` \| [`PromptTypeMethod`](PromptTypeMethod.md)<``"text"``\> - -## Methods - -### onRender - -▸ **onRender**(`this`, `kluer`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `this` | `prompts` | -| `kluer` | `any` | - -#### Returns - -`void` - -#### Inherited from - -BaseQuestion.onRender - -___ - -### onState - -▸ **onState**(`state`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `state` | [`PromptState`](PromptState.md) | - -#### Returns - -`void` - -#### Inherited from - -BaseQuestion.onState diff --git a/packages/node-utilities/docs/interfaces/ToggleQuestion.md b/packages/node-utilities/docs/interfaces/ToggleQuestion.md deleted file mode 100644 index b0ac9fbb..00000000 --- a/packages/node-utilities/docs/interfaces/ToggleQuestion.md +++ /dev/null @@ -1,145 +0,0 @@ -# Interface: ToggleQuestion - -## Hierarchy - -- `BaseQuestion`<`boolean`\> - - ↳ **`ToggleQuestion`** - -## Table of contents - -### Properties - -- [active](ToggleQuestion.md#active) -- [format](ToggleQuestion.md#format) -- [inactive](ToggleQuestion.md#inactive) -- [initial](ToggleQuestion.md#initial) -- [message](ToggleQuestion.md#message) -- [name](ToggleQuestion.md#name) -- [stdin](ToggleQuestion.md#stdin) -- [stdout](ToggleQuestion.md#stdout) -- [type](ToggleQuestion.md#type) - -### Methods - -- [onRender](ToggleQuestion.md#onrender) -- [onState](ToggleQuestion.md#onstate) - -## Properties - -### active - -• **active**: `string` - -___ - -### format - -• **format**: [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.format - -___ - -### inactive - -• **inactive**: `string` - -___ - -### initial - -• **initial**: `boolean` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.initial - -___ - -### message - -• **message**: `string` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.message - -___ - -### name - -• **name**: `string` \| [`PromptsMethod`](../README.md#promptsmethod) - -#### Inherited from - -BaseQuestion.name - -___ - -### stdin - -• **stdin**: `internal` - -#### Inherited from - -BaseQuestion.stdin - -___ - -### stdout - -• **stdout**: `internal` - -#### Inherited from - -BaseQuestion.stdout - -___ - -### type - -• **type**: ``"toggle"`` \| [`PromptTypeMethod`](PromptTypeMethod.md)<``"toggle"``\> - -## Methods - -### onRender - -▸ **onRender**(`this`, `kluer`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `this` | `prompts` | -| `kluer` | `any` | - -#### Returns - -`void` - -#### Inherited from - -BaseQuestion.onRender - -___ - -### onState - -▸ **onState**(`state`): `void` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `state` | [`PromptState`](PromptState.md) | - -#### Returns - -`void` - -#### Inherited from - -BaseQuestion.onState diff --git a/packages/node-utilities/docs/interfaces/UnparsedImport.md b/packages/node-utilities/docs/interfaces/UnparsedImport.md deleted file mode 100644 index 85c3752d..00000000 --- a/packages/node-utilities/docs/interfaces/UnparsedImport.md +++ /dev/null @@ -1,75 +0,0 @@ -# Interface: UnparsedImport - -## Type parameters - -| Name | Type | -| :------ | :------ | -| `I` | extends [`ImportMethod`](../README.md#importmethod) = [`ImportMethod`](../README.md#importmethod) | - -## Table of contents - -### Properties - -- [alias](UnparsedImport.md#alias) -- [aliases](UnparsedImport.md#aliases) -- [default](UnparsedImport.md#default) -- [describe](UnparsedImport.md#describe) -- [description](UnparsedImport.md#description) -- [handler](UnparsedImport.md#handler) -- [method](UnparsedImport.md#method) -- [name](UnparsedImport.md#name) -- [run](UnparsedImport.md#run) - -## Properties - -### alias - -• `Optional` **alias**: `string` - -___ - -### aliases - -• `Optional` **aliases**: `string`[] - -___ - -### default - -• `Optional` **default**: `I` - -___ - -### describe - -• `Optional` **describe**: `string` - -___ - -### description - -• `Optional` **description**: `string` - -___ - -### handler - -• `Optional` **handler**: `I` - -___ - -### method - -• `Optional` **method**: `I` - -___ - -### name - -• `Optional` **name**: `string` - -___ - -### run - -• `Optional` **run**: `I` diff --git a/packages/node-utilities/indexer.config.json b/packages/node-utilities/indexer.config.json deleted file mode 100644 index 42cf1cd1..00000000 --- a/packages/node-utilities/indexer.config.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "source": "src/**/*.ts", - "output": "src/index.ts", - "recursive": true -} diff --git a/packages/node-utilities/package.json b/packages/node-utilities/package.json deleted file mode 100644 index c0cc9336..00000000 --- a/packages/node-utilities/package.json +++ /dev/null @@ -1,57 +0,0 @@ -{ - "name": "@snickbit/node-utilities", - "version": "4.7.9", - "description": "A collection of simple Node.js helpers", - "license": "MIT", - "exports": { - "require": "./dist/index.js", - "import": "./dist/index.mjs", - "types": "./dist/index.d.ts" - }, - "main": "./dist/index.js", - "module": "./dist/index.mjs", - "types": "./dist/index.d.ts", - "files": [ - "dist" - ], - "scripts": { - "build": "tsup --minify", - "check": "pnpm -w run lint && pnpm run typecheck", - "dev": "tsup --watch", - "docs": "typedoc src/index.ts", - "release": "semantic-release", - "typecheck": "tsc --noEmit" - }, - "release": { - "extends": [ - "@snickbit/semantic-release" - ] - }, - "jest": { - "preset": "ts-jest", - "testEnvironment": "node" - }, - "dependencies": { - "@snickbit/out": "^2.1.4", - "@snickbit/utilities": "^3.11.1", - "ansi-styles-template": "^1.0.0", - "cli-progress": "3.12.0", - "is-wsl": "^2.2.0", - "lodash.throttle": "^4.1.1", - "nanospinner": "^1.1.0", - "prompts": "^2.4.2" - }, - "devDependencies": { - "@types/jest": "29.5.3", - "@types/node": "20.4.2", - "jest": "29.6.1", - "ts-jest": "29.1.1", - "tsup": "7.1.0", - "typedoc": "0.24.8", - "typedoc-plugin-markdown": "3.15.3", - "typescript": "5.1.6" - }, - "engines": { - "node": ">= 14.17" - } -} diff --git a/packages/node-utilities/src/before-exit.ts b/packages/node-utilities/src/before-exit.ts deleted file mode 100644 index bfdbdc3c..00000000 --- a/packages/node-utilities/src/before-exit.ts +++ /dev/null @@ -1,35 +0,0 @@ -import EventEmitter from 'events' - -let _emitter - -/** @internal */ -function useEmitter() { - // eslint-disable-next-line unicorn/prefer-event-target - _emitter ||= new EventEmitter() - return _emitter -} - -/** - * Add a function to be called before the process exits. - * @category Before Exit - */ -export function beforeExit(callback: () => void) { - const emitter = useEmitter() - - // so the program will not close instantly - process.stdin.resume() - - // attach user callback to the process event emitter - // if no callback, it will still exit gracefully on Ctrl-C - callback ||= (() => void 0) - emitter.on('cleanup', callback) - - // do app specific cleaning before exiting - process.on('exit', () => emitter.emit('cleanup')) - - // catch ctrl+c event and exit normally - process.on('SIGINT', () => process.exit(2)) - - // catch uncaught exceptions, trace, then exit normally - process.on('uncaughtException', () => process.exit(99)) -} diff --git a/packages/node-utilities/src/buffer.ts b/packages/node-utilities/src/buffer.ts deleted file mode 100644 index d1183372..00000000 --- a/packages/node-utilities/src/buffer.ts +++ /dev/null @@ -1,21 +0,0 @@ -import {isBase64} from '@snickbit/utilities' -import {Readable} from 'stream' - -/** - * Make a buffer from a string. - * @category Buffer - */ -export const makeBuffer = (content: string): Buffer => Buffer.from(content, isBase64(content) ? 'base64' : 'utf8') - -/** - * Make a buffer from a file stream - * @category Buffer - */ -export function bufferStream(readable: Readable): Promise { - return new Promise((resolve, reject) => { - const chunks: Buffer[] = [] - readable.on('data', chunk => chunks.push(chunk)) - readable.once('end', () => resolve(Buffer.concat(chunks))) - readable.once('error', reject) - }) -} diff --git a/packages/node-utilities/src/env.d.ts b/packages/node-utilities/src/env.d.ts deleted file mode 100644 index 3e9578ef..00000000 --- a/packages/node-utilities/src/env.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -declare namespace NodeJS { - export interface Process { - defaultApp?: boolean - } -} diff --git a/packages/node-utilities/src/environment.ts b/packages/node-utilities/src/environment.ts deleted file mode 100644 index 9ea9f529..00000000 --- a/packages/node-utilities/src/environment.ts +++ /dev/null @@ -1,52 +0,0 @@ -import {interpolate} from '@snickbit/utilities' -import fs from 'fs' -import isWsl from 'is-wsl' -import os from 'os' - -/** @category Environment */ -export const platform: string = os.platform() - -/** @category Environment */ -export const is_wsl: boolean = isWsl - -/** @category Environment */ -export const home_dir: string = os.homedir() - -/** @category Environment */ -export const temp_dir: string = is_wsl ? `${home_dir}/.tmp` : os.tmpdir() -if (!fs.existsSync(temp_dir)) { - fs.mkdirSync(temp_dir, {recursive: true}) -} - -/** @category Environment */ -export const app_data_dir: string = process.env.APPDATA || (platform === 'darwin' ? `${process.env.HOME}/Library/Preferences` : `${process.env.HOME}/.local/share`) - -/** @category Environment */ -export const user_config_dir = `${os.homedir()}/.config` - -/** @category Environment */ -export const user_data_dir: string = app_data_dir - -/** @category Environment */ -export const verbose: number = Number.parseInt(process.env.VERBOSE || '0') || 0 - -/** @category Environment */ -export const bashrc_path = `${home_dir}/.bashrc` - -/** - * Check if the current process is a Electron app - * @category Environment - */ -export const isElectronApp = (): boolean => !!process.versions.electron - -/** - * Check if the current process is a bundled Electron app. - * @category Environment - */ -export const isBundledElectronApp = (): boolean => isElectronApp() && !process?.defaultApp - -/** - * interpolate string with env variables, optionally pass an object of default values - * @category Environment - */ -export const interpolateEnv = (str: string, defaultValues: Record = {}): string => interpolate(str, {...defaultValues, ...process.env}) diff --git a/packages/node-utilities/src/files.ts b/packages/node-utilities/src/files.ts deleted file mode 100644 index a6d98bbb..00000000 --- a/packages/node-utilities/src/files.ts +++ /dev/null @@ -1,115 +0,0 @@ -import {JSONParse, parseOptions} from '@snickbit/utilities' -import fs, {PathLike, PathOrFileDescriptor, WriteFileOptions} from 'fs' -import path from 'path' - -/** - * Save file to disk as JSON - * @category Files - */ -export function saveFileJSON(filepath: PathOrFileDescriptor, content: any, options: WriteFileOptions = 'utf8') { - return saveFile(filepath, `${JSON.stringify(content, null, '\t')}\n`, options) -} - -/** - * Save file to disk as JSON - * @category Files - * @deprecated use saveFileJSON instead - */ -export const saveFileJson = saveFileJSON - -/** @category Files */ -export const fileExists = (filepath: PathLike) => fs.existsSync(filepath) - -/** @category Files */ -export const isDirectory = (filepath: PathLike) => fileExists(filepath) && fs.lstatSync(filepath).isDirectory() - -/** - * Save file to disk - * @category Files - */ -export function saveFile(filepath: PathOrFileDescriptor, content: NodeJS.ArrayBufferView | string, options: WriteFileOptions = 'utf8') { - if (!fs.existsSync(path.dirname(filepath as string))) { - fs.mkdirSync(path.dirname(filepath as string), {recursive: true}) - } - return fs.writeFileSync(filepath, content, options) -} - -/** - * Get file content - * @category Files - */ -export function getFile(filepath: PathLike, fallback?: any) { - filepath = path.normalize(filepath as string) - return fs.existsSync(filepath) ? fs.readFileSync(filepath, 'utf8') : fallback -} - -/** - * Make a directory - * @category Files - */ -export function mkdir(dir_path: PathLike, recursive = true) { - dir_path = path.normalize(dir_path as string) - if (!fs.existsSync(dir_path)) { - fs.mkdirSync(dir_path, {recursive}) - } -} - -/** @category Files */ -export function unlink(filepath: PathLike) { - filepath = path.normalize(filepath as string) - if (fs.existsSync(filepath)) { - fs.unlinkSync(filepath) - } -} - -/** - * Get JSON from file - * @category Files - */ -export function getFileJSON(filepath: PathLike, fallback?: any) { - const content = getFile(filepath) - return content ? JSONParse(content, fallback) : fallback -} - -/** - * Get JSON from file - * @category Files - * @deprecated use getFileJSON instead - */ -export const getFileJson = getFileJSON - -/** @category Files */ -export interface FindUpOptions { - distance: number - cwd: string - - /** - * Used for tracking current distance - * @internal - */ - d: number -} - -/** @category Files */ -export function findUp(name: PathLike | string, options?: Partial | boolean | string): any { - options = parseOptions(options, { - cwd: process.cwd(), - distance: false - }, 'cwd') as FindUpOptions - options.d ||= 0 - - const directory = path.resolve(options.cwd || '') - const parsed = path.parse(directory) - const resolved = path.join(directory, name as string) - if (fileExists(resolved)) { - return options.distance ? { - path: resolved, - distance: options.d - } : resolved - } else if (parsed.root === directory) { - return null - } - options.d++ - options.cwd = path.dirname(directory) - return findUp(name, options) -} diff --git a/packages/node-utilities/src/imports.ts b/packages/node-utilities/src/imports.ts deleted file mode 100644 index c1aacaa3..00000000 --- a/packages/node-utilities/src/imports.ts +++ /dev/null @@ -1,93 +0,0 @@ -import {arrayUnique, isCallable} from '@snickbit/utilities' - -/** @category Imports */ -export const isImport = (data: any) => typeof data === 'function' || data?.constructor.name === 'AsyncFunction' || Array.isArray(data) - -/** @category Imports */ -export const isImportDefinition = (data: any) => data && data['run'] || data['handler'] || data['method'] - -export type ImportMethod = (...args: Args[]) => Promise | Results - -/** @category Imports */ -export interface ImportDefinition extends ImportMethod { - default: Array | I | ImportDefinition | ImportMethod - name?: string - description?: string - aliases?: string[] - - [key: string]: any -} - -/** @category Imports */ -export type ImportRecords = Record> - -/** @category Imports */ -export type RecordOfImportRecords = Record> - -export type RawImports = ImportRecords | RecordOfImportRecords | any - -/** @category Imports */ -export interface ParsedImport { - name: string - aliases: string[] - description?: string - handler: I -} - -export type ParsedImportRecords = Record> - -export interface UnparsedImport { - name?: string - aliases?: string[] - alias?: string - description?: string - describe?: string - handler?: I - method?: I - default?: I - run?: I -} - -/** - * Parse imports from `import * as name from 'path'` statements into a more manageable format. - * @category Imports - */ -export function parseImports(imports: RawImports, parent?: string): ParsedImportRecords { - const importRecords = {} - for (const [import_item, data] of Object.entries(imports)) { - let parent_name = parent ?? '' - let import_name: string - - if (import_item === 'default') { - import_name = parent_name - parent_name = '' - } else { - import_name = import_item - } - - if (isImport(data) || isImportDefinition(data)) { - const unparsed = data as UnparsedImport - - const parsed = {} as ParsedImport - let sub_import_name = isImportDefinition(data) && unparsed.name ? unparsed.name : import_name - - if (!sub_import_name || parent_name && sub_import_name === `${parent_name}_default`) { - sub_import_name = parent_name - parent_name = '' - } - - parsed.name = parent_name ? `${parent_name}:${sub_import_name}` : sub_import_name - parsed.aliases = arrayUnique([unparsed?.alias, ...unparsed.aliases || []].flat()).filter(Boolean) - parsed.description = unparsed.description || unparsed.describe - const handler = unparsed.handler || unparsed.method || unparsed.run || unparsed.default || unparsed - parsed.handler = handler && isCallable(handler) ? handler as I : () => { - console.warn(`No handler found for ${parsed.name}`) - } - importRecords[parsed.name] = parsed - } else { - const subtasks = parseImports(data, import_name) - Object.assign(importRecords, subtasks) - } - } - return importRecords -} diff --git a/packages/node-utilities/src/index.ts b/packages/node-utilities/src/index.ts deleted file mode 100644 index 3e7d467c..00000000 --- a/packages/node-utilities/src/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -// WARNING: This file is automatically generated. Any changes will be lost the next time the generator is run. - -export * from './before-exit' -export * from './buffer' -export * from './environment' -export * from './files' -export * from './imports' -export * from './multi-progress' -export * from './progress' -export * from './prompt' -export * from './spinner' diff --git a/packages/node-utilities/src/multi-progress.ts b/packages/node-utilities/src/multi-progress.ts deleted file mode 100644 index 8bfb0546..00000000 --- a/packages/node-utilities/src/multi-progress.ts +++ /dev/null @@ -1,126 +0,0 @@ -import {parseOptions, uuid} from '@snickbit/utilities' -import {makeProgressConfig, Progress, ProgressConfig, ProgressOptions} from './progress' -import cliProgress, {MultiBar} from 'cli-progress' -import out from '@snickbit/out' - -const _instances = {} - -/** @category Progress */ -export type MultiProgressBars = Record - -/** - * Multi-Progress bar. Uses cli-progress to create multiple progress bars. - * @see https://github.com/npkgz/cli-progress - * @category Progress - */ -export function multiprogress(options?: ProgressOptions): MultiProgress { - return new MultiProgress(options) -} - -/** - * Multi-Progress bar. Uses cli-progress to create multiple progress bars. - * @see https://github.com/npkgz/cli-progress - * @category Progress - */ -export class MultiProgress extends Progress { - id: string - - bars: MultiProgressBars - - multibar: MultiBar - - constructor(options?: ProgressOptions) { - super(options) - this.id = uuid() - _instances[this.id] = this - this.bars = {} - this.out = this.options.out || out.prefix(this.options.name || 'multi-progress', 1) - } - - #create() { - if (!this.out.isVerbose()) { - this.multibar = new cliProgress.MultiBar(makeProgressConfig(this.options), cliProgress.Presets.shades_classic) - } - } - - /** - * Create a child progress bar - */ - create(options?: ProgressOptions): MultiProgressChild { - options = parseOptions(options, this.options) - const id = uuid() - this.bars[id] = new MultiProgressChild({ - ...options, - parent: this.id, - id - }) - - this.bars[id].start() - return this.bars[id] - } - - /** - * Stop all child progress bars - */ - stop(...messages: any[]): this { - this.multibar.stop() - if (messages.length) { - this.out.info(...messages) - } - return this - } - - /** - * Remove a child progress bar - */ - remove(instance: MultiProgressChild): this { - this.multibar.remove(instance.bar) - delete this.bars[instance.id] - return this - } -} - -export interface MultiProgressChildConfig extends ProgressConfig { - parent: string - id: string -} - -export type MultiProgressChildOptions = Partial - -/** - * Multi-progress child bar - * @category Progress - */ -export class MultiProgressChild extends Progress { - id: string - - declare options: MultiProgressChildConfig - - /** - * @param options - * @internal - */ - constructor(options?: MultiProgressChildOptions) { - super(options) - } - - /** - * @private - * @internal - */ - #create() { - if (!this.out.isVerbose()) { - this.bar = _instances[this.options.parent].create() - } - } - - /** - * Remove this child progress bar - * @internal - */ - remove() { - if (_instances[this.options.parent]) { - _instances[this.options.parent].remove(this) - } - } -} diff --git a/packages/node-utilities/src/progress.ts b/packages/node-utilities/src/progress.ts deleted file mode 100644 index 5b012d5d..00000000 --- a/packages/node-utilities/src/progress.ts +++ /dev/null @@ -1,268 +0,0 @@ -import {formatBytes, parseOptions} from '@snickbit/utilities' -import {template} from 'ansi-styles-template' -import out, {Out} from '@snickbit/out' -import cliProgress, {SingleBar} from 'cli-progress' - -/** @category Progress */ -export interface ProgressConfig { - name?: string - autoStart: boolean - message: string - valueFormat: string - total: number - current: number - out?: Out - config: Partial -} - -export type ProgressOptions = Partial - -export type ProgressPayload = Record - -export interface CLIProgressOptions { - format: any - etaBuffer: number - fps: number - barCompleteChar: string - barIncompleteChar: string - hideCursor: boolean - linewrap: string - formatValue?(v, options, type): any -} - -const defaultCliProgressConfig = { - format: undefined, - etaBuffer: 10, - fps: 10, - barCompleteChar: '\u2588', - barIncompleteChar: '\u2591', - hideCursor: true -} - -/** - * @internal - */ -export const default_progress_options: ProgressConfig = { - message: 'Working...', - autoStart: true, - total: 100, - current: 0, - valueFormat: 'number', - config: {...defaultCliProgressConfig} -} - -/** - * @internal - */ -export function makeProgressFormat(options) { - let _format = '[{{white}}{bar}{{/white}}]{{reset}} {{magenta}}{percentage}%{{/magenta}} | {{yellow}}ETA: {eta}s{{/yellow}} | {{green}}{value}{{/green}}/{total} | {message}' - if (options.config.format) { - _format = options.config.format - } else if (options.label) { - _format = `${options.label} | ${_format}` - } - return template(_format, { - leftBrace: '{{', - rightBrace: '}}' - }) -} - -/** - * @internal - */ -export function makeProgressConfig(options) { - return { - ...defaultCliProgressConfig, - ...options.config, - format: makeProgressFormat(options) - } -} - -/** - * Progress bar. Uses cli-progress to create multiple progress bars. - * @see https://github.com/npkgz/cli-progress - * @category Progress - */ -export function progress(options?: ProgressOptions) { - return new Progress(options) -} - -/** - * Progress bar. Uses cli-progress and @snickbit/out to output progress. - * @see https://github.com/npkgz/cli-progress - * @category Progress - */ -export class Progress { - options: ProgressConfig - - out: Out - - bar: SingleBar - - constructor(options?: ProgressOptions) { - this.options = parseOptions(options, {...default_progress_options}) - this.out = this.options.out || out.prefix(this.options.name || 'progress', 1) - this.options.config.formatValue = this.#formatValue.bind(this) - this.#create() - if (this.options.autoStart) { - this.start() - } - } - - #create(): this { - if (!this.out.isVerbose()) { - const progressConfig = makeProgressConfig(this.options) - this.out.debug(`Creating progress bar with config:`, progressConfig) - this.bar = new cliProgress.SingleBar(progressConfig, cliProgress.Presets.shades_classic) - } - return this - } - - #formatValue(v, options, type): any { - switch (this.options.valueFormat) { - case 'bytes': - case 'byte': { - if (type === 'value' || type === 'total') { - return formatBytes(v) - } - } - } - return cliProgress.Format.ValueFormat(v, options, type) - } - - /** - * Get the ETA - */ - eta(): number | string { - return this.bar ? this.bar.eta.getTime() : 0 - } - - /** - * Start the progress bar - */ - start(options?: ProgressOptions): this { - const parsed: ProgressOptions = parseOptions(options, this.options) - if (parsed.message) { - this.out.debug(parsed.message) - } - if (this.bar) { - this.bar.start(parsed.total, parsed.current, parsed) - } - return this - } - - /** - * Tick the progress - */ - tick(payload: ProgressPayload): this - tick(value?: number, payload?: ProgressPayload): this - tick(message: string, payload?: ProgressPayload): this - tick(valueMessageOrPayload?: ProgressPayload | number | string, payload?: ProgressPayload): this { - let value = 1 - - if (typeof valueMessageOrPayload === 'object') { - payload = valueMessageOrPayload - if ('value' in payload) { - value = payload.value - delete payload.value - } - } else if (typeof valueMessageOrPayload === 'string') { - payload = {message: valueMessageOrPayload, ...payload} - } else if (typeof valueMessageOrPayload === 'number') { - value = valueMessageOrPayload - } - - if (this.bar) { - this.bar.increment(value, payload) - } - if (payload) { - this.out.verbose(`Increment progress by ${value} and payload to:`, payload) - } else { - this.out.verbose(`Increment progress by ${value}`) - } - return this - } - - /** - * Set the progress bar current value - */ - set(value: number, payload?: ProgressPayload) { - if (this.bar) { - if (payload) { - this.bar.update(value, payload) - this.out.verbose(`Set progress current to ${value} and payload to:`, payload) - } else { - this.bar.update(value) - this.out.verbose(`Set progress current to ${value}`) - } - } - } - - /** - * Update the progress bar - */ - update(payload?: ProgressPayload): this { - if (this.bar) { - this.bar.update(null, payload) - } - return this - } - - /** - * Set the progress bar message - * @param {string} message - */ - message(message: string) { - return this.update({message}) - } - - /** - * Set the progress bar total - */ - setTotal(total: number): this { - if (this.bar) { - this.bar.setTotal(total) - } - this.out.verbose(`Set progress total to ${total}`) - return this - } - - /** - * Fail and stop the progress bar - */ - fail(...messages: any[]): this { - if (this.bar) { - this.bar.stop() - } - if (messages.length) { - this.out.error(...messages) - } - return this - } - - /** - * Stop the progress bar - */ - stop(...messages: any[]): this { - if (this.bar) { - this.bar.stop() - } - if (messages.length) { - this.out.info(...messages) - } - return this - } - - /** - * Succeed and stop the progress bar - */ - finish(...messages: any[]): this { - if (this.bar) { - this.bar.stop() - } - if (messages.length) { - this.out.success(...messages) - } - return this - } -} diff --git a/packages/node-utilities/src/prompt.ts b/packages/node-utilities/src/prompt.ts deleted file mode 100644 index a0c04c5b..00000000 --- a/packages/node-utilities/src/prompt.ts +++ /dev/null @@ -1,286 +0,0 @@ -#!/usr/bin/env node -import {isObject, parseOptions} from '@snickbit/utilities' -import prompts from 'prompts' -import Stream from 'stream' - -/** @category Prompts */ -export type PromptsMethod = (prev: string, answers: Answers, previousQuestion: Question) => Promise | string - -/** @category Prompts */ -export type PromptType = 'autocomplete' | 'autocompleteMultiselect' | 'confirm' | 'date' | 'invisible' - | 'list' | 'multiselect' | 'number' | 'password' | 'select' | 'text' | 'toggle' - -/** @category Prompts */ -export type AnswerTypes = Date | boolean | number | string - -/** @category Prompts */ -export type QuestionRecords = Record - -/** @category Prompts */ -export interface PromptTypeMethod

{ - (prev: string, answers: Answers, previousQuestion: Question): P -} - -interface BaseQuestion { - name: PromptsMethod | string - message: PromptsMethod | string - initial: InitialType | PromptsMethod - format: PromptsMethod - - onRender(this: prompts, kluer: any): void - - onState(state: PromptState): void - - stdin: Stream - stdout: Stream -} - -// Question extensions -interface QuestionMinMax { - // number | multiselect - min: number - max: number -} - -interface QuestionHints { - // select | multiselect - hint: string - warn: string -} - -interface QuestionChoices { - // select | multiselect | autocomplete - choices: ChoiceDefinition | ChoiceOption[] -} - -// Question types -export interface AutoCompleteQuestion extends BaseQuestion, QuestionChoices { - // autocomplete - type: PromptTypeMethod<'autocomplete'> | 'autocomplete' - - suggest(input, choices): Promise - - limit: number - clearFirst: boolean - fallback: string -} - -/** @category Prompts */ -export interface AutoCompleteMultiSelectQuestion extends Omit { - type: PromptTypeMethod<'autocompleteMultiselect'> | 'autocompleteMultiselect' -} - -/** @category Prompts */ -export interface ConfirmQuestion extends BaseQuestion, QuestionChoices { - type: PromptTypeMethod<'confirm'> | 'confirm' -} - -/** @category Prompts */ -export interface DateQuestion extends BaseQuestion, QuestionMinMax { - // date - type: PromptTypeMethod<'date'> | 'date' - locales: PromptsLocales - mask: string -} - -/** @category Prompts */ -export interface InvisibleQuestion extends BaseQuestion { - type: PromptTypeMethod<'invisible'> | 'invisible' -} - -/** @category Prompts */ -export interface ListQuestion extends BaseQuestion { - // list - type: PromptTypeMethod<'list'> | 'list' - separator: string -} - -/** @category Prompts */ -export interface MultiSelectQuestion extends Omit, QuestionMinMax, QuestionHints, QuestionChoices { - // multiselect - type: PromptTypeMethod<'multiselect'> | 'multiselect' - instructions: boolean | string - optionsPerPage: number -} - -/** @category Prompts */ -export interface NumberQuestion extends BaseQuestion { - // number - type: PromptTypeMethod<'number'> | 'number' - float: boolean - round: number - increment: number -} - -/** @category Prompts */ -export interface PasswordQuestion extends BaseQuestion { - type: PromptTypeMethod<'password'> | 'password' -} - -/** @category Prompts */ -export interface SelectQuestion extends BaseQuestion, QuestionHints, QuestionChoices { - type: PromptTypeMethod<'select'> | 'select' -} - -/** @category Prompts */ -export interface TextQuestion extends BaseQuestion { - // text - type: PromptTypeMethod<'text'> | 'text' - style: 'default' | 'emoji' | 'invisible' | 'password' -} - -/** @category Prompts */ -export interface ToggleQuestion extends BaseQuestion { - // toggle - type: PromptTypeMethod<'toggle'> | 'toggle' - active: string - inactive: string -} - -/** @category Prompts */ -export type Question = - AutoCompleteMultiSelectQuestion | - AutoCompleteQuestion | - ConfirmQuestion | - DateQuestion | - InvisibleQuestion | - ListQuestion | - MultiSelectQuestion | - NumberQuestion | - PasswordQuestion | - SelectQuestion | - TextQuestion | - ToggleQuestion - -/** @category Prompts */ -export interface PromptsLocales { - months: string[] - monthsShort: string[] - weekdays: string[] - weekdaysShort: string[] -} - -/** @category Prompts */ -export type Answers = Record - -/** @category Prompts */ -export type ChoiceRecords = Record - -/** @category Prompts */ -export interface ChoiceDefinition { - title: string - value: any -} - -/** @category Prompts */ -export interface PromptState { - aborted: boolean -} - -/** @category Prompts */ -export type ChoiceOption = ChoiceDefinition | string - -type LazyChoice = number | string - -/** - * @category Prompts - * @see https://github.com/terkelg/prompts/issues/252 - */ -function onState(state: PromptState) { - if (state.aborted) { - // If we don't re-enable the terminal cursor before exiting - // the program, the cursor will remain hidden - process.stdout.write('\u001B[?25h') - process.stdout.write('\n') - process.exit(1) - } -} - -const defaultPromptOptions = { - type: 'text', - name: 'value', - onState -} - -/** @category Prompts */ -export async function prompt(questions: Question[] | QuestionRecords): Promise { - if (isObject(questions)) { - const answers: Answers = {} - for (const key in questions) { - answers[key] = await prompts({...defaultPromptOptions, ...questions[key]}) - } - - return answers - } - - return prompts(questions) -} - -/** - * Prompt the user for confirmation using Prompts. - * @see https://github.com/terkelg/prompts - * @category Prompts - */ -export async function confirm(question: string, defaultAnswer?: boolean): Promise -export async function confirm(question: string, options?: Partial): Promise -export async function confirm(question: string, optionsOrDefault?: Partial | boolean): Promise { - const options = typeof optionsOrDefault === 'object' ? {...optionsOrDefault, type: 'confirm'} : {type: 'confirm', initial: optionsOrDefault} - return ask(question, options as Question) -} - -/** - * Prompt the user for input using Prompts. - * @see https://github.com/terkelg/prompts - * @category Prompts - */ -export async function ask(question: string, defaultAnswer?: boolean | string): Promise -export async function ask(question: string, options?: Partial): Promise -export async function ask(question: string, optionsOrDefault?: Partial | boolean | string): Promise { - const options = parseOptions(optionsOrDefault, { - ...defaultPromptOptions, - style: 'default', - message: question - }, 'initial') - - // double check that it has a name - options.name ||= 'value' - - if (options.type === 'multiselect' && options.initial) { - throw new Error('Cannot use initial with multiselect') - } - - let choices: any[] = [] - let useIndexes = false - if (options.choices) { - if (typeof options.initial !== 'number') { - options.initial = options.choices.indexOf(options.initial) - if (options.initial === -1) { - delete options.initial - } - } - - choices = [...options.choices] - useIndexes = choices.some(element => isLazyChoice(element)) - options.choices = [] - for (const choice of choices) { - if (isLazyChoice(choice)) { - options.choices.push({title: choice, value: choice}) - } else { - options.choices.push(choice) - } - } - } - - const response = await prompts(options) - const answer = response?.value - - if (useIndexes && choices && answer && choices[answer]) { - return choices[answer]?.value || choices[answer] || answer - } - - return answer -} - -function isLazyChoice(choice: any): choice is LazyChoice { - return typeof choice === 'number' || typeof choice === 'string' -} diff --git a/packages/node-utilities/src/spinner.ts b/packages/node-utilities/src/spinner.ts deleted file mode 100644 index 781fb279..00000000 --- a/packages/node-utilities/src/spinner.ts +++ /dev/null @@ -1,158 +0,0 @@ -import {Out} from '@snickbit/out' -import {isString} from '@snickbit/utilities' -import {createSpinner} from 'nanospinner' -import throttle from 'lodash.throttle' - -/** @category Spinner */ -export interface SpinnerConfig { - text: string - color: string - stream: any - interval: number - frames: string[] - mark: string -} - -/** @category Spinner */ -export type SpinnerOptions = Partial - -const updateText = throttle((instance, text) => { - instance.update({text}) -}, 150) - -const updateSpinner = throttle((instance, options) => { - instance.update(options) -}, 150) - -/** - * Spinner. Uses nanospinner to show spinners in the terminal. - * @see https://github.com/usmanyunusov/nanospinner - * @category Spinner - * @deprecated use @snickbit/spinner instead - */ -export function spinner(options?: SpinnerOptions | string) { - return new Spinner(options) -} - -/** - * Spinner. Uses nanospinner to show spinners in the terminal. - * @see https://github.com/usmanyunusov/nanospinner - * @category Spinner - * @deprecated use @snickbit/spinner instead - */ -export class Spinner { - spinner - - preload_message = '' - - out: Out - - constructor(options?: SpinnerOptions | string) { - const parsed = this.#parseOptions(options) - this.preload_message = parsed.text - this.spinner = createSpinner(parsed.text, parsed) - this.out = new Out('spinner') - } - - /** - * Parse the options - */ - #parseOptions(options?: SpinnerOptions | string, fallback_text?: string): SpinnerConfig { - options ||= {} - - if (isString(options)) { - options = {text: options as string} - } - options = options as SpinnerOptions - - if (options?.text) { - options.text = this.#getMessage(options.text, fallback_text) - } - - return options as SpinnerConfig - } - - /** - * Parse the message, using the fallback if necessary - */ - #getMessage(message: string, fallback?: string): string { - return message || this.preload_message || fallback || '' - } - - /** - * Set the spinner text - */ - text(message: string): this { - updateText(this.spinner, this.#getMessage(message)) - return this - } - - /** - * Update the spinner - */ - update(options: SpinnerOptions | string): this { - options = this.#parseOptions(options) - updateSpinner(this.spinner, options) - return this - } - - /** - * Start the spinner - */ - start(options?: SpinnerOptions | string): this { - const parsed = this.#parseOptions(options) - this.preload_message = parsed.text - if (this.spinner) { - this.spinner.start(parsed) - } else if (parsed.text) { - this.out.info(parsed.text) - } - return this - } - - /** - * Fail and stop the spinner - */ - fail(options?: SpinnerOptions | string): this { - return this.error(options) - } - - /** - * Error and stop the spinner - */ - error(options?: SpinnerOptions | string): this { - options = this.#parseOptions(options, 'Something went wrong.') - if (this.spinner) { - this.spinner.error(options.text) - } else if (options.text) { - this.out.error(options.text) - } - return this - } - - /** - * Stop the spinner - */ - stop(options?: SpinnerOptions | string): this { - options = this.#parseOptions(options) - if (this.spinner) { - this.spinner.stop(options.text) - } else if (options.text) { - this.out.warn(options.text) - } - return this - } - - /** - * Succeed and stop the spinner - */ - finish(options?: SpinnerOptions | string): this { - options = this.#parseOptions(options, 'Finished!') - if (this.spinner) { - this.spinner.success(options) - } else if (options.text) { - this.out.success(options.text) - } - return this - } -} diff --git a/packages/node-utilities/typedoc.json b/packages/node-utilities/typedoc.json deleted file mode 100644 index 44bd80f2..00000000 --- a/packages/node-utilities/typedoc.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": [ - "../../typedoc.json" - ], - "entryPoints": [ - "src/index.ts" - ] -} diff --git a/packages/plural/.gitignore b/packages/plural/.gitignore deleted file mode 100644 index 74632601..00000000 --- a/packages/plural/.gitignore +++ /dev/null @@ -1,20 +0,0 @@ -# hidden folders & junk files -.*/ -.* -*.iml - -# Log files -logs/ -*.log - -# Dependencies -node_modules/ -*.lock -*-lock.yaml -*-lock.json - -# Compiled files -dist/ - -# keep -!.git* diff --git a/packages/plural/CHANGELOG.md b/packages/plural/CHANGELOG.md deleted file mode 100644 index 2feb105b..00000000 --- a/packages/plural/CHANGELOG.md +++ /dev/null @@ -1,43 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. See -[Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -## @snickbit/plural [1.0.13](https://github.com/remedyred/snickbit.js/compare/@snickbit/plural@1.0.12...@snickbit/plural@1.0.13) (2023-03-03) - - -### Bug Fixes - -* remove depcheck ([#119](https://github.com/remedyred/snickbit.js/issues/119)) ([0fb970f](https://github.com/remedyred/snickbit.js/commit/0fb970fe23d85f4e678fbdca577c877b059a86fb)) - -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -## [0.0.5](https://github.com/snickbit/snickbit.js/compare/@snickbit/plural@0.0.4...@snickbit/plural@0.0.5) (2022-08-13) - -**Note:** Version bump only for package @snickbit/plural - -## [0.0.4](https://github.com/snickbit/snickbit.js/compare/@snickbit/plural@0.0.3...@snickbit/plural@0.0.4) (2022-08-06) - -### Bug Fixes - -* replace let with const ([1d5c624](https://github.com/snickbit/snickbit.js/commit/1d5c6248acdc7d9e4d46ba94c03af1932d9a5c76)) - -# @snickbit/plural Changelog - -## 0.0.3 - -### Patch Changes - -- [c5a5cf2](https://github.com/snickbit/snickbit.js/commit/c5a5cf2) **chore**: bump dependencies -- [dadd932](https://github.com/snickbit/snickbit.js/commit/dadd932) **chore**: bump dependencies -- [9bf343e](https://github.com/snickbit/snickbit.js/commit/9bf343e) **chore**: bump deps -- [a05ea6b](https://github.com/snickbit/snickbit.js/commit/a05ea6b) **chore**: update dependencies - -## 0.0.2 - -### Patch Changes - -- [66624f1](https://github.com/snickbit/snickbit.js/commit/66624f1) **chore**: update dependencies diff --git a/packages/plural/README.md b/packages/plural/README.md deleted file mode 100644 index bcd558b5..00000000 --- a/packages/plural/README.md +++ /dev/null @@ -1,60 +0,0 @@ -# @snickbit/plural - - - -- Pluralizes strings -- Singularizes strings -- Written in TypeScript -- Zero dependencies - - - -## Installation -```bash -pnpm add @snickbit/plural -``` - -```bash -yarn add @snickbit/plural -``` - -```bash -npm i @snickbit/plural -``` - -## Usage - -```js -import {plural, singular} from '@snickbit/plural' - -// or in Node.js -// const {plural, singular} = require('@snickbit/plural') - -console.log(plural('test')) //=> "tests" -console.log(plural('test', 0)) //=> "tests" -console.log(plural('test', 1)) //=> "test" -console.log(plural('test', 2)) //=> "tests" - -// Singularize -console.log(singular('tests')) //=> "test" -console.log(singular('test')) //=> "test" -console.log(singular('test', 0)) //=> "tests" -console.log(singular('test', 2)) //=> "tests" - -``` - -## Documentation - -### [API Docs](./docs/README.md) - -### [CHANGELOG](CHANGELOG.md) - -## Acknowledgements - -### Based on [pluralize](https://github.com/plurals/pluralize) - -## License - -Copyright (c) 2022 - **Nicholas Lowe** aka **Snickbit** - -[MIT License](../../LICENSE) diff --git a/packages/plural/__fixtures__/basic.ts b/packages/plural/__fixtures__/basic.ts deleted file mode 100644 index 533ecc87..00000000 --- a/packages/plural/__fixtures__/basic.ts +++ /dev/null @@ -1,662 +0,0 @@ -export default [ - // Uncountables. - ['firmware', 'firmware'], - ['fish', 'fish'], - ['moose', 'moose'], - ['police', 'police'], - ['sheep', 'sheep'], - ['series', 'series'], - ['agenda', 'agenda'], - ['news', 'news'], - ['reindeer', 'reindeer'], - ['starfish', 'starfish'], - ['smallpox', 'smallpox'], - ['tennis', 'tennis'], - ['chickenpox', 'chickenpox'], - ['shambles', 'shambles'], - ['garbage', 'garbage'], - ['you', 'you'], - ['wildlife', 'wildlife'], - ['Staff', 'Staff'], - ['STAFF', 'STAFF'], - ['turquois', 'turquois'], - ['carnivorous', 'carnivorous'], - ['only', 'only'], - ['aircraft', 'aircraft'], - // Latin. - ['veniam', 'veniam'], - // Pluralization. - ['this', 'these'], - ['that', 'those'], - ['is', 'are'], - ['man', 'men'], - ['superman', 'supermen'], - ['ox', 'oxen'], - ['bus', 'buses'], - ['airbus', 'airbuses'], - ['railbus', 'railbuses'], - ['wife', 'wives'], - ['guest', 'guests'], - ['thing', 'things'], - ['mess', 'messes'], - ['guess', 'guesses'], - ['person', 'people'], - ['meteor', 'meteors'], - ['chateau', 'chateaus'], - ['lap', 'laps'], - ['cough', 'coughs'], - ['death', 'deaths'], - ['coach', 'coaches'], - ['boy', 'boys'], - ['toy', 'toys'], - ['guy', 'guys'], - ['girl', 'girls'], - ['chair', 'chairs'], - ['toe', 'toes'], - ['tiptoe', 'tiptoes'], - ['tomato', 'tomatoes'], - ['potato', 'potatoes'], - ['tornado', 'tornadoes'], - ['torpedo', 'torpedoes'], - ['hero', 'heroes'], - ['superhero', 'superheroes'], - ['volcano', 'volcanoes'], - ['canto', 'cantos'], - ['hetero', 'heteros'], - ['photo', 'photos'], - ['portico', 'porticos'], - ['quarto', 'quartos'], - ['kimono', 'kimonos'], - ['albino', 'albinos'], - ['cherry', 'cherries'], - ['piano', 'pianos'], - ['pro', 'pros'], - ['combo', 'combos'], - ['turbo', 'turbos'], - ['bar', 'bars'], - ['crowbar', 'crowbars'], - ['van', 'vans'], - ['tobacco', 'tobaccos'], - ['afficionado', 'afficionados'], - ['monkey', 'monkeys'], - ['neutrino', 'neutrinos'], - ['rhino', 'rhinos'], - ['steno', 'stenos'], - ['latino', 'latinos'], - ['casino', 'casinos'], - ['avocado', 'avocados'], - ['commando', 'commandos'], - ['tuxedo', 'tuxedos'], - ['speedo', 'speedos'], - ['dingo', 'dingoes'], - ['echo', 'echoes'], - ['nacho', 'nachos'], - ['motto', 'mottos'], - ['psycho', 'psychos'], - ['poncho', 'ponchos'], - ['pass', 'passes'], - ['ghetto', 'ghettos'], - ['mango', 'mangos'], - ['lady', 'ladies'], - ['bath', 'baths'], - ['professional', 'professionals'], - ['dwarf', 'dwarfs'], - ['encyclopedia', 'encyclopedias'], - ['louse', 'lice'], - ['roof', 'roofs'], - ['woman', 'women'], - ['formula', 'formulae'], - ['polyhedron', 'polyhedra'], - ['index', 'indices'], // Maybe "indexes". - ['matrix', 'matrices'], - ['vertex', 'vertices'], - ['axe', 'axes'], // Could also be plural of "ax". - ['pickaxe', 'pickaxes'], - ['crisis', 'crises'], - ['criterion', 'criteria'], - ['phenomenon', 'phenomena'], - ['addendum', 'addenda'], - ['datum', 'data'], - ['forum', 'forums'], - ['millennium', 'millennia'], - ['alumnus', 'alumni'], - ['medium', 'media'], - ['census', 'censuses'], - ['genus', 'genera'], - ['dogma', 'dogmata'], - ['life', 'lives'], - ['hive', 'hives'], - ['kiss', 'kisses'], - ['dish', 'dishes'], - ['human', 'humans'], - ['knife', 'knives'], - ['phase', 'phases'], - ['judge', 'judges'], - ['class', 'classes'], - ['witch', 'witches'], - ['church', 'churches'], - ['massage', 'massages'], - ['prospectus', 'prospectuses'], - ['syllabus', 'syllabi'], - ['viscus', 'viscera'], - ['cactus', 'cacti'], - ['hippopotamus', 'hippopotamuses'], - ['octopus', 'octopuses'], - ['platypus', 'platypuses'], - ['kangaroo', 'kangaroos'], - ['atlas', 'atlases'], - ['stigma', 'stigmata'], - ['schema', 'schemata'], - ['phenomenon', 'phenomena'], - ['diagnosis', 'diagnoses'], - ['mongoose', 'mongooses'], - ['mouse', 'mice'], - ['liturgist', 'liturgists'], - ['box', 'boxes'], - ['gas', 'gases'], - ['self', 'selves'], - ['chief', 'chiefs'], - ['quiz', 'quizzes'], - ['child', 'children'], - ['shelf', 'shelves'], - ['fizz', 'fizzes'], - ['tooth', 'teeth'], - ['thief', 'thieves'], - ['day', 'days'], - ['loaf', 'loaves'], - ['fix', 'fixes'], - ['spy', 'spies'], - ['vertebra', 'vertebrae'], - ['clock', 'clocks'], - ['lap', 'laps'], - ['cuff', 'cuffs'], - ['leaf', 'leaves'], - ['calf', 'calves'], - ['moth', 'moths'], - ['mouth', 'mouths'], - ['house', 'houses'], - ['proof', 'proofs'], - ['hoof', 'hooves'], - ['elf', 'elves'], - ['turf', 'turfs'], - ['craft', 'crafts'], - ['die', 'dice'], - ['penny', 'pennies'], - ['campus', 'campuses'], - ['virus', 'viri'], - ['iris', 'irises'], - ['bureau', 'bureaus'], - ['kiwi', 'kiwis'], - ['wiki', 'wikis'], - ['igloo', 'igloos'], - ['ninja', 'ninjas'], - ['pizza', 'pizzas'], - ['kayak', 'kayaks'], - ['canoe', 'canoes'], - ['tiding', 'tidings'], - ['pea', 'peas'], - ['drive', 'drives'], - ['nose', 'noses'], - ['movie', 'movies'], - ['status', 'statuses'], - ['alias', 'aliases'], - ['memorandum', 'memoranda'], - ['language', 'languages'], - ['plural', 'plurals'], - ['word', 'words'], - ['multiple', 'multiples'], - ['reward', 'rewards'], - ['sandwich', 'sandwiches'], - ['subway', 'subways'], - ['direction', 'directions'], - ['land', 'lands'], - ['row', 'rows'], - ['grow', 'grows'], - ['flow', 'flows'], - ['rose', 'roses'], - ['raise', 'raises'], - ['friend', 'friends'], - ['follower', 'followers'], - ['male', 'males'], - ['nail', 'nails'], - ['sex', 'sexes'], - ['tape', 'tapes'], - ['ruler', 'rulers'], - ['king', 'kings'], - ['queen', 'queens'], - ['zero', 'zeros'], - ['quest', 'quests'], - ['goose', 'geese'], - ['foot', 'feet'], - ['ex', 'exes'], - ['reflex', 'reflexes'], - ['heat', 'heats'], - ['train', 'trains'], - ['test', 'tests'], - ['pie', 'pies'], - ['fly', 'flies'], - ['eye', 'eyes'], - ['lie', 'lies'], - ['node', 'nodes'], - ['trade', 'trades'], - ['chinese', 'chinese'], - ['please', 'pleases'], - ['japanese', 'japanese'], - ['regex', 'regexes'], - ['license', 'licenses'], - ['zebra', 'zebras'], - ['general', 'generals'], - ['corps', 'corps'], - ['pliers', 'pliers'], - ['flyer', 'flyers'], - ['scissors', 'scissors'], - ['fireman', 'firemen'], - ['chirp', 'chirps'], - ['harp', 'harps'], - ['corpse', 'corpses'], - ['dye', 'dyes'], - ['move', 'moves'], - ['zombie', 'zombies'], - ['variety', 'varieties'], - ['talkie', 'talkies'], - ['walkie-talkie', 'walkie-talkies'], - ['groupie', 'groupies'], - ['goonie', 'goonies'], - ['lassie', 'lassies'], - ['genie', 'genies'], - ['foodie', 'foodies'], - ['faerie', 'faeries'], - ['collie', 'collies'], - ['obloquy', 'obloquies'], - ['looey', 'looies'], - ['osprey', 'ospreys'], - ['cover', 'covers'], - ['tie', 'ties'], - ['groove', 'grooves'], - ['bee', 'bees'], - ['ave', 'aves'], - ['wave', 'waves'], - ['wolf', 'wolves'], - ['airwave', 'airwaves'], - ['archive', 'archives'], - ['arch', 'arches'], - ['dive', 'dives'], - ['aftershave', 'aftershaves'], - ['cave', 'caves'], - ['grave', 'graves'], - ['gift', 'gifts'], - ['nerve', 'nerves'], - ['nerd', 'nerds'], - ['carve', 'carves'], - ['rave', 'raves'], - ['scarf', 'scarves'], - ['sale', 'sales'], - ['sail', 'sails'], - ['swerve', 'swerves'], - ['love', 'loves'], - ['dove', 'doves'], - ['glove', 'gloves'], - ['wharf', 'wharves'], - ['valve', 'valves'], - ['werewolf', 'werewolves'], - ['view', 'views'], - ['emu', 'emus'], - ['menu', 'menus'], - ['wax', 'waxes'], - ['fax', 'faxes'], - ['nut', 'nuts'], - ['crust', 'crusts'], - ['lemma', 'lemmata'], - ['anathema', 'anathemata'], - ['analysis', 'analyses'], - ['locus', 'loci'], - ['uterus', 'uteri'], - ['curriculum', 'curricula'], - ['quorum', 'quora'], - ['genius', 'geniuses'], - ['flower', 'flowers'], - ['crash', 'crashes'], - ['soul', 'souls'], - ['career', 'careers'], - ['planet', 'planets'], - ['son', 'sons'], - ['sun', 'suns'], - ['drink', 'drinks'], - ['diploma', 'diplomas'], - ['dilemma', 'dilemmas'], - ['grandma', 'grandmas'], - ['no', 'nos'], - ['yes', 'yeses'], - ['employ', 'employs'], - ['employee', 'employees'], - ['history', 'histories'], - ['story', 'stories'], - ['purchase', 'purchases'], - ['order', 'orders'], - ['key', 'keys'], - ['bomb', 'bombs'], - ['city', 'cities'], - ['sanity', 'sanities'], - ['ability', 'abilities'], - ['activity', 'activities'], - ['cutie', 'cuties'], - ['validation', 'validations'], - ['floaty', 'floaties'], - ['nicety', 'niceties'], - ['goalie', 'goalies'], - ['crawly', 'crawlies'], - ['duty', 'duties'], - ['scrutiny', 'scrutinies'], - ['deputy', 'deputies'], - ['beauty', 'beauties'], - ['bank', 'banks'], - ['family', 'families'], - ['tally', 'tallies'], - ['ally', 'allies'], - ['alley', 'alleys'], - ['valley', 'valleys'], - ['medley', 'medleys'], - ['melody', 'melodies'], - ['trolly', 'trollies'], - ['thunk', 'thunks'], - ['koala', 'koalas'], - ['special', 'specials'], - ['book', 'books'], - ['knob', 'knobs'], - ['crab', 'crabs'], - ['plough', 'ploughs'], - ['high', 'highs'], - ['low', 'lows'], - ['hiccup', 'hiccups'], - ['bonus', 'bonuses'], - ['circus', 'circuses'], - ['abacus', 'abacuses'], - ['phobia', 'phobias'], - ['case', 'cases'], - ['lace', 'laces'], - ['trace', 'traces'], - ['mage', 'mages'], - ['lotus', 'lotuses'], - ['motorbus', 'motorbuses'], - ['cutlas', 'cutlases'], - ['tequila', 'tequilas'], - ['liar', 'liars'], - ['delta', 'deltas'], - ['visa', 'visas'], - ['flea', 'fleas'], - ['favela', 'favelas'], - ['cobra', 'cobras'], - ['finish', 'finishes'], - ['gorilla', 'gorillas'], - ['mass', 'masses'], - ['face', 'faces'], - ['rabbit', 'rabbits'], - ['adventure', 'adventures'], - ['breeze', 'breezes'], - ['brew', 'brews'], - ['canopy', 'canopies'], - ['copy', 'copies'], - ['spy', 'spies'], - ['cave', 'caves'], - ['charge', 'charges'], - ['cinema', 'cinemas'], - ['coffee', 'coffees'], - ['favourite', 'favourites'], - ['themself', 'themselves'], - ['country', 'countries'], - ['issue', 'issues'], - ['authority', 'authorities'], - ['force', 'forces'], - ['objective', 'objectives'], - ['present', 'presents'], - ['industry', 'industries'], - ['believe', 'believes'], - ['century', 'centuries'], - ['category', 'categories'], - ['eve', 'eves'], - ['fee', 'fees'], - ['gene', 'genes'], - ['try', 'tries'], - ['currency', 'currencies'], - ['pose', 'poses'], - ['cheese', 'cheeses'], - ['clue', 'clues'], - ['cheer', 'cheers'], - ['litre', 'litres'], - ['money', 'monies'], - ['attorney', 'attorneys'], - ['balcony', 'balconies'], - ['cockney', 'cockneys'], - ['donkey', 'donkeys'], - ['honey', 'honeys'], - ['smiley', 'smilies'], - ['survey', 'surveys'], - ['whiskey', 'whiskeys'], - ['whisky', 'whiskies'], - ['volley', 'volleys'], - ['tongue', 'tongues'], - ['suit', 'suits'], - ['suite', 'suites'], - ['cruise', 'cruises'], - ['eave', 'eaves'], - ['consultancy', 'consultancies'], - ['pouch', 'pouches'], - ['wallaby', 'wallabies'], - ['abyss', 'abysses'], - ['weekly', 'weeklies'], - ['whistle', 'whistles'], - ['utilise', 'utilises'], - ['utilize', 'utilizes'], - ['mercy', 'mercies'], - ['mercenary', 'mercenaries'], - ['take', 'takes'], - ['flush', 'flushes'], - ['gate', 'gates'], - ['evolve', 'evolves'], - ['slave', 'slaves'], - ['native', 'natives'], - ['revolve', 'revolves'], - ['twelve', 'twelves'], - ['sleeve', 'sleeves'], - ['subjective', 'subjectives'], - ['stream', 'streams'], - ['beam', 'beams'], - ['foam', 'foams'], - ['callus', 'calluses'], - ['use', 'uses'], - ['beau', 'beaux'], - ['gateau', 'gateaus'], - ['fetus', 'fetuses'], - ['luau', 'luaus'], - ['pilau', 'pilaus'], - ['shoe', 'shoes'], - ['sandshoe', 'sandshoes'], - ['zeus', 'zeuses'], - ['nucleus', 'nuclei'], - ['sky', 'skies'], - ['beach', 'beaches'], - ['brush', 'brushes'], - ['hoax', 'hoaxes'], - ['scratch', 'scratches'], - ['nanny', 'nannies'], - ['negro', 'negroes'], - ['taco', 'tacos'], - ['cafe', 'cafes'], - ['cave', 'caves'], - ['giraffe', 'giraffes'], - ['goodwife', 'goodwives'], - ['housewife', 'housewives'], - ['safe', 'safes'], - ['save', 'saves'], - ['pocketknife', 'pocketknives'], - ['tartufe', 'tartufes'], - ['tartuffe', 'tartuffes'], - ['truffle', 'truffles'], - ['jefe', 'jefes'], - ['agrafe', 'agrafes'], - ['agraffe', 'agraffes'], - ['bouffe', 'bouffes'], - ['carafe', 'carafes'], - ['chafe', 'chafes'], - ['pouffe', 'pouffes'], - ['pouf', 'poufs'], - ['piaffe', 'piaffes'], - ['gaffe', 'gaffes'], - ['executive', 'executives'], - ['cove', 'coves'], - ['dove', 'doves'], - ['fave', 'faves'], - ['positive', 'positives'], - ['solve', 'solves'], - ['trove', 'troves'], - ['treasure', 'treasures'], - ['suave', 'suaves'], - ['bluff', 'bluffs'], - ['half', 'halves'], - ['knockoff', 'knockoffs'], - ['handkerchief', 'handkerchiefs'], - ['reed', 'reeds'], - ['reef', 'reefs'], - ['yourself', 'yourselves'], - ['sunroof', 'sunroofs'], - ['plateau', 'plateaus'], - ['radius', 'radii'], - ['stratum', 'strata'], - ['stratus', 'strati'], - ['focus', 'foci'], - ['fungus', 'fungi'], - ['appendix', 'appendices'], - ['seraph', 'seraphim'], - ['cherub', 'cherubim'], - ['memo', 'memos'], - ['cello', 'cellos'], - ['automaton', 'automata'], - ['button', 'buttons'], - ['crayon', 'crayons'], - ['captive', 'captives'], - ['abrasive', 'abrasives'], - ['archive', 'archives'], - ['additive', 'additives'], - ['hive', 'hives'], - ['beehive', 'beehives'], - ['olive', 'olives'], - ['black olive', 'black olives'], - ['chive', 'chives'], - ['adjective', 'adjectives'], - ['cattle drive', 'cattle drives'], - ['explosive', 'explosives'], - ['executive', 'executives'], - ['negative', 'negatives'], - ['fugitive', 'fugitives'], - ['progressive', 'progressives'], - ['laxative', 'laxatives'], - ['incentive', 'incentives'], - ['genesis', 'geneses'], - ['surprise', 'surprises'], - ['enterprise', 'enterprises'], - ['relative', 'relatives'], - ['positive', 'positives'], - ['perspective', 'perspectives'], - ['superlative', 'superlatives'], - ['afterlife', 'afterlives'], - ['native', 'natives'], - ['detective', 'detectives'], - ['collective', 'collectives'], - ['lowlife', 'lowlives'], - ['low-life', 'low-lives'], - ['strife', 'strifes'], - ['pony', 'ponies'], - ['phony', 'phonies'], - ['felony', 'felonies'], - ['colony', 'colonies'], - ['symphony', 'symphonies'], - ['semicolony', 'semicolonies'], - ['radiotelephony', 'radiotelephonies'], - ['company', 'companies'], - ['ceremony', 'ceremonies'], - ['carnivore', 'carnivores'], - ['emphasis', 'emphases'], - ['abuse', 'abuses'], - ['ass', 'asses'], - ['mile', 'miles'], - ['consensus', 'consensuses'], - ['coatdress', 'coatdresses'], - ['courthouse', 'courthouses'], - ['playhouse', 'playhouses'], - ['crispness', 'crispnesses'], - ['racehorse', 'racehorses'], - ['greatness', 'greatnesses'], - ['demon', 'demons'], - ['lemon', 'lemons'], - ['pokemon', 'pokemon'], - ['pokémon', 'pokémon'], - ['christmas', 'christmases'], - ['zymase', 'zymases'], - ['accomplice', 'accomplices'], - ['amice', 'amices'], - ['titmouse', 'titmice'], - ['slice', 'slices'], - ['base', 'bases'], - ['database', 'databases'], - ['rise', 'rises'], - ['uprise', 'uprises'], - ['size', 'sizes'], - ['prize', 'prizes'], - ['booby', 'boobies'], - ['hobby', 'hobbies'], - ['baby', 'babies'], - ['cookie', 'cookies'], - ['budgie', 'budgies'], - ['calorie', 'calories'], - ['brownie', 'brownies'], - ['lolly', 'lollies'], - ['hippie', 'hippies'], - ['smoothie', 'smoothies'], - ['techie', 'techies'], - ['specie', 'species'], - ['quickie', 'quickies'], - ['pixie', 'pixies'], - ['rotisserie', 'rotisseries'], - ['porkpie', 'porkpies'], - ['newbie', 'newbies'], - ['veggie', 'veggies'], - ['bourgeoisie', 'bourgeoisies'], - ['party', 'parties'], - ['apology', 'apologies'], - ['ancestry', 'ancestries'], - ['anomaly', 'anomalies'], - ['anniversary', 'anniversaries'], - ['battery', 'batteries'], - ['nappy', 'nappies'], - ['hanky', 'hankies'], - ['junkie', 'junkies'], - ['hogtie', 'hogties'], - ['footsie', 'footsies'], - ['curry', 'curries'], - ['fantasy', 'fantasies'], - ['housefly', 'houseflies'], - ['falsy', 'falsies'], - ['doggy', 'doggies'], - ['carny', 'carnies'], - ['cabby', 'cabbies'], - ['charlie', 'charlies'], - ['bookie', 'bookies'], - ['auntie', 'aunties'], - // Prototype inheritance. - ['constructor', 'constructors'], - // Non-standard case. - ['randomWord', 'randomWords'], - ['camelCase', 'camelCases'], - ['PascalCase', 'PascalCases'], - ['Alumnus', 'Alumni'], - ['CHICKEN', 'CHICKENS'], - ['日本語', '日本語'], - ['한국', '한국'], - ['中文', '中文'], - ['اللغة العربية', 'اللغة العربية'], - ['四 chicken', '四 chickens'], - ['Order2', 'Order2s'], - ['Work Order2', 'Work Order2s'], - ['SoundFX2', 'SoundFX2s'], - ['oDonald', 'oDonalds'] -] diff --git a/packages/plural/__fixtures__/plural.ts b/packages/plural/__fixtures__/plural.ts deleted file mode 100644 index 5e47104a..00000000 --- a/packages/plural/__fixtures__/plural.ts +++ /dev/null @@ -1,9 +0,0 @@ -export default [ - ['plateaux', 'plateaux'], - ['axis', 'axes'], - ['basis', 'bases'], - ['automatum', 'automata'], - ['thou', 'you'], - ['axiS', 'axeS'], - ['passerby', 'passersby'] -] diff --git a/packages/plural/__fixtures__/singular.ts b/packages/plural/__fixtures__/singular.ts deleted file mode 100644 index 21c5ad98..00000000 --- a/packages/plural/__fixtures__/singular.ts +++ /dev/null @@ -1,9 +0,0 @@ -export default [ - ['dingo', 'dingos'], - ['mango', 'mangoes'], - ['echo', 'echos'], - ['ghetto', 'ghettoes'], - ['nucleus', 'nucleuses'], - ['bureau', 'bureaux'], - ['seraph', 'seraphs'] -] diff --git a/packages/plural/__tests__/plural.test.ts b/packages/plural/__tests__/plural.test.ts deleted file mode 100644 index f3be4b96..00000000 --- a/packages/plural/__tests__/plural.test.ts +++ /dev/null @@ -1,83 +0,0 @@ -import {isPlural, isSingular, plural, singular} from '../src' -import BASIC_TESTS from '../__fixtures__/basic' -import PLURAL_TESTS from '../__fixtures__/plural' -import SINGULAR_TESTS from '../__fixtures__/singular' - -const PLURALS = [...BASIC_TESTS, ...PLURAL_TESTS] -const SINGULARS = [...BASIC_TESTS, ...SINGULAR_TESTS] - -const JUST_PLURALS = PLURALS.map(([, output]) => output) - -const JUST_SINGULARS = [...BASIC_TESTS, ...SINGULAR_TESTS].map(([input]) => input) - -describe('plural', () => { - describe('methods', () => { - describe('plural', () => { - it.each(PLURALS)('%s -> %s', (input, output) => { - expect(plural(input)).toBe(output) - }) - }) - - describe('isPlural', () => { - it.each(JUST_PLURALS)('isPlural(%s)', input => { - expect(isPlural(input)).toBe(true) - }) - }) - - describe('singular', () => { - it.each([...BASIC_TESTS, ...SINGULAR_TESTS])('%s <-- %s', (output, input) => { - expect(singular(input)).toBe(output) - }) - }) - - describe('isSingular', () => { - it.each(JUST_SINGULARS)('isSingular(%s)', input => { - expect(isSingular(input)).toBe(true) - }) - }) - }) - - describe('automatically convert', () => { - describe.each(PLURALS)('plural', (input, output) => { - // Make sure the word stays plural. - it(`5 ${output} -> ${output}`, () => { - expect(plural(output, 5)).toBe(output) - }) - - // Make sure the word becomes a plural. - if (input !== output) { - it(`5 ${input} -> ${output}`, () => { - expect(plural(input, 5)).toBe(output) - }) - } - }) - - describe.each(SINGULARS)('singular', (output, input) => { - // Make sure the word stays singular. - it(`1 ${output} -> ${output}`, () => { - expect(plural(output, 1)).toBe(output) - }) - - // Make sure the word becomes singular. - if (output !== input) { - it(`1 ${input} -> ${output}`, () => { - expect(plural(input, 1)).toBe(output) - }) - } - }) - }) - - describe('spescials', () => { - it(`Alumni -> Alumni`, () => { - expect(plural('Alumni')).toBe('Alumni') - }) - - it(`randomWord -> randomWords`, () => { - expect(plural('randomWord')).toBe('randomWords') - }) - - it(`Werewolf -> Werewolves`, () => { - expect(plural('Werewolf')).toBe('Werewolves') - }) - }) -}) diff --git a/packages/plural/docs/README.md b/packages/plural/docs/README.md deleted file mode 100644 index f414f677..00000000 --- a/packages/plural/docs/README.md +++ /dev/null @@ -1,112 +0,0 @@ -# @snickbit/plural - -## Table of contents - -### Functions - -- [isPlural](README.md#isplural) -- [isSingular](README.md#issingular) -- [plural](README.md#plural) -- [singular](README.md#singular) - -## Functions - -### isPlural - -▸ **isPlural**(`word`, `count?`): `boolean` - -Check if a word is plural. - -#### Parameters - -| Name | Type | Default value | -| :------ | :------ | :------ | -| `word` | `string` | `undefined` | -| `count` | `number` | `2` | - -#### Returns - -`boolean` - -___ - -### isSingular - -▸ **isSingular**(`word`, `count?`): `boolean` - -Check if a word is singular. - -#### Parameters - -| Name | Type | Default value | -| :------ | :------ | :------ | -| `word` | `string` | `undefined` | -| `count` | `number` | `1` | - -#### Returns - -`boolean` - -___ - -### plural - -▸ **plural**(`word`, `count?`): `any` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `word` | `string` | -| `count?` | `number` | - -#### Returns - -`any` - -▸ **plural**(`word`, `pluralized`, `count?`): `any` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `word` | `string` | -| `pluralized` | `string` | -| `count?` | `number` | - -#### Returns - -`any` - -___ - -### singular - -▸ **singular**(`word`, `count?`): `any` - -Get the singular version of a word - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `word` | `string` | -| `count?` | `number` | - -#### Returns - -`any` - -▸ **singular**(`word`, `singularized`, `count?`): `any` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `word` | `string` | -| `singularized` | `string` | -| `count?` | `number` | - -#### Returns - -`any` diff --git a/packages/plural/package.json b/packages/plural/package.json deleted file mode 100644 index 0c2f05f2..00000000 --- a/packages/plural/package.json +++ /dev/null @@ -1,46 +0,0 @@ -{ - "name": "@snickbit/plural", - "version": "1.0.19", - "description": "Pluralize and singularize any English word.", - "license": "MIT", - "exports": { - "require": "./dist/index.js", - "import": "./dist/index.mjs", - "types": "./dist/index.d.ts" - }, - "main": "./dist/index.js", - "module": "./dist/index.mjs", - "types": "./dist/index.d.ts", - "files": [ - "dist" - ], - "scripts": { - "build": "tsup --minify", - "check": "pnpm -w run lint && pnpm run typecheck", - "dev": "tsup --watch", - "docs": "typedoc src/index.ts --tsconfig tsconfig.json", - "release": "semantic-release", - "typecheck": "tsc --noEmit" - }, - "release": { - "extends": [ - "@snickbit/semantic-release" - ] - }, - "jest": { - "preset": "ts-jest", - "testEnvironment": "node" - }, - "devDependencies": { - "@types/jest": "29.5.3", - "jest": "29.6.1", - "ts-jest": "29.1.1", - "tsup": "7.1.0", - "typedoc": "0.24.8", - "typedoc-plugin-markdown": "3.15.3", - "typescript": "5.1.6" - }, - "engines": { - "node": ">= 14.17" - } -} diff --git a/packages/plural/src/index.ts b/packages/plural/src/index.ts deleted file mode 100644 index 326ffb9f..00000000 --- a/packages/plural/src/index.ts +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Get the plural version of a word - */ -import {checkWord, replaceWord} from './pluralize' - -export function plural(word: string, count?: number) -export function plural(word: string, pluralized: string, count?: number) -export function plural(word: string, countOrPluralized?: number | string, optionalCount?: number) { - let count = 2 - let pluralized = '' - if (typeof countOrPluralized === 'number') { - count = countOrPluralized - } else if (typeof countOrPluralized === 'string') { - pluralized = countOrPluralized - if (optionalCount !== undefined) { - count = optionalCount - } - } - - // if count is 1, return original string - if (Math.abs(count) === 1) { - return singular(word, 1) - } - - // if count is greater than 1 and the user provided a pluralized string, return that - if (pluralized) { - return pluralized - } - - return replaceWord(word, count) -} - -/** - * Get the singular version of a word - */ -export function singular(word: string, count?: number) -export function singular(word: string, singularized: string, count?: number) -export function singular(word: string, countOrSingularized?: number | string, optionalCount?: number) { - let count = 1 - let singularized = '' - if (typeof countOrSingularized === 'number') { - count = countOrSingularized - } else if (typeof countOrSingularized === 'string') { - singularized = countOrSingularized - if (optionalCount !== undefined) { - count = optionalCount - } - } - - // if count is 1, return original string - if (Math.abs(count) !== 1) { - return plural(word, count) - } - - // if count is not 1 and the user provided a singularized string, return that - if (singularized) { - return singularized - } - - return replaceWord(word, count) -} - -/** - * Check if a word is plural. - */ -export const isPlural = (word: string, count = 2) => checkWord(word, count) - -/** - * Check if a word is singular. - */ -export const isSingular = (word: string, count = 1) => checkWord(word, count) diff --git a/packages/plural/src/pluralize.ts b/packages/plural/src/pluralize.ts deleted file mode 100644 index 2ae00dc9..00000000 --- a/packages/plural/src/pluralize.ts +++ /dev/null @@ -1,152 +0,0 @@ -import {irregularPlurals, IrregularRule, irregularSingles} from './rules/irregular-rules' -import pluralRules from './rules/plural-rules' -import singularRules from './rules/singular-rules' -import uncountableRules from './rules/uncountable-rules' - -export type PluralRuleMatch = RegExp -export type PluralRuleReplacement = string -export type PluralRule = [PluralRuleMatch, PluralRuleReplacement] - -/** - * Pass in a word token to produce a function that can replicate the case on - * another word. - */ -function restoreCase(word: string, token: string): string { - // Tokens are an exact match. - if (word.toLowerCase() === token.toLowerCase()) { - return word - } - - // Lower cased words. E.g. "hello". - if (word === word.toLowerCase()) { - return token.toLowerCase() - } - - // Upper cased words. E.g. "WHISKY". - if (word === word.toUpperCase()) { - return token.toUpperCase() - } - - const diff = findFirstDiff(word.toLowerCase(), token.toLowerCase()) - - // starting at the index of diff, match casing of each character - let result = word.slice(0, diff) - let lowers = /[a-z]/.test(word) ? 1 : 0 - for (let index = diff; index < token.length; index++) { - if (word[index] !== undefined) { - // check the casing of the character in the original string - if (word[index] === word[index].toUpperCase() && word[index] !== word[index].toLowerCase()) { - result += token[index].toUpperCase() - } else { - lowers++ - result += token[index].toLowerCase() - } - } else if (token[index] !== undefined) { - result += lowers === -1 ? token[index].toUpperCase() : token[index].toLowerCase() - } - } - - return result -} - -function findFirstDiff(first, second): number { - let index = 0 - if (first === second) { - return -1 - } - while (first[index] === second[index]) { - index++ - } - return index -} - -/** - * Sanitize a word by passing in the word and sanitization rules. - */ -function sanitizeWord(token: string, word: string, rules: PluralRule[]): string { - // Empty string or doesn't need fixing. - if (!token.length || uncountableRules.includes(token)) { - return word - } - - let len = rules.length - - // Iterate over the sanitization rules and use the first one to match. - while (len--) { - const rule = rules[len] - const [matcher, replacer] = rule - - if (matcher.test(word)) { - return restoreCase(word, word.replace(matcher, replacer)) - } - } - - return word -} - -function getRules(count: number) { - let keep: IrregularRule - let replace: IrregularRule - let rules: PluralRule[] - - if (Math.abs(count) === 1) { - replace = irregularPlurals - keep = irregularSingles - rules = singularRules - } else { - replace = irregularSingles - keep = irregularPlurals - rules = pluralRules - } - - return { - keep, - replace, - rules - } -} - -export function replaceWord(word: string, count: number) { - const { - keep, - replace, - rules - } = getRules(count) - - // Get the correct token and case restoration functions. - const token = word.toLowerCase() - - // Check against the keep object map. - if (Object.keys(keep).includes(token)) { - return restoreCase(word, token) - } - - // Check against the replacement map for a direct word replacement. - if (Object.keys(replace).includes(token)) { - return restoreCase(word, replace[token]) - } - - // Run all the rules against the word. - return sanitizeWord(token, word, rules) -} - -export function checkWord(word: string, count: number) { - const { - keep, - replace, - rules - } = getRules(count) - - const token = word.toLowerCase() - - if (Object.keys(keep).includes(token)) { - return true - } - - if (Object.keys(replace).includes(token)) { - return false - } - - return sanitizeWord(token, token, rules) === token -} - diff --git a/packages/plural/src/rules/irregular-rules.ts b/packages/plural/src/rules/irregular-rules.ts deleted file mode 100644 index edfd3ed6..00000000 --- a/packages/plural/src/rules/irregular-rules.ts +++ /dev/null @@ -1,200 +0,0 @@ -// noinspection JSNonASCIINames,NonAsciiCharacters - -export type IrregularRule = Record - -const irregulars = { - addendum: 'addenda', - aircraft: 'aircraft', - alga: 'algae', - alumna: 'alumnae', - alumnus: 'alumni', - amoeba: 'amoebae', - analysis: 'analyses', - antenna: 'antennae', - antithesis: 'antitheses', - apex: 'apices', - appendix: 'appendices', - automaton: 'automata', - axis: 'axes', - bacillus: 'bacilli', - bacterium: 'bacteria', - barracks: 'barracks', - beau: 'beaux', - bison: 'bison', - buffalo: 'buffalo', - bureau: 'bureaus', - cactus: 'cacti', - calf: 'calves', - carp: 'carp', - census: 'censuses', - chassis: 'chassis', - cherub: 'cherubim', - child: 'children', - château: 'châteaus', - cod: 'cod', - codex: 'codices', - concerto: 'concerti', - corpus: 'corpora', - crisis: 'crises', - criterion: 'criteria', - curriculum: 'curricula', - datum: 'data', - deer: 'deer', - diagnosis: 'diagnoses', - die: 'dice', - dwarf: 'dwarfs', // "Dwarves" is only the plural of dwarf in Middle-Earth. - echo: 'echoes', - elf: 'elves', - elk: 'elk', - ellipsis: 'ellipses', - embargo: 'embargoes', - emphasis: 'emphases', - erratum: 'errata', - 'faux pas': 'faux pas', - fez: 'fezes', - firmware: 'firmware', - fish: 'fish', - focus: 'foci', - foot: 'feet', - formula: 'formulae', - fungus: 'fungi', - gallows: 'gallows', - genus: 'genera', - goose: 'geese', - graffito: 'graffiti', - grouse: 'grouse', - half: 'halves', - hero: 'heroes', - hoof: 'hooves', - hovercraft: 'hovercraft', - hypothesis: 'hypotheses', - index: 'indices', - kakapo: 'kakapo', - knife: 'knives', - larva: 'larvae', - leaf: 'leaves', - libretto: 'libretti', - life: 'lives', - loaf: 'loaves', - locus: 'loci', - louse: 'lice', - man: 'men', - matrix: 'matrices', - means: 'means', - medium: 'media', - memorandum: 'memoranda', - millennium: 'millennia', - minutia: 'minutiae', - moose: 'moose', - mouse: 'mice', - nebula: 'nebulae', - nemesis: 'nemeses', - neurosis: 'neuroses', - news: 'news', - nucleus: 'nuclei', - oasis: 'oases', - offspring: 'offspring', - opus: 'opera', - ovum: 'ova', - ox: 'oxen', - paralysis: 'paralyses', - parenthesis: 'parentheses', - person: 'people', - phenomenon: 'phenomena', - phylum: 'phyla', - pike: 'pike', - polyhedron: 'polyhedra', - potato: 'potatoes', - prognosis: 'prognoses', - quiz: 'quizzes', - radius: 'radii', - referendum: 'referenda', - salmon: 'salmon', - scarf: 'scarves', - self: 'selves', - series: 'series', - sheep: 'sheep', - shelf: 'shelves', - shrimp: 'shrimp', - soliloquy: 'soliloquies', - spacecraft: 'spacecraft', - specie: 'species', - spectrum: 'spectra', - squid: 'squid', - stimulus: 'stimuli', - stratum: 'strata', - swine: 'swine', - syllabus: 'syllabi', - symposium: 'symposia', - synopsis: 'synopses', - synthesis: 'syntheses', - tableau: 'tableaus', - that: 'those', - thesis: 'theses', - thief: 'thieves', - this: 'these', - tomato: 'tomatoes', - tooth: 'teeth', - trout: 'trout', - tuna: 'tuna', - vertebra: 'vertebrae', - vertex: 'vertices', - veto: 'vetoes', - vita: 'vitae', - vortex: 'vortices', - watercraft: 'watercraft', - wharf: 'wharves', - wife: 'wives', - wolf: 'wolves', - woman: 'women', - I: 'we', - me: 'us', - he: 'they', - she: 'they', - them: 'them', - myself: 'ourselves', - yourself: 'yourselves', - itself: 'themselves', - herself: 'themselves', - himself: 'themselves', - themself: 'themselves', - is: 'are', - was: 'were', - has: 'have', - my: 'our', - its: 'their', - his: 'their', - her: 'their', - dingo: 'dingoes', - volcano: 'volcanoes', - tornado: 'tornadoes', - torpedo: 'torpedoes', - viscus: 'viscera', - stigma: 'stigmata', - stoma: 'stomata', - dogma: 'dogmata', - lemma: 'lemmata', - schema: 'schemata', - anathema: 'anathemata', - axe: 'axes', - yes: 'yeses', - eave: 'eaves', - human: 'humans', - proof: 'proofs', - carve: 'carves', - valve: 'valves', - looey: 'looies', - groove: 'grooves', - pickaxe: 'pickaxes', - passerby: 'passersby' -} - -export const irregularSingles = {} as IrregularRule -export const irregularPlurals = {} as IrregularRule - -for (const single in irregulars) { - const plural = irregulars[single] - irregularSingles[single] = plural - irregularPlurals[plural] = single -} - diff --git a/packages/plural/src/rules/plural-rules.ts b/packages/plural/src/rules/plural-rules.ts deleted file mode 100644 index eb84e446..00000000 --- a/packages/plural/src/rules/plural-rules.ts +++ /dev/null @@ -1,30 +0,0 @@ -import {PluralRule} from '../pluralize' - -export default [ - [/s?$/i, 's'], - // eslint-disable-next-line no-control-regex - [/[^\u0000-\u007F]$/i, '$&'], - [/([^aeiou]ese)$/i, '$1'], - [/(ax|test)is$/i, '$1es'], - [/(alias|[^aou]us|t[lm]as|gas|ris)$/i, '$1es'], - [/(e[mn]u)s?$/i, '$1s'], - [/([^l]ias|[aeiou]las|[ejrz]as|[iu]am)$/i, '$1'], - [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, '$1i'], - [/(alumn|alg|vertebr)(?:a|ae)$/i, '$1ae'], - [/(seraph|cherub)(?:im)?$/i, '$1im'], - [/(her|at|gr)o$/i, '$1oes'], - [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, '$1a'], - [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, '$1a'], - [/sis$/i, 'ses'], - [/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, '$1$2ves'], - [/([^aeiouy]|qu)y$/i, '$1ies'], - [/([^ch][eio][ln])ey$/i, '$1ies'], - [/(x|ch|ss|sh|zz)$/i, '$1es'], - [/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, '$1ices'], - [/\b((?:tit)?m|l)(?:ice|ouse)$/i, '$1ice'], - [/(pe)(?:rson|ople)$/i, '$1ople'], - [/(child)(?:ren)?$/i, '$1ren'], - [/eaux$/i, '$&'], - [/m[ae]n$/i, 'men'], - [/thou$/i, 'you'] -] as PluralRule[] diff --git a/packages/plural/src/rules/singular-rules.ts b/packages/plural/src/rules/singular-rules.ts deleted file mode 100644 index 89b14a69..00000000 --- a/packages/plural/src/rules/singular-rules.ts +++ /dev/null @@ -1,29 +0,0 @@ -import {PluralRule} from '../pluralize' - -export default [ - [/s$/i, ''], - [/(ss)$/i, '$1'], - [/(wi|kni|(?:after|half|high|low|mid|non|night|\W|^)li)ves$/i, '$1fe'], - [/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, '$1f'], - [/ies$/i, 'y'], - [/(dg|ss|ois|lk|ok|wn|mb|th|ch|ec|oal|is|ck|ix|sser|ts|wb)ies$/i, '$1ie'], - [/\b(l|(?:neck|cross|hog|aun)?t|coll|faer|food|gen|goon|group|hipp|junk|vegg|(?:pork)?p|charl|calor|cut)ies$/i, '$1ie'], - [/\b(mon|smil)ies$/i, '$1ey'], - [/\b((?:tit)?m|l)ice$/i, '$1ouse'], - [/(seraph|cherub)im$/i, '$1'], - [/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, '$1'], - [/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, '$1sis'], - [/(movie|twelve|abuse|e[mn]u)s$/i, '$1'], - [/(test)(?:is|es)$/i, '$1is'], - [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, '$1us'], - [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, '$1um'], - [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, '$1on'], - [/(alumn|alg|vertebr)ae$/i, '$1a'], - [/(cod|mur|sil|vert|ind)ices$/i, '$1ex'], - [/(matr|append)ices$/i, '$1ix'], - [/(pe)(rson|ople)$/i, '$1rson'], - [/(child)ren$/i, '$1'], - [/(eau)x?$/i, '$1'], - [/men$/i, 'man'] -] as PluralRule[] - diff --git a/packages/plural/src/rules/uncountable-rules.ts b/packages/plural/src/rules/uncountable-rules.ts deleted file mode 100644 index 7ef370d0..00000000 --- a/packages/plural/src/rules/uncountable-rules.ts +++ /dev/null @@ -1,130 +0,0 @@ -import {PluralRuleMatch} from '../pluralize' -import pluralRules from './plural-rules' -import singularRules from './singular-rules' - -export const uncountables = [ - // Singular words with no plurals. - 'adulthood', - 'advice', - 'agenda', - 'aid', - 'aircraft', - 'alcohol', - 'ammo', - 'analytics', - 'anime', - 'athletics', - 'audio', - 'bison', - 'blood', - 'bream', - 'buffalo', - 'butter', - 'carp', - 'cash', - 'chassis', - 'chess', - 'clothing', - 'cod', - 'commerce', - 'cooperation', - 'corps', - 'debris', - 'diabetes', - 'digestion', - 'elk', - 'energy', - 'equipment', - 'excretion', - 'expertise', - 'firmware', - 'flounder', - 'fun', - 'gallows', - 'garbage', - 'graffiti', - 'hardware', - 'headquarters', - 'health', - 'herpes', - 'highjinks', - 'homework', - 'housework', - 'information', - 'jeans', - 'justice', - 'kudos', - 'labour', - 'literature', - 'machinery', - 'mackerel', - 'mail', - 'mews', - 'moose', - 'music', - 'mud', - 'manga', - 'news', - 'only', - 'personnel', - 'pike', - 'plankton', - 'pliers', - 'police', - 'pollution', - 'premises', - 'rain', - 'research', - 'rice', - 'salmon', - 'scissors', - 'series', - 'sewage', - 'shambles', - 'shrimp', - 'software', - 'staff', - 'swine', - 'tennis', - 'traffic', - 'transportation', - 'trout', - 'tuna', - 'wealth', - 'welfare', - 'whiting', - 'wildebeest', - 'wildlife', - 'you', - /pok[eé]mon$/i, - // Regexes. - /[^aeiou]ese$/i, // "chinese", "japanese" - /deer$/i, // "deer", "reindeer" - /fish$/i, // "fish", "blowfish", "angelfish" - /measles$/i, - /o[iu]s$/i, // "carnivorous" - /pox$/i, // "chickenpox", "smallpox" - /sheep$/i -] - -const uncountableRules: string[] = [] - -for (const uncountable of uncountables) { - if (typeof uncountable === 'string') { - uncountableRules.push(uncountable.toLowerCase()) - continue - } - - pluralRules.push([sanitizeRule(uncountable), '$&']) - singularRules.push([sanitizeRule(uncountable), '$&']) -} - -function sanitizeRule(rule: PluralRuleMatch | string): RegExp { - if (typeof rule === 'string') { - return new RegExp(`^${rule}$`, 'i') - } - - return rule -} - -export default uncountableRules diff --git a/packages/plural/tsconfig.json b/packages/plural/tsconfig.json deleted file mode 100644 index ba1ab297..00000000 --- a/packages/plural/tsconfig.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "include": [ - "src/**/*.ts", - "__tests__/**/*.ts", - "__fixtures__/**/*.ts" - ] -} diff --git a/packages/plural/typedoc.json b/packages/plural/typedoc.json deleted file mode 100644 index 44bd80f2..00000000 --- a/packages/plural/typedoc.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": [ - "../../typedoc.json" - ], - "entryPoints": [ - "src/index.ts" - ] -} diff --git a/packages/queue/package.json b/packages/queue/package.json index 5bd4c9ea..9786e7fe 100644 --- a/packages/queue/package.json +++ b/packages/queue/package.json @@ -1,6 +1,6 @@ { "name": "@snickbit/queue", - "version": "1.3.9", + "version": "1.3.10", "description": "Fluid queueing library for any function or promise", "license": "MIT", "exports": { @@ -37,7 +37,7 @@ "lite-fifo": "0.3.3" }, "devDependencies": { - "@snickbit/indexer": "2.9.1", + "@snickbit/indexer": "2.9.4", "@types/jest": "29.5.3", "jest": "29.6.1", "ts-jest": "29.1.1", diff --git a/packages/spinner/package.json b/packages/spinner/package.json index cf3c4dd2..67caaa7b 100644 --- a/packages/spinner/package.json +++ b/packages/spinner/package.json @@ -1,6 +1,6 @@ { "name": "@snickbit/spinner", - "version": "1.3.4", + "version": "1.3.6", "description": "Minimal terminal spinner for Node.js", "license": "MIT", "exports": { @@ -31,12 +31,12 @@ }, "dependencies": { "@snickbit/ansi": "^0.0.26", - "@snickbit/utilities": "3.11.3", + "@snickbit/utilities": "3.12.0", "cli-spinners": "^2.9.0", "kleur": "^4.1.5" }, "devDependencies": { - "@snickbit/indexer": "2.9.1", + "@snickbit/indexer": "2.9.4", "@types/node": "20.4.2", "tsup": "7.1.0", "tsx": "3.12.7", diff --git a/packages/state/package.json b/packages/state/package.json index 964be836..20a249be 100644 --- a/packages/state/package.json +++ b/packages/state/package.json @@ -1,6 +1,6 @@ { "name": "@snickbit/state", - "version": "1.0.11", + "version": "1.0.14", "description": "Simple state management for TypeScript", "license": "MIT", "exports": { @@ -32,7 +32,7 @@ "testEnvironment": "node" }, "dependencies": { - "@snickbit/utilities": "3.11.3", + "@snickbit/utilities": "3.11.4", "mitt": "3.0.1" }, "devDependencies": { diff --git a/packages/upwords/package.json b/packages/upwords/package.json index a800eaa4..905b87f6 100644 --- a/packages/upwords/package.json +++ b/packages/upwords/package.json @@ -1,6 +1,6 @@ { "name": "@snickbit/upwords", - "version": "2.0.40", + "version": "2.0.41", "description": "Helper function to convert a string to title case, attempting to preserve acronyms and special case words.", "license": "MIT", "exports": { diff --git a/packages/utilities/CHANGELOG.md b/packages/utilities/CHANGELOG.md deleted file mode 100644 index b211ee11..00000000 --- a/packages/utilities/CHANGELOG.md +++ /dev/null @@ -1,218 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. See -[Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -## @snickbit/utilities [3.4.19](https://github.com/remedyred/snickbit.js/compare/@snickbit/utilities@3.4.18...@snickbit/utilities@3.4.19) (2023-03-03) - - -### Bug Fixes - -* remove depcheck ([#119](https://github.com/remedyred/snickbit.js/issues/119)) ([0fb970f](https://github.com/remedyred/snickbit.js/commit/0fb970fe23d85f4e678fbdca577c877b059a86fb)) - - - -### Dependencies - -* **@snickbit/plural:** upgraded to 1.0.13 - -# Change Log - -All notable changes to this project will be documented in this file. -See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. - -# [3.4.0](https://github.com/snickbit/snickbit.js/compare/@snickbit/utilities@3.3.1...@snickbit/utilities@3.4.0) (2022-08-19) - -### Features - -* **numbers:** add numberEven and numberOdd helper functions ([#27](https://github.com/snickbit/snickbit.js/issues/27)) ([ac1ba83](https://github.com/snickbit/snickbit.js/commit/ac1ba8394e58dc283963c0aa4e2d1b60e5f0f8a5)) - -## [3.3.1](https://github.com/snickbit/snickbit.js/compare/@snickbit/utilities@3.3.0...@snickbit/utilities@3.3.1) (2022-08-13) - -**Note:** Version bump only for package @snickbit/utilities - -# [3.3.0](https://github.com/snickbit/snickbit.js/compare/@snickbit/utilities@3.2.2...@snickbit/utilities@3.3.0) (2022-08-11) - -### Features - -* **objects:** add objectSort helper ([8347e1e](https://github.com/snickbit/snickbit.js/commit/8347e1eb5bdd8d51dd9ed6ccc3a762140032a4fa)) -* **utilities:** Add generics and tests to object helpers ([#15](https://github.com/snickbit/snickbit.js/issues/15)) ([1dc46bc](https://github.com/snickbit/snickbit.js/commit/1dc46bc925757607186b867e8c018c3b36644753)) - -## [3.2.2](https://github.com/snickbit/snickbit.js/compare/@snickbit/utilities@3.2.1...@snickbit/utilities@3.2.2) (2022-08-06) - -**Note:** Version bump only for package @snickbit/utilities - -## [3.2.1](https://github.com/snickbit/snickbit.js/compare/@snickbit/utilities@3.2.0...@snickbit/utilities@3.2.1) (2022-08-05) - -**Note:** Version bump only for package @snickbit/utilities - -# @snickbit/utilities - -## 3.2.0 - -### Minor Changes - -- [6e47996](https://github.com/snickbit/snickbit.js/commit/6e47996) **docs**: update -- [e6aab6b](https://github.com/snickbit/snickbit.js/commit/e6aab6b) **feat**: add isBoolean -- [1a3a6c4](https://github.com/snickbit/snickbit.js/commit/1a3a6c4) **fix**: make includeNullUndefined optional for isPrimitive -- [d8f9235](https://github.com/snickbit/snickbit.js/commit/d8f9235) **docs**: update -- [fe0a883](https://github.com/snickbit/snickbit.js/commit/fe0a883) **fix**: replace isType with specific helper classes -- [07af361](https://github.com/snickbit/snickbit.js/commit/07af361) **fix**: overhaul validations to include typescript predicates -- [fbb0222](https://github.com/snickbit/snickbit.js/commit/fbb0222) **chore**: bump dependencies - -## 3.1.0 - -### Minor Changes - -- [92edee6](https://github.com/snickbit/snickbit.js/commit/92edee6) **docs**: update -- [4f04a11](https://github.com/snickbit/snickbit.js/commit/4f04a11) **docs**: update jsDoc definitions for numbers -- [516291b](https://github.com/snickbit/snickbit.js/commit/516291b) **test**: add numberPad tests -- [f46edd1](https://github.com/snickbit/snickbit.js/commit/f46edd1) **feat**: allow numberPad to pad to more than 2 characters -- [f835d9c](https://github.com/snickbit/snickbit.js/commit/f835d9c) **feat**: add randomBetween helper function -- [07b67e3](https://github.com/snickbit/snickbit.js/commit/07b67e3) **chore**: update dependencies - -## 3.0.28 - -### Patch Changes - -- [ad55cdf](https://github.com/snickbit/snickbit.js/commit/ad55cdf) **fix**: migrate to @snickbit/indexer -- [c5a5cf2](https://github.com/snickbit/snickbit.js/commit/c5a5cf2) **chore**: bump dependencies -- [dadd932](https://github.com/snickbit/snickbit.js/commit/dadd932) **chore**: bump dependencies -- [9bf343e](https://github.com/snickbit/snickbit.js/commit/9bf343e) **chore**: bump deps - -## 3.0.27 - -### Patch Changes - -- [3cf4eae](https://github.com/snickbit/snickbit.js/commit/3cf4eae) **fix**: remove workspace protocol - -## 3.0.26 - -### Patch Changes - -- [1aa47de](https://github.com/snickbit/snickbit.js/commit/1aa47de) **docs**: update -- [a05ea6b](https://github.com/snickbit/snickbit.js/commit/a05ea6b) **chore**: update dependencies -- [afe2581](https://github.com/snickbit/snickbit.js/commit/afe2581) **fix**: update type to be any -- [db8b8b5](https://github.com/snickbit/snickbit.js/commit/db8b8b5) **chore**: update dependencies - -## 3.0.25 - -### Patch Changes - -- [45fc8e9](https://github.com/snickbit/snickbit.js/commit/45fc8e9) **fix**: remove workspace protocol - -## 3.0.24 - -### Patch Changes - -- [66624f1](https://github.com/snickbit/snickbit.js/commit/66624f1) **chore**: update dependencies -- [f7e55ec](https://github.com/snickbit/snickbit.js/commit/f7e55ec) **docs**: update - -## 3.0.23 - -### Patch Changes - -- [a8694ff](https://github.com/snickbit/snickbit.js/commit/a8694ff) **fix**: remove workspace protocol -- [6fe1985](https://github.com/snickbit/snickbit.js/commit/6fe1985) **chore**: bump dependencies - -## 3.0.22 - -### Patch Changes - -- [5ae5d0a](https://github.com/snickbit/snickbit.js/commit/5ae5d0a) **chore**: bump dependencies -- [1b4e5bf](https://github.com/snickbit/snickbit.js/commit/1b4e5bf) **docs**: update -- [3c0265a](https://github.com/snickbit/snickbit.js/commit/3c0265a) **chore**: remove plur dependency -- [2c2ffb7](https://github.com/snickbit/snickbit.js/commit/2c2ffb7) **chore**: add workspace protocol -- [ad3e17c](https://github.com/snickbit/snickbit.js/commit/ad3e17c) **feat**: add findFirstDiff helper -- [9905c96](https://github.com/snickbit/snickbit.js/commit/9905c96) **feat**: replace plur with @snickbit/plural -- [af8be48](https://github.com/snickbit/snickbit.js/commit/af8be48) **chore**: remove ide inspection comments -- [d1a5e3a](https://github.com/snickbit/snickbit.js/commit/d1a5e3a) **fix**: replace pluralize with plur - -## 3.0.21 - -### Patch Changes - -- [ca07e6b](https://github.com/snickbit/snickbit.js/commit/ca07e6b) **style**: heavy code restyling -- [5665547](https://github.com/snickbit/snickbit.js/commit/5665547) **chore**: bump dependencies -- [b7a81fe](https://github.com/snickbit/snickbit.js/commit/b7a81fe) **fix**: remove default underscore from safeVarName and replace with optional string -- [7347cef](https://github.com/snickbit/snickbit.js/commit/7347cef) **chore**: update indexer config -- [b3676ba](https://github.com/snickbit/snickbit.js/commit/b3676ba) **refactor**: split all is* methods into validations -- [1f54b0e](https://github.com/snickbit/snickbit.js/commit/1f54b0e) **chore**: bump indexer version, and rerun -- [a932b4f](https://github.com/snickbit/snickbit.js/commit/a932b4f) **chore**: bump indexer version -- [cffb49e](https://github.com/snickbit/snickbit.js/commit/cffb49e) **build**: rebuild indexes on prod - -## 3.0.20 - -### Patch Changes - -- [e114dc3](https://github.com/snickbit/snickbit.js/commit/e114dc3) **docs**: update -- [d6a1f20](https://github.com/snickbit/snickbit.js/commit/d6a1f20) **fix**: options parsing and type definition -- [d0f6c5d](https://github.com/snickbit/snickbit.js/commit/d0f6c5d) **style**: shorten import -- [de1532c](https://github.com/snickbit/snickbit.js/commit/de1532c) **test**: add arrayReject test -- [facbd0c](https://github.com/snickbit/snickbit.js/commit/facbd0c) **fix**: convert to arrow function -- [ff43f0d](https://github.com/snickbit/snickbit.js/commit/ff43f0d) **style**: sort package.json -- [769e3b9](https://github.com/snickbit/snickbit.js/commit/769e3b9) **style**: relint -- [3bf8776](https://github.com/snickbit/snickbit.js/commit/3bf8776) **chore**: update indexer and indexer config - -## 3.0.19 - -### Patch Changes - -- [4ca542a](https://github.com/snickbit/snickbit.js/commit/4ca542a) **build**: switch to pnpm for running -- [d479dbb](https://github.com/snickbit/snickbit.js/commit/d479dbb) **docs**: update -- [28b8137](https://github.com/snickbit/snickbit.js/commit/28b8137) **feat**: add array reject helper - -## 3.0.18 - -### Patch Changes - -- [da8a0b3](https://github.com/snickbit/snickbit.js/commit/da8a0b3) **style**: reformat - -## 3.0.17 - -### Patch Changes - -- [d4a042e](https://github.com/snickbit/snickbit.js/commit/d4a042e) **chore**: update dependencies -- [c6f76f8](https://github.com/snickbit/snickbit.js/commit/c6f76f8) **build**: add dev watcher scripts with source maps -- [447e7b0](https://github.com/snickbit/snickbit.js/commit/447e7b0) **docs**: update chore: update dependencies chore: adjust configurations - -## 3.0.16 - -### Patch Changes - -- [db8b5a7](https://github.com/snickbit/snickbit.js/commit/db8b5a7) **fix**: remove buffer helper to maintain full browser compatibility -- [b61521a](https://github.com/snickbit/snickbit.js/commit/b61521a) **chore**: update build config -- [67a87da](https://github.com/snickbit/snickbit.js/commit/67a87da) **docs**: update - -## 3.0.15 - -### Patch Changes - -- [8a65a3c](https://github.com/snickbit/snickbit.js/commit/8a65a3c) **chore**: update dependencies - -## 3.0.14 - -### Patch Changes - -- [c7fb5bc](https://github.com/snickbit/snickbit.js/commit/c7fb5bc) **docs**: update -- [ef3ba51](https://github.com/snickbit/snickbit.js/commit/ef3ba51) **chore**: update build config -- [164874d](https://github.com/snickbit/snickbit.js/commit/164874d) **chore**: update build config -- [a10d1e5](https://github.com/snickbit/snickbit.js/commit/a10d1e5) **fix**(utilities): simplify bufferStream - -## 3.0.12 - -### Patch Changes - -- 7af5524: chore: update config - -## 3.0.2 - -### Patch Changes - -- 7239e6e: Overhaul build configurations - -## 3.0.1 - -### Major Changes - -- 2ee680d: First public release diff --git a/packages/utilities/README.md b/packages/utilities/README.md deleted file mode 100644 index 61148390..00000000 --- a/packages/utilities/README.md +++ /dev/null @@ -1,29 +0,0 @@ -# @snickbit/utilities - - - -This is a collection of basic helper functions with very minimal dependencies. - - - -## Installation - -```bash -yarn add @snickbit/utilities -``` - -```bash -npm add @snickbit/utilities -``` - -## Documentation - -### [API Docs](./docs/README.md) - -### [CHANGELOG](CHANGELOG.md) - -## License - -Copyright (c) 2022 - **Nicholas Lowe** aka **Snickbit** - -[MIT License](../../LICENSE) diff --git a/packages/utilities/__tests__/arrays.test.ts b/packages/utilities/__tests__/arrays.test.ts deleted file mode 100644 index f3cacd9e..00000000 --- a/packages/utilities/__tests__/arrays.test.ts +++ /dev/null @@ -1,63 +0,0 @@ -import {arrayReject, arrayUnique, arrayUniqueInsensitive} from '../src' - -const mock_array_numbers = [ - 1, - 2, - 3, - 4, - 5, - 6, - 7, - 8, - 9, - 10 -] - -const mock_array_strings = [ - 'one', - 'two', - 'three', - 'four', - 'five', - 'six', - 'seven', - 'eight', - 'nine', - 'ten' -] - -describe('arrays', () => { - it('arrayReject(arr, callback) should return opposite of callback', () => { - const arr = [...mock_array_numbers] - - /* eslint-disable unicorn/consistent-function-scoping */ - const callback = (...args: any[]) => args[0] > 5 - expect(arrayReject(arr, callback)).toEqual([ - 1, - 2, - 3, - 4, - 5 - ]) - }) - - it('arrayUnique(arr) should return unique values (case sensitive)', () => { - const arr_upper = mock_array_strings.map(str => str.toUpperCase()) - const arr = [ - ...mock_array_strings, - ...arr_upper, - ...mock_array_strings - ] - expect(arrayUnique(arr)).toEqual([...mock_array_strings, ...arr_upper]) - }) - - it('arrayUniqueInsensitive(arr) should return unique values (case insensitive)', () => { - const arr_upper = mock_array_strings.map(str => str.toUpperCase()) - const arr = [ - ...mock_array_strings, - ...arr_upper, - ...mock_array_strings - ] - expect(arrayUniqueInsensitive(arr)).toEqual(mock_array_strings) - }) -}) diff --git a/packages/utilities/__tests__/functions.test.ts b/packages/utilities/__tests__/functions.test.ts deleted file mode 100644 index 7535fb72..00000000 --- a/packages/utilities/__tests__/functions.test.ts +++ /dev/null @@ -1,118 +0,0 @@ -import {overloadOptions, OverloadSchema, parseOptions} from '../src' - -describe('parseOptions', () => { - test('parseOptions({test: true, two: false}, {test: false, other: false}) should return {test: true, other: false, two: false}', () => { - const test_object = { - test: true, - two: false - } - const default_object = { - test: false, - other: false - } - const expected_object = { - test: true, - other: false, - two: false - } - expect(parseOptions(test_object, default_object)).toEqual(expected_object) - }) - - test('parseOptions(true, {test: false, other: false}, "test") should return {test: true, other: false}', () => { - const test_object = true - const default_object = { - test: false, - other: false - } - const expected_object = { - test: true, - other: false - } - expect(parseOptions(test_object, default_object, 'test')).toEqual(expected_object) - }) - - test('parseOptions(undefined, true) should return throw a TypeError', () => { - const test_object = undefined - const default_object = true - // @ts-expect-error - expect(() => parseOptions(test_object, default_object)).toThrow(TypeError) - }) - - test('parseOptions({test: true, two: false}, {test: false, other: false}) should return {test: true, other: false, two: false}', () => { - const test_object = { - test: undefined, - two: false - } - const default_object = { - test: false, - other: false - } - const expected_object = { - test: false, - other: false, - two: false - } - expect(parseOptions(test_object, default_object)).toEqual(expected_object) - }) -}) - -describe('overloadOptions', () => { - const baseChannel = 'test' - const baseContext = { - test: false, - other: false - } - const baseConfig = { - test: true, - other: false, - two: false - } - const baseSchemas: OverloadSchema[] = [ - { - channel: 'string', - context: 'object', - config: 'object' - }, - { - context: 'object', - config: 'object' - } - ] - - const baseExpected = { - channel: 'test', - context: { - test: false, - other: false - }, - config: { - test: true, - other: false, - two: false - } - } - - test('overloadOptions("test", {}, {}) = {channel: "test", context: {}, config: {}}', () => { - expect(overloadOptions([ - baseChannel, - baseContext, - baseConfig - ], baseSchemas)).toEqual(baseExpected) - }) - - test('overloadOptions({}, {}) = {context: {}, config: {}}', () => { - const expected = { - context: baseExpected.context, - config: baseExpected.config - } - expect(overloadOptions([baseContext, baseConfig], baseSchemas)).toEqual(expected) - }) - - test('overloadOptions("test", {}) = {channel: "test", context: {}, config: undefined}', () => { - const expected = { - channel: baseExpected.channel, - context: baseExpected.context - } - expect(overloadOptions([baseChannel, baseContext], baseSchemas)).toEqual(expected) - }) -}) diff --git a/packages/utilities/__tests__/generators.test.ts b/packages/utilities/__tests__/generators.test.ts deleted file mode 100644 index f40a68a1..00000000 --- a/packages/utilities/__tests__/generators.test.ts +++ /dev/null @@ -1,11 +0,0 @@ -import {randomString} from '../src' - -test('randomString should return a random 10 character string', () => { - const result = randomString(10) - expect(result.length).toBe(10) -}) - -test('randomString should return a random 32 character string', () => { - const result = randomString(32) - expect(result.length).toBe(32) -}) diff --git a/packages/utilities/__tests__/numbers.test.ts b/packages/utilities/__tests__/numbers.test.ts deleted file mode 100644 index 01b76bda..00000000 --- a/packages/utilities/__tests__/numbers.test.ts +++ /dev/null @@ -1,76 +0,0 @@ -import {numberEven, numberOdd, numberPad} from '../src' - -describe('numbers', () => { - describe('numberPad', () => { - it('(5) should return 05', () => { - expect(numberPad(5)).toBe('05') - }) - it('(5, 2) should return 05', () => { - expect(numberPad(5, 2)).toBe('05') - }) - - it('(50, 2) should return 50', () => { - expect(numberPad(50, 2)).toBe('50') - }) - - it('(500, 2) should return 500', () => { - expect(numberPad(500, 2)).toBe('500') - }) - - it('(5, 3) should return 005', () => { - expect(numberPad(5, 3)).toBe('005') - }) - - it('(50, 3) should return 050', () => { - expect(numberPad(50, 3)).toBe('050') - }) - - it('(500, 3) should return 500', () => { - expect(numberPad(500, 3)).toBe('500') - }) - }) - - describe('numberEven', () => { - it.each([ - [0, 0], - [1, 2], - [2, 2], - [3, 4], - [4, 4] - ])('should return %d as the even number %d', (subject, result) => { - expect(numberEven(subject)).toBe(result) - }) - - it.each([ - [0, 0], - [1, 0], - [2, 2], - [3, 2], - [4, 4] - ])('should return %d as the even number %d by subtraction', (subject, result) => { - expect(numberEven(subject, true)).toBe(result) - }) - }) - - describe('numberOdd', () => { - it.each([ - [0, 1], - [1, 1], - [2, 3], - [3, 3], - [4, 5] - ])('should return %d as the odd number %d', (subject, result) => { - expect(numberOdd(subject)).toBe(result) - }) - - it.each([ - [0, -1], - [1, 1], - [2, 1], - [3, 3], - [4, 3] - ])('should return %d as the odd number %d', (subject, result) => { - expect(numberOdd(subject, true)).toBe(result) - }) - }) -}) diff --git a/packages/utilities/__tests__/objects.test.ts b/packages/utilities/__tests__/objects.test.ts deleted file mode 100644 index 4e2dbc52..00000000 --- a/packages/utilities/__tests__/objects.test.ts +++ /dev/null @@ -1,344 +0,0 @@ -/* eslint-disable unicorn/consistent-function-scoping */ -import { - objectClone, - objectCopy, - objectExcept, - objectFilter, - objectFind, - objectFindEntry, - objectFindKey, - objectFlatten, - objectGetMethod, - objectHasMethod, - objectMerge, - objectMergeDeep, - objectMethods, - objectOnly, - ObjectPredicate, - objectPull, - objectSort -} from '../src' - -const mockPlainObject = { - a: 1, - b: 2, - c: 3 -} - -const mockSubObject = { - e: 4, - f: 5, - g: 6 -} - -const nestedObject = { - ...mockPlainObject, - d: mockSubObject -} - -const mockObject = { - ...nestedObject, - h() { - return 7 - } -} - -const mockExtraObject = { - i: 8, - j: 9, - k: 10 -} - -const mockObjectWithArray = { - ...mockPlainObject, - l: [ - 11, - 12, - 13 - ] -} - -const mockObjectWithSameArray = {l: [14, 15]} - -describe('objects', () => { - describe('objectFindKey', () => { - it('should expose a function', () => { - expect(objectFindKey).toBeInstanceOf(Function) - }) - - it('should accept a string, and return the appropriate key', () => { - expect(objectFindKey(mockObject, 'c')).toBe('c') - }) - - it('should accept a predicate, and return the appropriate key', () => { - const predicate: ObjectPredicate = (key, value) => value === 3 - expect(objectFindKey(mockObject, predicate)).toBe('c') - }) - }) - - describe('objectFind', () => { - it('should expose a function', () => { - expect(objectFind).toBeDefined() - }) - - it('should accept a string (key) and return the appropriate value', () => { - expect(objectFind(mockObject, 'c')).toBe(3) - }) - - it('should accept a predicate, and return the appropriate key', () => { - const predicate: ObjectPredicate = key => key === 'c' - expect(objectFind(mockObject, predicate)).toBe(3) - }) - }) - - describe('objectFindEntry', () => { - it('should expose a function', () => { - expect(objectFindEntry).toBeDefined() - }) - - it('should accept a string (key) and return the appropriate value', () => { - expect(objectFindEntry(mockObject, 'c')).toStrictEqual(['c', 3]) - }) - - it('should accept a predicate, and return the appropriate key', () => { - const predicate: ObjectPredicate = key => key === 'c' - expect(objectFindEntry(mockObject, predicate)).toStrictEqual(['c', 3]) - }) - }) - - describe('objectHasMethod', () => { - it('should expose a function', () => { - expect(objectHasMethod).toBeDefined() - }) - - it('should accept a string (key) and correctly test for a matching method (true)', () => { - expect(objectHasMethod(mockObject, 'h')).toBe(true) - }) - - it('should accept a string (key) and correctly test for a matching method (false)', () => { - expect(objectHasMethod(mockObject, 'c')).toBe(false) - }) - }) - - describe('objectGetMethod', () => { - it('should expose a function', () => { - expect(objectGetMethod).toBeDefined() - }) - - it('should accept a string (key) and return a method if it exists (true)', () => { - expect(objectGetMethod(mockObject, 'h')).toBe(mockObject.h) - }) - - it('should accept a string (key) and return a method if it exists (false)', () => { - expect(objectGetMethod(mockObject, 'c')).toBeUndefined() - }) - }) - - describe('objectFilter', () => { - it('should expose a function', () => { - expect(objectFilter).toBeDefined() - }) - - it('should accept an object and a predicate, and return a filtered object', () => { - const predicate: ObjectPredicate = (key, value) => value < 4 - expect(objectFilter(mockObject, predicate)).toStrictEqual(mockPlainObject) - }) - }) - - describe('objectOnly', () => { - it('should expose a function', () => { - expect(objectOnly).toBeDefined() - }) - - it('should accept an object and an array, and return only the keys from the array', () => { - const keys = ['a', 'b'] - expect(objectOnly(mockPlainObject, keys)).toStrictEqual({a: 1, b: 2}) - }) - }) - - describe('objectExcept', () => { - it('should expose a function', () => { - expect(objectExcept).toBeDefined() - }) - - it('should accept an object and an array, and return everything except the keys from the array', () => { - const keys = ['a', 'b'] - expect(objectExcept(mockPlainObject, keys)).toStrictEqual({c: 3}) - }) - }) - - describe('objectFlatten', () => { - it('should expose a function', () => { - expect(objectFlatten).toBeDefined() - }) - - xit('should accept a nested object, and return an object with only a single level', () => { - expect(nestedObject).toStrictEqual({ - a: 1, - b: 2, - c: 3, - 'd.e': 4, - 'd.f': 5, - 'd.g': 6 - }) - }) - }) - - describe('objectClone', () => { - it('should expose a function', () => { - expect(objectClone).toBeDefined() - }) - - it('should make a full copy of a plain object', () => { - const clone = objectClone(mockPlainObject) - expect(clone).toStrictEqual(mockPlainObject) - clone.a = 12 - expect(clone).not.toStrictEqual(mockPlainObject) - }) - - it('should make a full copy of a functional object', () => { - const clone = objectClone(mockObject) - expect(clone).toStrictEqual(mockObject) - clone.a = 12 - expect(clone).not.toStrictEqual(mockObject) - }) - }) - - describe('objectCopy', () => { - it('should expose a function', () => { - expect(objectCopy).toBeDefined() - }) - - it('should make a full copy of a plain object', () => { - const clone = objectCopy(mockPlainObject) - expect(clone).toStrictEqual(mockPlainObject) - clone.a = 12 - expect(clone).not.toStrictEqual(mockPlainObject) - }) - - it('should make a partial copy of a functional object', () => { - const clone = objectCopy(mockObject) - expect(clone).toStrictEqual(nestedObject) - clone.a = 12 - expect(clone).not.toStrictEqual(nestedObject) - }) - }) - - describe('objectMerge', () => { - it('should expose a function', () => { - expect(objectMerge).toBeDefined() - }) - - it('should combine two plain objects', () => { - expect(objectMerge(mockPlainObject, mockSubObject)).toStrictEqual({ - ...mockPlainObject, - ...mockSubObject - }) - }) - - it('should combine a plain object and a functional object', () => { - expect(objectMerge(mockObject, mockExtraObject)).toStrictEqual({ - ...mockObject, - ...mockExtraObject - }) - }) - }) - - describe('objectMergeDeep', () => { - it('should expose a function', () => { - expect(objectMergeDeep).toBeDefined() - }) - - xit('objectMergeDeep should return expected output', () => { - expect(objectMergeDeep(mockObjectWithArray, mockObjectWithSameArray)).toStrictEqual({ - ...mockPlainObject, - l: [ - 11, - 12, - 13, - 14, - 15 - ] - }) - }) - }) - - describe('objectMethods', () => { - it('should expose a function', () => { - expect(objectMethods).toBeDefined() - }) - - it('should return the keys of an objects methods', () => { - expect(objectMethods(mockObject)).toStrictEqual(['h']) - }) - }) - - describe('objectPull', () => { - it('should expose a function', () => { - expect(objectPull).toBeDefined() - }) - - let pullableObject: any - let pulledKey: string - let pulledValue: number - - beforeEach(() => { - pullableObject = {...mockPlainObject} - pulledKey = 'a' - }) - - it('should accept an object and a key', () => { - expect(() => { - pulledValue = objectPull(pullableObject, pulledKey) - }).not.toThrow() - }) - - beforeEach(() => { - pulledValue = objectPull(pullableObject, pulledKey) - }) - - it('should return the value of the key', () => { - expect(pulledValue).toBe(1) - }) - - it('should remove the key from the object', () => { - expect(pullableObject).toStrictEqual({b: 2, c: 3}) - }) - }) - - describe('objectSort', () => { - it('should expose a function', () => { - expect(objectSort).toBeDefined() - }) - - let unsortedObject: any - - beforeEach(() => { - unsortedObject = { - c: 3, - b: 2, - a: 1 - } - }) - - it('unsorted object should not equal sorted object', () => { - expect(JSON.stringify(unsortedObject)).not.toEqual(JSON.stringify(mockPlainObject)) - }) - - it('should accept an object and sort it by it\'s keys', () => { - const sorted = objectSort(unsortedObject) - expect(JSON.stringify(sorted)).toEqual(JSON.stringify(mockPlainObject)) - }) - - it('should accept an object and sort it by a predicate', () => { - const sorted = objectSort(unsortedObject, ([, value_a]: [string, number], [, value_b]: [string, number]) => { - return value_a - value_b - }) - expect(JSON.stringify(sorted)).toEqual(JSON.stringify({ - a: 1, - b: 2, - c: 3 - })) - }) - }) -}) diff --git a/packages/utilities/docs/README.md b/packages/utilities/docs/README.md deleted file mode 100644 index 39506eab..00000000 --- a/packages/utilities/docs/README.md +++ /dev/null @@ -1,2748 +0,0 @@ -# @snickbit/utilities - -## Table of contents - -### Modules Interfaces - -- [isCallableOptions](interfaces/isCallableOptions.md) - -### Validation Interfaces - -- [AnyFunction](interfaces/AnyFunction.md) -- [AsyncFunction](interfaces/AsyncFunction.md) - -### Arrays Type Aliases - -- [ArrayPredicate](README.md#arraypredicate) - -### Generators Type Aliases - -- [CombinationOptions](README.md#combinationoptions) - -### Modules Type Aliases - -- [AdvancedVariableType](README.md#advancedvariabletype) -- [BasicVariableType](README.md#basicvariabletype) -- [CallableVariableType](README.md#callablevariabletype) -- [EmptyVariableType](README.md#emptyvariabletype) -- [JSONStringifyOptions](README.md#jsonstringifyoptions) -- [OverloadSchema](README.md#overloadschema) -- [PrimitiveVariableType](README.md#primitivevariabletype) -- [TFunction](README.md#tfunction) -- [TryWaitFunction](README.md#trywaitfunction) -- [VariableType](README.md#variabletype) - -### Objects Type Aliases - -- [IObject](README.md#iobject) -- [ObjectPredicate](README.md#objectpredicate) - -### Templating Type Aliases - -- [interpolateReplacements](README.md#interpolatereplacements) - -### Validation Type Aliases - -- [AnyClass](README.md#anyclass) -- [ArrayWithValues](README.md#arraywithvalues) -- [EmptyArray](README.md#emptyarray) -- [EmptyObject](README.md#emptyobject) -- [VariableTypeDefinition](README.md#variabletypedefinition) - -### Variables - -- [advanced](README.md#advanced) -- [all](README.md#all) -- [basic](README.md#basic) -- [callable](README.md#callable) -- [empty](README.md#empty) -- [primitive](README.md#primitive) -- [reserved](README.md#reserved) - -### Arrays Functions - -- [arrayDuplicates](README.md#arrayduplicates) -- [arrayMerge](README.md#arraymerge) -- [arrayMergeDeep](README.md#arraymergedeep) -- [arrayReject](README.md#arrayreject) -- [arrayRemove](README.md#arrayremove) -- [arrayShuffle](README.md#arrayshuffle) -- [arrayToKeyValue](README.md#arraytokeyvalue) -- [arrayToObject](README.md#arraytoobject) -- [arrayUnique](README.md#arrayunique) -- [arrayUniqueInsensitive](README.md#arrayuniqueinsensitive) -- [arrayWrap](README.md#arraywrap) -- [isSingle](README.md#issingle) - -### Functions Functions - -- [debounce](README.md#debounce) -- [debounceAsync](README.md#debounceasync) -- [debouncePromise](README.md#debouncepromise) -- [functionClone](README.md#functionclone) -- [overloadOptions](README.md#overloadoptions) -- [parseOptions](README.md#parseoptions) -- [promiseAll](README.md#promiseall) -- [tryWait](README.md#trywait) - -### Generators Functions - -- [combinations](README.md#combinations) -- [makeRandomSegment](README.md#makerandomsegment) -- [randomString](README.md#randomstring) -- [uuid](README.md#uuid) - -### Misc. Functions - -- [sleep](README.md#sleep) - -### Modules Functions - -- [plural](README.md#plural) -- [singular](README.md#singular) -- [toInt](README.md#toint) - -### Numbers Functions - -- [formatBytes](README.md#formatbytes) -- [formatCurrency](README.md#formatcurrency) -- [formatPercentage](README.md#formatpercentage) -- [maxDecimals](README.md#maxdecimals) -- [numberEven](README.md#numbereven) -- [numberOdd](README.md#numberodd) -- [numberPad](README.md#numberpad) -- [randomBetween](README.md#randombetween) - -### Objects Functions - -- [objectClone](README.md#objectclone) -- [objectCopy](README.md#objectcopy) -- [objectExcept](README.md#objectexcept) -- [objectFilter](README.md#objectfilter) -- [objectFind](README.md#objectfind) -- [objectFindEntry](README.md#objectfindentry) -- [objectFindKey](README.md#objectfindkey) -- [objectFlatten](README.md#objectflatten) -- [objectGetMethod](README.md#objectgetmethod) -- [objectHasMethod](README.md#objecthasmethod) -- [objectMerge](README.md#objectmerge) -- [objectMergeDeep](README.md#objectmergedeep) -- [objectMethods](README.md#objectmethods) -- [objectOnly](README.md#objectonly) -- [objectOverwrite](README.md#objectoverwrite) -- [objectPull](README.md#objectpull) -- [objectSort](README.md#objectsort) - -### Parsing Functions - -- [JSONParse](README.md#jsonparse) -- [JSONPrettify](README.md#jsonprettify) -- [JSONStringify](README.md#jsonstringify) -- [parse](README.md#parse) - -### Strings Functions - -- [camelCase](README.md#camelcase) -- [findFirstDiff](README.md#findfirstdiff) -- [initials](README.md#initials) -- [kebabCase](README.md#kebabcase) -- [limitString](README.md#limitstring) -- [limitWords](README.md#limitwords) -- [naturalSort](README.md#naturalsort) -- [padString](README.md#padstring) -- [safeVarName](README.md#safevarname) -- [slugify](README.md#slugify) -- [snakeCase](README.md#snakecase) -- [spaceCase](README.md#spacecase) -- [upperFirst](README.md#upperfirst) -- [wordWrap](README.md#wordwrap) - -### Templating Functions - -- [escapeRegExp](README.md#escaperegexp) -- [escapeReplacement](README.md#escapereplacement) -- [interpolate](README.md#interpolate) - -### Validation Functions - -- [isArray](README.md#isarray) -- [isAsyncFunction](README.md#isasyncfunction) -- [isAwaitable](README.md#isawaitable) -- [isBase64](README.md#isbase64) -- [isBoolean](README.md#isboolean) -- [isClass](README.md#isclass) -- [isDate](README.md#isdate) -- [isDefined](README.md#isdefined) -- [isEmpty](README.md#isempty) -- [isFunction](README.md#isfunction) -- [isNullDefined](README.md#isnulldefined) -- [isNumber](README.md#isnumber) -- [isObject](README.md#isobject) -- [isPrimitive](README.md#isprimitive) -- [isPromise](README.md#ispromise) -- [isSet](README.md#isset) -- [isString](README.md#isstring) -- [isType](README.md#istype) - -### Variables Functions - -- [clone](README.md#clone) -- [count](README.md#count) -- [isCallable](README.md#iscallable) -- [isJSONString](README.md#isjsonstring) -- [merge](README.md#merge) -- [mergeDeep](README.md#mergedeep) -- [typeOf](README.md#typeof) - -## Arrays Type Aliases - -### ArrayPredicate - -Ƭ **ArrayPredicate**: (`value`: `T`, `index?`: `number`, `array?`: `T`[]) => `T` - -#### Type declaration - -▸ <`T`\>(`value`, `index?`, `array?`): `T` - -##### Type parameters - -| Name | Type | -| :------ | :------ | -| `T` | `any` | - -##### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `T` | -| `index?` | `number` | -| `array?` | `T`[] | - -##### Returns - -`T` - -___ - -## Generators Type Aliases - -### CombinationOptions - -Ƭ **CombinationOptions**: `Record`<`string`, `any`[]\> - -___ - -## Modules Type Aliases - -### AdvancedVariableType - -Ƭ **AdvancedVariableType**: ``"array"`` \| ``"date"`` \| ``"object"`` \| ``"symbol"`` - -___ - -### BasicVariableType - -Ƭ **BasicVariableType**: ``"bigint"`` \| ``"boolean"`` \| ``"number"`` \| ``"string"`` - -___ - -### CallableVariableType - -Ƭ **CallableVariableType**: ``"asyncfunction"`` \| ``"function"`` \| ``"promise"`` - -___ - -### EmptyVariableType - -Ƭ **EmptyVariableType**: ``"null"`` \| ``"undefined"`` - -___ - -### JSONStringifyOptions - -Ƭ **JSONStringifyOptions**: `boolean` \| { `force?`: `boolean` ; `pretty?`: `boolean` \| `number` } - -___ - -### OverloadSchema - -Ƭ **OverloadSchema**: `Record`<`string`, [`VariableType`](README.md#variabletype)\> - -___ - -### PrimitiveVariableType - -Ƭ **PrimitiveVariableType**: [`BasicVariableType`](README.md#basicvariabletype) \| [`EmptyVariableType`](README.md#emptyvariabletype) - -___ - -### TFunction - -Ƭ **TFunction**<`F`\>: (...`args`: `Parameters`<`F`\>) => `ReturnType`<`F`\> - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `F` | extends [`AnyFunction`](interfaces/AnyFunction.md) = [`AnyFunction`](interfaces/AnyFunction.md) | - -#### Type declaration - -▸ (`...args`): `ReturnType`<`F`\> - -##### Parameters - -| Name | Type | -| :------ | :------ | -| `...args` | `Parameters`<`F`\> | - -##### Returns - -`ReturnType`<`F`\> - -___ - -### TryWaitFunction - -Ƭ **TryWaitFunction**: (...`args`: `any`[]) => `Promise`<`any`\> \| `any` - -#### Type declaration - -▸ (`...args`): `Promise`<`any`\> \| `any` - -##### Parameters - -| Name | Type | -| :------ | :------ | -| `...args` | `any`[] | - -##### Returns - -`Promise`<`any`\> \| `any` - -___ - -### VariableType - -Ƭ **VariableType**: [`AdvancedVariableType`](README.md#advancedvariabletype) \| [`CallableVariableType`](README.md#callablevariabletype) \| [`PrimitiveVariableType`](README.md#primitivevariabletype) - -___ - -## Objects Type Aliases - -### IObject - -Ƭ **IObject**: `Record`<`string` \| `symbol`, `any`\> - -___ - -### ObjectPredicate - -Ƭ **ObjectPredicate**<`T`, `K`, `O`\>: (`key`: `K`, `value?`: `T`, `object?`: `O`) => `unknown` - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `T` | `any` | -| `K` | `string` | -| `O` | extends `object` = `any` | - -#### Type declaration - -▸ (`key`, `value?`, `object?`): `unknown` - -##### Parameters - -| Name | Type | -| :------ | :------ | -| `key` | `K` | -| `value?` | `T` | -| `object?` | `O` | - -##### Returns - -`unknown` - -___ - -## Templating Type Aliases - -### interpolateReplacements - -Ƭ **interpolateReplacements**: `Record`<`string`, `any` \| `number` \| `string`\> - -___ - -## Validation Type Aliases - -### AnyClass - -Ƭ **AnyClass**: (...`args`: `any`[]) => [`AnyClass`](README.md#anyclass) - -#### Type declaration - -• **new AnyClass**(`...args`): [`AnyClass`](README.md#anyclass) - -##### Parameters - -| Name | Type | -| :------ | :------ | -| `...args` | `any`[] | - -##### Returns - -[`AnyClass`](README.md#anyclass) - -___ - -### ArrayWithValues - -Ƭ **ArrayWithValues**: [`any`, ...any] - -___ - -### EmptyArray - -Ƭ **EmptyArray**: `never`[] - -___ - -### EmptyObject - -Ƭ **EmptyObject**: `Record`<`any`, `never`\> - -___ - -### VariableTypeDefinition - -Ƭ **VariableTypeDefinition**: `Object` - -#### Type declaration - -| Name | Type | -| :------ | :------ | -| `name` | `string` | - -## Variables - -### advanced - -• `Const` **advanced**: [`AdvancedVariableType`](README.md#advancedvariabletype)[] - -___ - -### all - -• `Const` **all**: [`VariableType`](README.md#variabletype)[] - -___ - -### basic - -• `Const` **basic**: [`BasicVariableType`](README.md#basicvariabletype)[] - -___ - -### callable - -• `Const` **callable**: [`CallableVariableType`](README.md#callablevariabletype)[] - -___ - -### empty - -• `Const` **empty**: [`EmptyVariableType`](README.md#emptyvariabletype)[] - -___ - -### primitive - -• `Const` **primitive**: [`PrimitiveVariableType`](README.md#primitivevariabletype)[] - -___ - -### reserved - -• `Const` **reserved**: `string`[] - -## Arrays Functions - -### arrayDuplicates - -▸ **arrayDuplicates**<`T`\>(`array`, `predicate?`): `T`[] - -Return the duplicate values from an array - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `T` | `any` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `array` | `T`[] | -| `predicate?` | [`ArrayPredicate`](README.md#arraypredicate) | - -#### Returns - -`T`[] - -___ - -### arrayMerge - -▸ **arrayMerge**(`...arrs`): `any`[] - -Merge two or more arrays together - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `...arrs` | `any`[][] | - -#### Returns - -`any`[] - -___ - -### arrayMergeDeep - -▸ **arrayMergeDeep**(`...arrs`): `any`[] - -Merge two or more arrays together, recursing child values - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `...arrs` | `any`[][] | - -#### Returns - -`any`[] - -___ - -### arrayReject - -▸ **arrayReject**<`T`\>(`array`, `callback`): `T`[] - -Get the reverse of a filtered array - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `T` | `any` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `array` | `T`[] | -| `callback` | (...`args`: `any`[]) => `boolean` | - -#### Returns - -`T`[] - -___ - -### arrayRemove - -▸ **arrayRemove**<`T`\>(`array`, `value`): `T`[] - -Finds and returns an element from an array, removing it in the process - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `T` | `any` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `array` | `T`[] | -| `value` | `T` | - -#### Returns - -`T`[] - -___ - -### arrayShuffle - -▸ **arrayShuffle**<`T`\>(`array`): `T`[] - -Shuffles/randomizes an array - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `T` | `any` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `array` | `T`[] | - -#### Returns - -`T`[] - -___ - -### arrayToKeyValue - -▸ **arrayToKeyValue**<`TValue`\>(`array`): `Object` - -Turn an array of two value arrays into an object of key/value pairs - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `TValue` | `any` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `array` | [`string` \| `number` \| `symbol`, `TValue`][] | - -#### Returns - -`Object` - -___ - -### arrayToObject - -▸ **arrayToObject**<`T`, `V`\>(`array`, `key`, `value`): `Record`<`string`, `V`\> - -Convert an array to an object using the given key as the property - -**`Example`** - -```ts -arrayToObject([{id: 1, name: 'John'}, {id: 2, name: 'Jane'}], 'id', 'name') -// {1: 'John', 2: 'Jane'} -``` - -**`Example`** - -```ts -arrayToObject([{id: 1, name: 'John'}, {id: 2, name: 'Jane'}], 'name') -// {John: {id: 1, name: 'John'}, Jane: {id: 2, name: 'Jane'}} -``` - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `T` | `any` | -| `V` | `T` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `array` | `T`[] | -| `key` | keyof `T` | -| `value` | keyof `T` | - -#### Returns - -`Record`<`string`, `V`\> - -___ - -### arrayUnique - -▸ **arrayUnique**<`T`\>(`array`, `key?`): `T`[] - -Returns unique values from an array. Optionally pass a key when the array is an object array. - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `T` | `any` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `array` | `T`[] | -| `key?` | `string` | - -#### Returns - -`T`[] - -___ - -### arrayUniqueInsensitive - -▸ **arrayUniqueInsensitive**<`T`\>(`array`, `key?`): `T`[] - -Returns unique values from an array, ignoring case. Optionally pass a key when the array is an object array. - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `T` | `any` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `array` | `T`[] | -| `key?` | `string` | - -#### Returns - -`T`[] - -___ - -### arrayWrap - -▸ **arrayWrap**<`T`\>(`values`): `T`[] - -Wrap a variable in an array if it is not already an array - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `T` | `any` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `values` | `T` \| `T`[] | - -#### Returns - -`T`[] - -___ - -### isSingle - -▸ **isSingle**<`T`\>(`array`, `value?`): `boolean` - -Checks if the given array only contains a single value, optionally pass a value or predicate to check against - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `T` | `any` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `array` | `T`[] | -| `value?` | `T` | - -#### Returns - -`boolean` - -___ - -## Functions Functions - -### debounce - -▸ **debounce**<`F`\>(`fn`, `delay?`): (...`args`: `Parameters`<`F`\>) => `void` - -Debounce a function - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `F` | extends [`TFunction`](README.md#tfunction)<[`AnyFunction`](interfaces/AnyFunction.md)<`any`\>\> | - -#### Parameters - -| Name | Type | Default value | Description | -| :------ | :------ | :------ | :------ | -| `fn` | `F` | `undefined` | The function to debounce | -| `delay?` | `number` | `50` | The delay in milliseconds | - -#### Returns - -`fn` - -▸ (`...args`): `void` - -##### Parameters - -| Name | Type | -| :------ | :------ | -| `...args` | `Parameters`<`F`\> | - -##### Returns - -`void` - -___ - -### debounceAsync - -▸ **debounceAsync**<`F`\>(`fn`, `delay?`): (...`args`: `Parameters`<`F`\>) => `Promise`<`unknown`\> - -Debounce a function asynchronously, returning a promise - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `F` | extends [`TFunction`](README.md#tfunction)<[`AnyFunction`](interfaces/AnyFunction.md)<`any`\>\> | - -#### Parameters - -| Name | Type | Default value | Description | -| :------ | :------ | :------ | :------ | -| `fn` | `F` | `undefined` | The function to debounce | -| `delay?` | `number` | `50` | The delay in milliseconds | - -#### Returns - -`fn` - -▸ (`...args`): `Promise`<`unknown`\> - -##### Parameters - -| Name | Type | -| :------ | :------ | -| `...args` | `Parameters`<`F`\> | - -##### Returns - -`Promise`<`unknown`\> - -___ - -### debouncePromise - -▸ **debouncePromise**<`F`\>(`fn`, `delay?`): (...`args`: `Parameters`<`F`\>) => `Promise`<`unknown`\> - -Debounce a function asynchronously, returning a promise - -**`Alias`** - -debounceAsync - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `F` | extends [`TFunction`](README.md#tfunction)<[`AnyFunction`](interfaces/AnyFunction.md)<`any`\>\> | - -#### Parameters - -| Name | Type | Default value | -| :------ | :------ | :------ | -| `fn` | `F` | `undefined` | -| `delay?` | `number` | `50` | - -#### Returns - -`fn` - -▸ (`...args`): `Promise`<`unknown`\> - -##### Parameters - -| Name | Type | -| :------ | :------ | -| `...args` | `Parameters`<`F`\> | - -##### Returns - -`Promise`<`unknown`\> - -___ - -### functionClone - -▸ **functionClone**<`F`\>(`fn`): `F` - -Clone a function - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `F` | extends [`TFunction`](README.md#tfunction)<[`AnyFunction`](interfaces/AnyFunction.md)<`any`\>\> | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `fn` | `F` | - -#### Returns - -`F` - -___ - -### overloadOptions - -▸ **overloadOptions**(`options`, `schemas`): `object` - -Parses an array of arguments for an overloaded function into an object - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `options` | `any`[] | -| `schemas` | [`OverloadSchema`](README.md#overloadschema)[] | - -#### Returns - -`object` - -___ - -### parseOptions - -▸ **parseOptions**(`given`, `defaults`, `non_object_key?`): `any` \| `object` - -Parse options for a function - -**`Example`** - -```ts -const options = parseOptions(true, {param: 'default'}, 'my_param') -// {param: 'default', my_param: true} -``` - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `given` | `any` | The given options | -| `defaults` | [`IObject`](README.md#iobject) | The default options | -| `non_object_key?` | `string` | Optional key to use if the given options are not an object, will be added to the defaults object | - -#### Returns - -`any` \| `object` - -___ - -### promiseAll - -▸ **promiseAll**(`array`, `fn`): `Promise`<`Awaited`<`unknown`\>[]\> - -Send each item in an array to a function, await the results - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `array` | `any`[] | -| `fn` | (`value`: `any`, `index`: `number`, `array`: `any`[]) => `any` | - -#### Returns - -`Promise`<`Awaited`<`unknown`\>[]\> - -___ - -### tryWait - -▸ **tryWait**(`fn`, `...args`): `Promise`<`any`\> - -Catch an async function or promise and force it to resolve, returning undefined if it fails - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `fn` | [`TryWaitFunction`](README.md#trywaitfunction) | -| `...args` | `any`[][] | - -#### Returns - -`Promise`<`any`\> - -___ - -## Generators Functions - -### combinations - -▸ **combinations**(`options`): `any`[] - -Generate an array of all possible property values. -Provide an object with each property as a key and an array of possible values as the value. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `options` | [`CombinationOptions`](README.md#combinationoptions) | - -#### Returns - -`any`[] - -___ - -### makeRandomSegment - -▸ **makeRandomSegment**(): `string` - -Generate a random string between 8 and 14 characters long - -#### Returns - -`string` - -___ - -### randomString - -▸ **randomString**(`length?`): `string` - -Generate a random string - -#### Parameters - -| Name | Type | Default value | -| :------ | :------ | :------ | -| `length` | `number` | `10` | - -#### Returns - -`string` - -___ - -### uuid - -▸ **uuid**(`prefix?`): `string` - -Create a uuid with an optional prefix. Prefix will replace the first part of the uuid. - -#### Parameters - -| Name | Type | Default value | -| :------ | :------ | :------ | -| `prefix` | `string` | `''` | - -#### Returns - -`string` - -___ - -## Misc. Functions - -### sleep - -▸ **sleep**(`ms`): `Promise`<`unknown`\> - -sleep for a given time - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `ms` | `number` | - -#### Returns - -`Promise`<`unknown`\> - -___ - -## Modules Functions - -### plural - -▸ **plural**(`word`, `count?`): `any` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `word` | `string` | -| `count?` | `number` | - -#### Returns - -`any` - -▸ **plural**(`word`, `pluralized`, `count?`): `any` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `word` | `string` | -| `pluralized` | `string` | -| `count?` | `number` | - -#### Returns - -`any` - -___ - -### singular - -▸ **singular**(`word`, `count?`): `any` - -Get the singular version of a word - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `word` | `string` | -| `count?` | `number` | - -#### Returns - -`any` - -▸ **singular**(`word`, `singularized`, `count?`): `any` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `word` | `string` | -| `singularized` | `string` | -| `count?` | `number` | - -#### Returns - -`any` - -___ - -### toInt - -▸ **toInt**(`value`): `number` - -Convert a string to a number, but less strict than Number() or parseInt(). -Will remove all non-numeric characters, and also round the number if it has decimals. - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `string` \| `number` | - -#### Returns - -`number` - -___ - -## Numbers Functions - -### formatBytes - -▸ **formatBytes**(`bytes`, `decimals?`): `string` - -Format a number in bytes. - -#### Parameters - -| Name | Type | Default value | Description | -| :------ | :------ | :------ | :------ | -| `bytes` | `number` | `undefined` | The number of bytes. | -| `decimals?` | `number` | `2` | The number of decimals. | - -#### Returns - -`string` - -___ - -### formatCurrency - -▸ **formatCurrency**(`amount`, `symbol?`, `decimals?`): `string` - -Format a number as currency. - -#### Parameters - -| Name | Type | Default value | Description | -| :------ | :------ | :------ | :------ | -| `amount` | `number` | `undefined` | The number to format. | -| `symbol?` | `string` | `'$'` | The currency symbol. | -| `decimals?` | `number` | `2` | The number of decimals. | - -#### Returns - -`string` - -___ - -### formatPercentage - -▸ **formatPercentage**(`amount`, `decimals?`): `string` - -Format a number as a percentage. - -#### Parameters - -| Name | Type | Default value | Description | -| :------ | :------ | :------ | :------ | -| `amount` | `number` | `undefined` | The number to format. | -| `decimals?` | `number` | `2` | The number of decimals to show. | - -#### Returns - -`string` - -___ - -### maxDecimals - -▸ **maxDecimals**(`value`, `max_places?`): `number` - -limit the amount of decimals to the given number - -#### Parameters - -| Name | Type | Default value | Description | -| :------ | :------ | :------ | :------ | -| `value` | `number` | `undefined` | the number to limit | -| `max_places?` | `number` | `2` | the maximum number of decimals | - -#### Returns - -`number` - -___ - -### numberEven - -▸ **numberEven**(`num`, `subtract?`): `number` - -Force a number to be even - -#### Parameters - -| Name | Type | Default value | Description | -| :------ | :------ | :------ | :------ | -| `num` | `number` | `undefined` | the number to force even | -| `subtract?` | `boolean` | `false` | whether to subtract 1 from the number if it is odd | - -#### Returns - -`number` - -___ - -### numberOdd - -▸ **numberOdd**(`num`, `subtract?`): `number` - -Force a number to be odd - -#### Parameters - -| Name | Type | Default value | Description | -| :------ | :------ | :------ | :------ | -| `num` | `number` | `undefined` | the number to force odd | -| `subtract?` | `boolean` | `false` | whether to subtract 1 from the number if it is even | - -#### Returns - -`number` - -___ - -### numberPad - -▸ **numberPad**(`num`, `length?`): `string` - -Pad a number with zeros. - -#### Parameters - -| Name | Type | Default value | Description | -| :------ | :------ | :------ | :------ | -| `num` | `string` \| `number` | `undefined` | The number to pad. | -| `length?` | `number` | `2` | The length of the resulting string. | - -#### Returns - -`string` - -___ - -### randomBetween - -▸ **randomBetween**(`min`, `max`, `inclusive?`): `number` - -Generate a random number between min and max. - -#### Parameters - -| Name | Type | Default value | Description | -| :------ | :------ | :------ | :------ | -| `min` | `number` | `undefined` | The minimum number. | -| `max` | `number` | `undefined` | The maximum number. | -| `inclusive?` | `boolean` | `true` | Whether to include the max value in the range. | - -#### Returns - -`number` - -___ - -## Objects Functions - -### objectClone - -▸ **objectClone**<`I`\>(`...objects`): `I` - -Deep clones an object - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `I` | extends `object` = [`IObject`](README.md#iobject) | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `...objects` | [`IObject`](README.md#iobject)[] | - -#### Returns - -`I` - -___ - -### objectCopy - -▸ **objectCopy**<`I`\>(`object`, `force?`): `I` - -Copy object as JSON (uses JSON.parse/JSON.stringify but won't throw any errors) - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `I` | extends `object` = [`IObject`](README.md#iobject) | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `object` | `I` | -| `force?` | `boolean` | - -#### Returns - -`I` - -___ - -### objectExcept - -▸ **objectExcept**<`I`\>(`object`, `excluded`): `I` - -Returns a new object without the excluded properties. - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `I` | extends `object` = [`IObject`](README.md#iobject) | - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `object` | `I` | the object to filter | -| `excluded` | `string`[] | the allowed properties | - -#### Returns - -`I` - -___ - -### objectFilter - -▸ **objectFilter**<`I`, `R`\>(`object`, `predicate?`): `R` - -Filter an object by a given predicate - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `I` | extends `object` = [`IObject`](README.md#iobject) | -| `R` | `Partial`<`I`\> | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `object` | `I` | -| `predicate` | [`ObjectPredicate`](README.md#objectpredicate)<`any`, `string`, `any`\> | - -#### Returns - -`R` - -___ - -### objectFind - -▸ **objectFind**<`T`, `I`\>(`object`, `predicate?`): `T` \| `undefined` - -Finds an object property's value that matches the given predicate - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `T` | `any` | -| `I` | extends `object` = [`IObject`](README.md#iobject) | - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `object` | `I` | | -| `predicate?` | `string` \| `symbol` \| [`ObjectPredicate`](README.md#objectpredicate)<`any`, `string`, `any`\> | A string or function that returns a boolean | - -#### Returns - -`T` \| `undefined` - -___ - -### objectFindEntry - -▸ **objectFindEntry**<`T`, `I`\>(`object`, `predicate`): [`string`, `T`] \| `undefined` - -Finds an object property's entry [key, value] that matches the given predicate - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `T` | `any` | -| `I` | extends `object` = [`IObject`](README.md#iobject) | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `object` | `I` | -| `predicate` | `string` \| `symbol` \| [`ObjectPredicate`](README.md#objectpredicate)<`any`, `string`, `any`\> | - -#### Returns - -[`string`, `T`] \| `undefined` - -___ - -### objectFindKey - -▸ **objectFindKey**<`I`\>(`object`, `predicate`): `string` \| `symbol` \| `undefined` - -Finds an object property's name that matches the given predicate - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `I` | extends `object` = [`IObject`](README.md#iobject) | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `object` | `I` | -| `predicate` | `string` \| `symbol` \| [`ObjectPredicate`](README.md#objectpredicate)<`any`, `string`, `any`\> | - -#### Returns - -`string` \| `symbol` \| `undefined` - -___ - -### objectFlatten - -▸ **objectFlatten**<`I`\>(`object`, `prefix?`): `I` - -Flattens an object into a single level using dot notation for nested properties. - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `I` | extends `object` = [`IObject`](README.md#iobject) | - -#### Parameters - -| Name | Type | Default value | -| :------ | :------ | :------ | -| `object` | `I` | `undefined` | -| `prefix` | `string` | `''` | - -#### Returns - -`I` - -___ - -### objectGetMethod - -▸ **objectGetMethod**<`T`, `I`\>(`object`, `method`, `strict?`): `T` \| `undefined` - -Checks if an object has a method with the given name, and returns the method - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `T` | `any` | -| `I` | extends `object` = [`IObject`](README.md#iobject) | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `object` | `I` | -| `method` | `string` | -| `strict?` | `boolean` | - -#### Returns - -`T` \| `undefined` - -___ - -### objectHasMethod - -▸ **objectHasMethod**<`I`\>(`object`, `method`, `strict?`): `boolean` - -Checks if an object has a method with the given name - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `I` | extends `object` = [`IObject`](README.md#iobject) | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `object` | `I` | -| `method` | `string` | -| `strict?` | `boolean` | - -#### Returns - -`boolean` - -___ - -### objectMerge - -▸ **objectMerge**<`I`\>(`...objects`): `I` - -Merge two or more objects together - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `I` | extends `object` = [`IObject`](README.md#iobject) | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `...objects` | [`IObject`](README.md#iobject)[] | - -#### Returns - -`I` - -___ - -### objectMergeDeep - -▸ **objectMergeDeep**<`I`\>(`...objects`): `I` - -Merge two or more objects together, recursing child values - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `I` | extends `object` = [`IObject`](README.md#iobject) | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `...objects` | [`IObject`](README.md#iobject)[] | - -#### Returns - -`I` - -___ - -### objectMethods - -▸ **objectMethods**<`I`\>(`object`): `string`[] - -Returns an array of the given object's available method names - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `I` | extends `object` = [`IObject`](README.md#iobject) | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `object` | `I` | - -#### Returns - -`string`[] - -___ - -### objectOnly - -▸ **objectOnly**<`I`\>(`object`, `allowed`): `I` - -Returns a new object with only the allowed properties. - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `I` | extends `object` = [`IObject`](README.md#iobject) | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `object` | `I` | -| `allowed` | `string`[] | - -#### Returns - -`I` - -___ - -### objectOverwrite - -▸ **objectOverwrite**<`I`\>(`object`, `...objects`): `I` - -Shallow merges multiple objects together, overwriting earlier objects' values with later objects' values. -Null and undefined values from later objects are ignored, and not copied over. - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `I` | extends `object` = [`IObject`](README.md#iobject) | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `object` | `I` | -| `...objects` | [`IObject`](README.md#iobject)[] | - -#### Returns - -`I` - -___ - -### objectPull - -▸ **objectPull**<`I`\>(`object`, `key`): `any` - -Remove a property from an object and return the value - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `I` | extends `object` = [`IObject`](README.md#iobject) | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `object` | `I` | -| `key` | `string` | - -#### Returns - -`any` - -___ - -### objectSort - -▸ **objectSort**<`I`\>(`object`): `I` - -Sort an object by it's keys - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `I` | extends `object` = [`IObject`](README.md#iobject) | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `object` | `I` | - -#### Returns - -`I` - -▸ **objectSort**<`I`\>(`object`, `sortFunction`): `I` - -Sort an object by a predicate - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `I` | extends `object` = [`IObject`](README.md#iobject) | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `object` | `I` | -| `sortFunction` | (`a`: [`string`, `unknown`], `b`: [`string`, `unknown`]) => `number` | - -#### Returns - -`I` - -___ - -## Parsing Functions - -### JSONParse - -▸ **JSONParse**<`T`\>(`text`, `strict?`): `T` \| `undefined` - -Parse a string into JSON - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `T` | `any` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `text` | `string` | -| `strict?` | `boolean` | - -#### Returns - -`T` \| `undefined` - -___ - -### JSONPrettify - -▸ **JSONPrettify**(`data`, `spacer?`): `string` - -Pretty print a JSON string - -#### Parameters - -| Name | Type | Default value | -| :------ | :------ | :------ | -| `data` | `any` | `undefined` | -| `spacer` | `number` | `2` | - -#### Returns - -`string` - -___ - -### JSONStringify - -▸ **JSONStringify**<`T`\>(`data`, `options?`): `string` - -Parse a variable into a JSON string - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `T` | `any` | - -#### Parameters - -| Name | Type | Default value | -| :------ | :------ | :------ | -| `data` | `T` | `undefined` | -| `options` | [`JSONStringifyOptions`](README.md#jsonstringifyoptions) | `false` | - -#### Returns - -`string` - -___ - -### parse - -▸ **parse**(`value`): `any` - -Parse a string into it's primitive type if possible. If not, return the original variable. - -**`Example`** - -```ts -'123' => 123 | '123.456' => 123.456 | 'true' => true | 'false' => false | 'null' => null | 'undefined' => undefined -``` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `any` | - -#### Returns - -`any` - -___ - -## Strings Functions - -### camelCase - -▸ **camelCase**(`text`): `string` - -Convert a string to camelCase - -**`See`** - -https://www.npmjs.com/package/just-camel-case - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `text` | `string` | - -#### Returns - -`string` - -___ - -### findFirstDiff - -▸ **findFirstDiff**(`first`, `second`): `number` - -Return the index of the first difference between two strings - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `first` | `any` | -| `second` | `any` | - -#### Returns - -`number` - --1 if no difference - -___ - -### initials - -▸ **initials**(`text`): `string` - -Convert a string to initials - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `text` | `string` | - -#### Returns - -`string` - -___ - -### kebabCase - -▸ **kebabCase**(`text`): `string` - -Convert a string to kebab-case - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `text` | `string` | The string to convert | - -#### Returns - -`string` - -___ - -### limitString - -▸ **limitString**(`text`, `limit?`, `suffix?`): `string` - -Limit a string to a certain length - -#### Parameters - -| Name | Type | Default value | -| :------ | :------ | :------ | -| `text` | `string` | `undefined` | -| `limit` | `number` | `100` | -| `suffix` | `string` | `'...'` | - -#### Returns - -`string` - -___ - -### limitWords - -▸ **limitWords**(`text`, `limit?`, `suffix?`): `string` - -Limit a string to a certain amount of words - -#### Parameters - -| Name | Type | Default value | -| :------ | :------ | :------ | -| `text` | `string` | `undefined` | -| `limit` | `number` | `100` | -| `suffix` | `string` | `'...'` | - -#### Returns - -`string` - -___ - -### naturalSort - -▸ **naturalSort**(`str1`, `str2`, `caseSensitive?`): `number` - -Compare two strings using a "natural order" algorithm - -#### Parameters - -| Name | Type | Default value | -| :------ | :------ | :------ | -| `str1` | `string` | `undefined` | -| `str2` | `string` | `undefined` | -| `caseSensitive?` | `boolean` | `false` | - -#### Returns - -`number` - -___ - -### padString - -▸ **padString**(`text`, `padding?`, `character?`): `string` - -Pad a string on both sides with the given character and length - -#### Parameters - -| Name | Type | Default value | -| :------ | :------ | :------ | -| `text` | `string` | `undefined` | -| `padding` | `number` | `2` | -| `character` | `string` | `' '` | - -#### Returns - -`string` - -___ - -### safeVarName - -▸ **safeVarName**(`text`, `replacer?`): `string` - -Create a safe javascript variable name from a string - -#### Parameters - -| Name | Type | Default value | -| :------ | :------ | :------ | -| `text` | `string` | `undefined` | -| `replacer` | `string` | `''` | - -#### Returns - -`string` - -___ - -### slugify - -▸ **slugify**(`text`, `replace?`): `string` - -Create slug from string - -#### Parameters - -| Name | Type | Default value | -| :------ | :------ | :------ | -| `text` | `string` | `undefined` | -| `replace` | `string` | `'-'` | - -#### Returns - -`string` - -___ - -### snakeCase - -▸ **snakeCase**(`text`): `string` - -Convert a string to snake_case - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `text` | `string` | - -#### Returns - -`string` - -___ - -### spaceCase - -▸ **spaceCase**(`text`): `string` - -Convert a string to space-case - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `text` | `string` | - -#### Returns - -`string` - -___ - -### upperFirst - -▸ **upperFirst**(`text`, `normalize?`): `string` - -Capitalize the first character of a string - -#### Parameters - -| Name | Type | Default value | Description | -| :------ | :------ | :------ | :------ | -| `text` | `string` | `undefined` | The text to capitalize | -| `normalize?` | `boolean` | `false` | Convert the rest of the string to lowercase | - -#### Returns - -`string` - -___ - -### wordWrap - -▸ **wordWrap**(`text`, `characters`, `padding?`): `string` - -Wrap a string at a certain character length. Optionally add padding to each line - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `text` | `string` | The text to wrap | -| `characters` | `number` | Number of characters to wrap at | -| `padding?` | `number` | Number of characters to pad each line with | - -#### Returns - -`string` - -___ - -## Templating Functions - -### escapeRegExp - -▸ **escapeRegExp**(`text`): `string` - -escape regexp - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `text` | `string` | - -#### Returns - -`string` - -___ - -### escapeReplacement - -▸ **escapeReplacement**(`text`): `string` - -escape regexp replacement string - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `text` | `string` | - -#### Returns - -`string` - -___ - -### interpolate - -▸ **interpolate**(`text`, `replacements`): `string` - -interpolate string with data from object using `{{key}}` syntax or `${key}` syntax - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `text` | `string` | -| `replacements` | [`interpolateReplacements`](README.md#interpolatereplacements) | - -#### Returns - -`string` - -___ - -## Validation Functions - -### isArray - -▸ **isArray**(`value`): value is [any, ...any[]] - -Checks if variable is an array and is not empty - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `any` | - -#### Returns - -value is [any, ...any[]] - -___ - -### isAsyncFunction - -▸ **isAsyncFunction**<`T`\>(`value`): value is AsyncFunction - -Check if a variable is an async function - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `T` | `any` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `any` | - -#### Returns - -value is AsyncFunction - -___ - -### isAwaitable - -▸ **isAwaitable**<`T`\>(`value`): value is AsyncFunction \| Promise - -Check if a variable can be used with await (a Promise or AsyncFunction) - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `T` | `any` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `any` | - -#### Returns - -value is AsyncFunction \| Promise - -___ - -### isBase64 - -▸ **isBase64**(`content`): `boolean` - -Check if a variable is a Base64 string - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `content` | `string` | - -#### Returns - -`boolean` - -___ - -### isBoolean - -▸ **isBoolean**(`value`): value is boolean - -Check if a variable is a boolean - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `any` | - -#### Returns - -value is boolean - -___ - -### isClass - -▸ **isClass**(`value`): value is AnyClass - -Check if a variable is a class - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `any` | - -#### Returns - -value is AnyClass - -___ - -### isDate - -▸ **isDate**(`value`): value is Date - -Check if a variable is a valid date - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `any` | - -#### Returns - -value is Date - -___ - -### isDefined - -▸ **isDefined**(`value`): value is undefined - -Check if a value is undefined - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `any` | - -#### Returns - -value is undefined - -___ - -### isEmpty - -▸ **isEmpty**(`value`): value is EmptyObject - -Check if a value is empty - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `any` | - -#### Returns - -value is EmptyObject - -▸ **isEmpty**(`value`): value is "" - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `string` | - -#### Returns - -value is "" - -▸ **isEmpty**(`value`): value is EmptyArray - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `any`[] | - -#### Returns - -value is EmptyArray - -___ - -### isFunction - -▸ **isFunction**(`value`, `strict?`): value is AnyFunction - -Check if a variable is a function - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `any` | -| `strict?` | ``false`` | - -#### Returns - -value is AnyFunction - -▸ **isFunction**(`value`, `strict`): value is Function - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `any` | -| `strict` | ``true`` | - -#### Returns - -value is Function - -___ - -### isNullDefined - -▸ **isNullDefined**(`value`): value is null - -Check if a value is null or undefined - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `any` | - -#### Returns - -value is null - -___ - -### isNumber - -▸ **isNumber**(`value`): value is number - -Check if a variable is a number - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `any` | - -#### Returns - -value is number - -___ - -### isObject - -▸ **isObject**(`value`, `strict?`): value is Record - -Check if a variable is an object and is not null or undefined - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `any` | -| `strict?` | ``true`` | - -#### Returns - -value is Record - -▸ **isObject**(`value`, `strict`): value is AnyFunction \| Record \| [any, ...any[]] \| Date - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `any` | -| `strict` | ``false`` | - -#### Returns - -value is AnyFunction \| Record \| [any, ...any[]] \| Date - -___ - -### isPrimitive - -▸ **isPrimitive**(`value`, `includeNullUndefined`): value is BasicVariableType - -Check if a variable is a primitive type. i.e. string, boolean, number, or bigint - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `any` | -| `includeNullUndefined` | ``true`` | - -#### Returns - -value is BasicVariableType - -▸ **isPrimitive**(`value`, `includeNullUndefined?`): value is PrimitiveVariableType - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `any` | -| `includeNullUndefined?` | ``false`` | - -#### Returns - -value is PrimitiveVariableType - -___ - -### isPromise - -▸ **isPromise**<`T`\>(`value`): value is Promise - -Check if a variable is a promise - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `T` | `any` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `any` | - -#### Returns - -value is Promise - -___ - -### isSet - -▸ **isSet**<`T`\>(`value`): value is Set - -Check if a variable is a Set - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `T` | `any` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `any` | - -#### Returns - -value is Set - -___ - -### isString - -▸ **isString**(`value`): value is string - -Check if a variable is a string - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `any` | - -#### Returns - -value is string - -___ - -### isType - -▸ **isType**(`value`, `type`): value is VariableType - -Check if a variable is the given type - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `any` | -| `type` | `string` \| [`VariableTypeDefinition`](README.md#variabletypedefinition) | - -#### Returns - -value is VariableType - -___ - -## Variables Functions - -### clone - -▸ **clone**(`value`): `any` - -Clone a variable - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `any` | - -#### Returns - -`any` - -___ - -### count - -▸ **count**(`value`, `strict?`): `number` - -Count the number of keys in an object \ -Count the number of entries in an array \ -Count the number of values in a Set \ -Get the length of a string - -#### Parameters - -| Name | Type | Default value | -| :------ | :------ | :------ | -| `value` | `any` | `undefined` | -| `strict` | `boolean` | `true` | - -#### Returns - -`number` - -___ - -### isCallable - -▸ **isCallable**(`value`, `options?`): `boolean` - -Check if a variable is callable - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `any` | -| `options?` | `boolean` \| `Partial`<[`isCallableOptions`](interfaces/isCallableOptions.md)\> | - -#### Returns - -`boolean` - -___ - -### isJSONString - -▸ **isJSONString**(`value`, `returnValue?`): `any` - -Check if a variable is a JSON string - -#### Parameters - -| Name | Type | Default value | -| :------ | :------ | :------ | -| `value` | `any` | `undefined` | -| `returnValue` | `boolean` | `false` | - -#### Returns - -`any` - -___ - -### merge - -▸ **merge**(`...values`): `any`[] \| [`IObject`](README.md#iobject) - -Merge two or more variables together - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `...values` | `any`[] \| [`IObject`](README.md#iobject)[] | - -#### Returns - -`any`[] \| [`IObject`](README.md#iobject) - -___ - -### mergeDeep - -▸ **mergeDeep**(`...values`): `any`[] \| [`IObject`](README.md#iobject) - -Merge two or more variables together, recursing child values - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `...values` | `any`[] \| [`IObject`](README.md#iobject)[] | - -#### Returns - -`any`[] \| [`IObject`](README.md#iobject) - -___ - -### typeOf - -▸ **typeOf**(`value`): [`VariableType`](README.md#variabletype) - -Return a variable's type - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `value` | `any` | - -#### Returns - -[`VariableType`](README.md#variabletype) diff --git a/packages/utilities/docs/interfaces/AnyFunction.md b/packages/utilities/docs/interfaces/AnyFunction.md deleted file mode 100644 index f6bb5ba4..00000000 --- a/packages/utilities/docs/interfaces/AnyFunction.md +++ /dev/null @@ -1,23 +0,0 @@ -# Interface: AnyFunction - -## Type parameters - -| Name | Type | -| :------ | :------ | -| `T` | `any` | - -## Callable - -### AnyFunction - -▸ **AnyFunction**(`...args`): `T` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `...args` | `any`[] | - -#### Returns - -`T` diff --git a/packages/utilities/docs/interfaces/AsyncFunction.md b/packages/utilities/docs/interfaces/AsyncFunction.md deleted file mode 100644 index a392b0c5..00000000 --- a/packages/utilities/docs/interfaces/AsyncFunction.md +++ /dev/null @@ -1,23 +0,0 @@ -# Interface: AsyncFunction - -## Type parameters - -| Name | Type | -| :------ | :------ | -| `T` | `any` | - -## Callable - -### AsyncFunction - -▸ **AsyncFunction**(`...args`): `Promise`<`T`\> - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `...args` | `any`[] | - -#### Returns - -`Promise`<`T`\> diff --git a/packages/utilities/docs/interfaces/isCallableOptions.md b/packages/utilities/docs/interfaces/isCallableOptions.md deleted file mode 100644 index e065655a..00000000 --- a/packages/utilities/docs/interfaces/isCallableOptions.md +++ /dev/null @@ -1,20 +0,0 @@ -# Interface: isCallableOptions - -## Table of contents - -### Properties - -- [async](isCallableOptions.md#async) -- [strict](isCallableOptions.md#strict) - -## Properties - -### async - -• **async**: ``false`` - -___ - -### strict - -• **strict**: ``false`` diff --git a/packages/utilities/indexer.config.json b/packages/utilities/indexer.config.json deleted file mode 100644 index 6a3fa668..00000000 --- a/packages/utilities/indexer.config.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "source": "src/**/*.ts", - "output": "src/index.ts" -} diff --git a/packages/utilities/package.json b/packages/utilities/package.json deleted file mode 100644 index 610f2f88..00000000 --- a/packages/utilities/package.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "name": "@snickbit/utilities", - "version": "3.11.3", - "description": "A collection of simple JavaScript helpers", - "license": "MIT", - "exports": { - "require": "./dist/index.js", - "import": "./dist/index.mjs", - "types": "./dist/index.d.ts" - }, - "main": "./dist/index.js", - "module": "./dist/index.mjs", - "types": "./dist/index.d.ts", - "files": [ - "dist" - ], - "scripts": { - "build": "tsup --minify", - "check": "pnpm -w run lint && pnpm run typecheck", - "dev": "tsup --watch", - "docs": "typedoc src/index.ts", - "index": "indexer", - "release": "semantic-release", - "typecheck": "tsc --noEmit" - }, - "release": { - "extends": [ - "@snickbit/semantic-release" - ] - }, - "jest": { - "preset": "ts-jest", - "testEnvironment": "node" - }, - "dependencies": { - "@lukeed/uuid": "^2.0.1", - "@snickbit/plural": "1.0.18", - "just-camel-case": "6.2.0" - }, - "devDependencies": { - "@snickbit/indexer": "2.9.1", - "@types/jest": "29.5.3", - "jest": "29.6.1", - "ts-jest": "29.1.1", - "tsup": "7.1.0", - "typedoc": "0.24.8", - "typedoc-plugin-markdown": "3.15.3", - "typescript": "5.1.6" - }, - "engines": { - "node": ">= 14.17" - } -} diff --git a/packages/utilities/src/arrays.ts b/packages/utilities/src/arrays.ts deleted file mode 100644 index 0bc95f75..00000000 --- a/packages/utilities/src/arrays.ts +++ /dev/null @@ -1,171 +0,0 @@ -import {isFunction} from './validations' -import {mergeDeep, typeOf} from './variables' - -/** @category Arrays */ -export type ArrayPredicate = (value: T, index?: number, array?: T[]) => T - -/** - * Checks if the given array only contains a single value, optionally pass a value or predicate to check against - * @category Arrays - */ -export function isSingle(array: T[], value?: T): boolean -export function isSingle(array: T[], predicate?: ArrayPredicate): boolean { - if (array.length !== 1) { - return false - } - - return !predicate || (isFunction(predicate) ? !!(predicate as ArrayPredicate)(array[0], 0, array) : array.includes(predicate)) -} - -/** - * Returns unique values from an array. Optionally pass a key when the array is an object array. - * @category Arrays - */ -export function arrayUnique(array: T[], key?: string): T[] { - return [...new Set(array.map(item => key ? item[key] : item))] -} - -/** - * Returns unique values from an array, ignoring case. Optionally pass a key when the array is an object array. - * @category Arrays - */ -export function arrayUniqueInsensitive(array: T[], key?: string): T[] { - return [ - ...new Set(array.map(item => { - let selectedItem = item - if (key) { - const itemWithLowercaseKeys = Object.fromEntries(Object.entries(item).map(([key, value]) => [key.toLowerCase(), value])) - selectedItem = itemWithLowercaseKeys[String(key).toLowerCase()] - } - return typeof selectedItem === 'string' ? selectedItem.toLowerCase() as T : selectedItem - })) - ] -} - -/** - * Convert an array to an object using the given key as the property - * @category Arrays - * - * @example - * arrayToObject([{id: 1, name: 'John'}, {id: 2, name: 'Jane'}], 'id', 'name') - * // {1: 'John', 2: 'Jane'} - * @example - * arrayToObject([{id: 1, name: 'John'}, {id: 2, name: 'Jane'}], 'name') - * // {John: {id: 1, name: 'John'}, Jane: {id: 2, name: 'Jane'}} - */ -export const arrayToObject = (array: T[], key: keyof T, value: keyof T): Record => { - return Object.fromEntries(array.map(item => [ - // eslint-disable-next-line array-element-newline - item[key], // set new object key - value ? item[value] : item // set new object value - ])) -} - -/** - * Wrap a variable in an array if it is not already an array - * @category Arrays - */ -export const arrayWrap = (values: T | T[]): T[] => Array.isArray(values) ? values : [values] - -/** - * Return the duplicate values from an array - * @category Arrays - */ -export function arrayDuplicates(array: T[], predicate?: ArrayPredicate): T[] { - const unique: T[] = [], - duplicates: T[] = [] - predicate ||= (value => value) - for (const item of array) { - const processedItem = predicate(item) - if (unique.includes(processedItem)) { - duplicates.push(item) - } else { - unique.push(processedItem) - } - } - return duplicates -} - -/** - * Finds and returns an element from an array, removing it in the process - * @category Arrays - */ -export function arrayRemove(array: T[], value: T): T[] { - if (!array || !value) { - return array - } - const index = array.indexOf(value) - if (index >= 0) { - array.splice(index, 1) - } - return array -} - -/** - * Shuffles/randomizes an array - * @category Arrays - */ -export function arrayShuffle(array: T[]): T[] { - let currentIndex = array.length, - randomIndex - - // While there remain elements to shuffle. - while (currentIndex !== 0) { - // Pick a remaining element. - randomIndex = Math.floor(Math.random() * currentIndex) - currentIndex-- - // And swap it with the current element. - [array[currentIndex], array[randomIndex]] = [array[randomIndex], array[currentIndex]] - } - - return array -} - -/** - * Merge two or more arrays together - * @category Arrays - */ -export function arrayMerge(...arrs: any[][]): any[] { - let toReturn: any[] = [] - for (const array of arrs) { - if (array && typeOf(array) === 'array') { - toReturn = [...toReturn, ...array] - } - } - return toReturn -} - -/** - * Merge two or more arrays together, recursing child values - * @category Arrays - */ -export function arrayMergeDeep(...arrs: any[][]): any[] { - const toReturn: any[] = [] - for (const array of arrs) { - for (const [key, value] of array.entries()) { - toReturn[key] = mergeDeep(toReturn[key], value) - } - } - return toReturn -} - -/** - * Get the reverse of a filtered array - * @category Arrays - */ -export function arrayReject(array: T[], callback: (...args: any[]) => boolean): T[] { - return array.filter((...args: any[]) => !callback.apply(array, args)) -} - -/** - * Turn an array of two value arrays into an object of key/value pairs - * @category Arrays - */ -export function arrayToKeyValue(array: [number | string | symbol, TValue][]): {[key: string]: TValue} { - const result: {[key: string]: any} = {} - for (const [key, value] of array) { - result[String(key)] = value - } - return result -} - diff --git a/packages/utilities/src/data/reserved.ts b/packages/utilities/src/data/reserved.ts deleted file mode 100644 index 7c1c144b..00000000 --- a/packages/utilities/src/data/reserved.ts +++ /dev/null @@ -1,53 +0,0 @@ -export const reserved = [ - 'await', - 'break', - 'case', - 'catch', - 'class', - 'const', - 'continue', - 'debugger', - 'default', - 'delete', - 'do', - 'else', - 'enum', - 'export', - 'extends', - 'false', - 'finally', - 'for', - 'function', - 'if', - 'implements', - 'import', - 'in', - 'Infinity', - 'instanceof', - 'interface', - 'let', - 'NaN', - 'new', - 'null', - 'package', - 'private', - 'protected', - 'public', - 'return', - 'static', - 'super', - 'switch', - 'this', - 'throw', - 'true', - 'try', - 'typeof', - 'undefined', - 'var', - 'void', - 'while', - 'with', - 'yield' -] - -export default reserved diff --git a/packages/utilities/src/data/variable-types.ts b/packages/utilities/src/data/variable-types.ts deleted file mode 100644 index 42a0ee64..00000000 --- a/packages/utilities/src/data/variable-types.ts +++ /dev/null @@ -1,44 +0,0 @@ -export type BasicVariableType = 'bigint' | 'boolean' | 'number' | 'string' -export const basic: BasicVariableType[] = [ - 'bigint', - 'boolean', - 'number', - 'string' -] - -export type EmptyVariableType = 'null' | 'undefined' -export const empty: EmptyVariableType[] = ['undefined', 'null'] - -export type AdvancedVariableType = 'array' | 'date' | 'object' | 'symbol' -export const advanced: AdvancedVariableType[] = [ - 'array', - 'object', - 'symbol', - 'date' -] - -export type CallableVariableType = 'asyncfunction' | 'function' | 'promise' -export const callable: CallableVariableType[] = [ - 'promise', - 'asyncfunction', - 'function' -] - -export type PrimitiveVariableType = BasicVariableType | EmptyVariableType -export const primitive: PrimitiveVariableType[] = [...basic, ...empty] - -export type VariableType = AdvancedVariableType | CallableVariableType | PrimitiveVariableType -export const all: VariableType[] = [ - ...primitive, - ...advanced, - ...callable -] - -export default { - all, - basic, - empty, - primitive, - advanced, - callable -} diff --git a/packages/utilities/src/functions.ts b/packages/utilities/src/functions.ts deleted file mode 100644 index c75b3b69..00000000 --- a/packages/utilities/src/functions.ts +++ /dev/null @@ -1,171 +0,0 @@ -import {arrayUnique} from './arrays' -import {VariableType} from './data/variable-types' -import {IObject} from './objects' -import {AnyFunction, isArray, isObject, isType} from './validations' - -/** - * Parse options for a function - * @category Functions - * - * @param {IObject | any} given - The given options - * @param {IObject} defaults - The default options - * @param {string} [non_object_key] - Optional key to use if the given options are not an object, will be added to the defaults object - * - * @example - * const options = parseOptions(true, {param: 'default'}, 'my_param') - * // {param: 'default', my_param: true} - */ -export function parseOptions(given: IObject | any, defaults: IObject, non_object_key?: string): any | object { - if (!isObject(defaults)) { - throw new TypeError('defaults must be an object') - } - - // if given is undefined, just return the defaults - if (given === undefined) { - return {...defaults} - } - - // if given is not an object, assign it to the non_object_key - if (!isObject(given) && non_object_key) { - given = {[non_object_key]: given} - } - - // merge the given options with the defaults - for (const key of arrayUnique([...Object.keys(defaults), ...Object.keys(given)])) { - if (given[key] === undefined) { - given[key] = defaults[key] - } - } - - return given -} - -export type TFunction = (...args: Parameters) => ReturnType - -export type TryWaitFunction = (...args: any[]) => Promise | any - -/** - * Catch an async function or promise and force it to resolve, returning undefined if it fails - * @category Functions - */ -export function tryWait(fn: TryWaitFunction, ...args: any[][]): Promise { - /* eslint no-async-promise-executor: off */ - return new Promise(async resolve => { - try { - const result = await fn(...args) - resolve(result) - } catch { - resolve() - } - }) -} - -/** - * Clone a function - * @category Functions - */ -export function functionClone(fn: F): F { - return function(...args: any[]): any { - return fn.apply(this, ...args) - } as F -} - -/** - * Send each item in an array to a function, await the results - * @category Functions - */ -export async function promiseAll(array: any[], fn: (value: any, index: number, array: any[]) => any): Promise[]> { - if (!isArray(array)) { - return [] - } - return Promise.all(array.map((...args) => fn(...args))) -} - -export type OverloadSchema = Record - -/** - * Parses an array of arguments for an overloaded function into an object - * @category Functions - */ -export function overloadOptions(options: any[], schemas: OverloadSchema[]): object { - let matches - - // check for schemas that have the same length and same first type - matches = schemas.filter(schema => Object.keys(schema).length === options.length && isType(options[0], Object.values(schema)[0])) - - if (matches.length !== 1) { - // check for type matches only - matches = matches.length ? matches : [...schemas] - for (const [index, option] of options.entries()) { - matches = matches.filter((schema: OverloadSchema) => isType(option, Object.values(schema)[index])) - if (matches.length === 1) { - break - } - } - } - - // get first match with same first type - if (matches.length !== 1) { - matches = [schemas.find(schema => isType(options[0], Object.values(schema)[0]))] - } - - const schema = matches[0] || schemas[0] || {} - const results: IObject = {} - for (const name in schema) { - results[name] = options.shift() - } - - return results -} - -/** - * Debounce a function - * @category Functions - * @param {TFunction} fn - The function to debounce - * @param {number} [delay=50] - The delay in milliseconds - */ -export function debounce(fn: F, delay = 50) { - let timeout: ReturnType - return function(...args: Parameters) { - clearTimeout(timeout) - timeout = setTimeout(() => { - fn.apply(this, args) - }, delay) - } -} - -/** - * Debounce a function asynchronously, returning a promise - * @category Functions - * @param {TFunction} fn - The function to debounce - * @param {number} [delay=50] - The delay in milliseconds - */ -export function debounceAsync(fn: F, delay = 50) { - let timeoutId: ReturnType - const pending: {resolve(value: unknown): void; reject(reason?: any): void}[] = [] - return (...args: Parameters) => new Promise((resolve, reject) => { - clearTimeout(timeoutId) - timeoutId = setTimeout(() => { - const currentPending = [...pending] - pending.length = 0 - Promise.resolve(fn.apply(this, args)).then(data => { - for (const {resolve} of currentPending) { - resolve(data) - } - }, - error => { - for (const {reject} of currentPending) { - reject(error) - } - }) - }, delay) - pending.push({resolve, reject}) - }) -} - -/** - * Debounce a function asynchronously, returning a promise - * @alias debounceAsync - * @category Functions - */ -export const debouncePromise = debounceAsync diff --git a/packages/utilities/src/generators.ts b/packages/utilities/src/generators.ts deleted file mode 100644 index cc0bb174..00000000 --- a/packages/utilities/src/generators.ts +++ /dev/null @@ -1,63 +0,0 @@ -import {v4 as secureUuid} from '@lukeed/uuid/secure' -import {IObject} from './objects' -import {clone} from './variables' - -/** - * Create a uuid with an optional prefix. Prefix will replace the first part of the uuid. - * @category Generators - */ -export function uuid(prefix = ''): string { - return `${prefix}${secureUuid().slice(prefix.length)}` -} - -/** - * Generate a random string - * @category Generators - */ -export function randomString(length = 10): string { - let text = '' - while (text.length < length) { - text += makeRandomSegment() - } - return text.slice(0, Math.max(0, length)) -} - -/** - * Generate a random string between 8 and 14 characters long - * @category Generators - */ -export function makeRandomSegment(): string { - return Math.random().toString(36).slice(2, 16) -} - -/** @category Generators */ -export type CombinationOptions = Record - -/** - * Generate an array of all possible property values. - * Provide an object with each property as a key and an array of possible values as the value. - * @category Generators - */ -export function combinations(options: CombinationOptions): any[] { - return combinationsLoop(options) -} - -function combinationsLoop(options: CombinationOptions, optionIndex = 0, current: IObject = {}): any[] { - const allKeys = Object.keys(options) - const optionKey = allKeys[optionIndex] - const values = options[optionKey] - const results: any[] = [] - - for (const value of values) { - current[optionKey] = value - - if (optionIndex + 1 < allKeys.length) { - results.push(...combinationsLoop(options, optionIndex + 1, current)) - } else { - const res = clone(current) - results.push(res) - } - } - - return results -} diff --git a/packages/utilities/src/index.ts b/packages/utilities/src/index.ts deleted file mode 100644 index 9a6c88da..00000000 --- a/packages/utilities/src/index.ts +++ /dev/null @@ -1,15 +0,0 @@ -// WARNING: This file is automatically generated. Any changes will be lost the next time the generator is run. - -export * from './arrays' -export * from './data/reserved' -export * from './data/variable-types' -export * from './functions' -export * from './generators' -export * from './numbers' -export * from './objects' -export * from './parsing' -export * from './sleep' -export * from './strings' -export * from './templating' -export * from './validations' -export * from './variables' diff --git a/packages/utilities/src/numbers.ts b/packages/utilities/src/numbers.ts deleted file mode 100644 index 4ada36f3..00000000 --- a/packages/utilities/src/numbers.ts +++ /dev/null @@ -1,108 +0,0 @@ -/** - * Pad a number with zeros. - * @param num - The number to pad. - * @param [length=2] - The length of the resulting string. - * @category Numbers - */ -export function numberPad(num: number | string, length = 2): string { - num = String(num) - const pad_length = length - num.length - return pad_length > 0 ? '0'.repeat(pad_length) + num : num -} - -/** - * Format a number in bytes. - * @param bytes - The number of bytes. - * @param [decimals=2] - The number of decimals. - * @category Numbers - */ -export function formatBytes(bytes: number, decimals = 2): string { - if (bytes === 0) { - return '0 Bytes' - } - - const k = 1000 - const dm = decimals < 0 ? 0 : decimals - const sizes = [ - 'Bytes', - 'KB', - 'MB', - 'GB', - 'TB', - 'PB', - 'EB', - 'ZB', - 'YB' - ] - - const index = Math.floor(Math.log(bytes) / Math.log(k)) - - return `${Number.parseFloat((bytes / Math.pow(k, index)).toFixed(dm))} ${sizes[index]}` -} - -/** - * Format a number as currency. - * @param amount - The number to format. - * @param [symbol='$'] - The currency symbol. - * @param [decimals=2] - The number of decimals. - * @category Numbers - */ -export const formatCurrency = (amount: number, symbol = '$', decimals = 2) => symbol + Number.parseFloat(String(amount || '0')).toFixed(decimals) - -/** - * Format a number as a percentage. - * @param amount - The number to format. - * @param [decimals=2] - The number of decimals to show. - * @category Numbers - */ -export const formatPercentage = (amount: number, decimals = 2) => `${Number.parseFloat(String(amount || '0')).toFixed(decimals)}%` - -/** - * limit the amount of decimals to the given number - * @param value - the number to limit - * @param [max_places=2] - the maximum number of decimals - * @category Numbers - */ -export const maxDecimals = (value: number, max_places = 2) => +Number.parseFloat(String(value)).toFixed(max_places) - -/** - * Generate a random number between min and max. - * @param min - The minimum number. - * @param max - The maximum number. - * @param [inclusive=true] - Whether to include the max value in the range. - * @category Numbers - */ -export function randomBetween(min: number, max: number, inclusive = true): number { - min = Math.ceil(min) - max = Math.floor(max) - return Math.floor(Math.random() * (max - min + (inclusive ? 1 : 0)) + min) -} - -/** - * Force a number to be even - * @param {number} num - the number to force even - * @param {boolean} [subtract=false] - whether to subtract 1 from the number if it is odd - * @category Numbers - */ -export function numberEven(num: number, subtract = false): number { - return num % 2 === 0 ? num : num + (subtract ? -1 : 1) -} - -/** - * Force a number to be odd - * @param {number} num - the number to force odd - * @param {boolean} [subtract=false] - whether to subtract 1 from the number if it is even - * @category Numbers - */ -export function numberOdd(num: number, subtract = false): number { - return num % 2 === 1 ? num : num + (subtract ? -1 : 1) -} - -/** - * Convert a string to a number, but less strict than Number() or parseInt(). - * Will remove all non-numeric characters, and also round the number if it has decimals. - * @param {string | number} value - */ -export function toInt(value: number | string): number { - return Math.round(Number(String(value).replaceAll(/[^\d.-]+/g, '').trim() || 0)) -} diff --git a/packages/utilities/src/objects.ts b/packages/utilities/src/objects.ts deleted file mode 100644 index 4754ee06..00000000 --- a/packages/utilities/src/objects.ts +++ /dev/null @@ -1,273 +0,0 @@ -import {JSONParse, JSONStringify} from './parsing' -import {isFunction, isObject} from './validations' -import {mergeDeep, typeOf} from './variables' - -/** @category Objects */ -export type IObject = Record - -/** @category Objects */ -export type ObjectPredicate = (key: K, value?: T, object?: O) => unknown - -/** - * Finds an object property's name that matches the given predicate - * @category Objects - */ -export function objectFindKey(object: I, predicate: ObjectPredicate | string | symbol): string | symbol | undefined { - const results = objectFindEntry(object, predicate) - return results ? results[0] : undefined -} - -/** - * Finds an object property's value that matches the given predicate - * @param {object} object - * @param {string|function} [predicate] - A string or function that returns a boolean - * @returns {any} - * @category Objects - */ -export function objectFind(object: I, predicate: ObjectPredicate | string | symbol): T | undefined { - const results = objectFindEntry(object, predicate) - return results ? results[1] : undefined -} - -/** - * Finds an object property's entry [key, value] that matches the given predicate - * @category Objects - */ -export function objectFindEntry(object: I, predicate: ObjectPredicate | string | symbol): [string, T] | undefined { - if (!isFunction(predicate)) { - const value = predicate - predicate = (v: any) => v === value - } - - return Object.entries(object).find(([k, v]) => (predicate as ObjectPredicate)(k, v, object)) -} - -/** - * Checks if an object has a method with the given name - * @category Objects - */ -export function objectHasMethod(object: I, method: string, strict?: boolean): boolean { - return !!objectGetMethod(object, method, strict) -} - -/** - * Checks if an object has a method with the given name, and returns the method - * @category Objects - */ -export function objectGetMethod(object: I, method: string, strict?: boolean): T | undefined { - if (!object || !isObject(object)) { - return undefined - } - if (typeOf(method) !== 'string') { - throw new Error(`Method name must be a string, got ${typeOf(method)}`) - } - return objectMethods(object) - .map(method_name => ({original: method_name, lower: method_name.toLowerCase()})) - .filter(method_def => strict ? method_def.original === method : method_def.lower === method.toLowerCase()) - .map(method_def => object[method_def.original]) - .pop() -} - -/** - * Filter an object by a given predicate - * @category Objects - */ -export function objectFilter< - I extends object = IObject, - R = Partial - >(object: I, predicate: ObjectPredicate = () => true): R { - if (!isObject(object)) { - throw new TypeError('objectFilter: object must be an object') - } - if (!isFunction(predicate)) { - throw new TypeError('objectFilter: predicate must be a function') - } - - const toReturn = {} as R - - for (const key of Object.keys(object)) { - const value = object[key] - if ((predicate as ObjectPredicate)(key, value, object)) { - toReturn[key] = value - } - } - - return toReturn -} - -/** - * Returns a new object with only the allowed properties. - * @category Objects - */ -export function objectOnly(object: I, allowed: string[]): I { - const toReturn = {} as I - - for (const key of allowed) { - if (object[key]) { - toReturn[key] = object[key] - } - } - - return toReturn -} - -/** - * Returns a new object without the excluded properties. - * @param object - the object to filter - * @param {array} excluded - the allowed properties - * @returns {object} - * @category Objects - */ -export function objectExcept(object: I, excluded: string[]): I { - const toReturn = {} as I - - for (const key of Object.keys(object)) { - if (!excluded.includes(key)) { - toReturn[key] = object[key] - } - } - - return toReturn -} - -/** - * Flattens an object into a single level using dot notation for nested properties. - * @category Objects - */ -export function objectFlatten(object: I, prefix = ''): I { - const toReturn = {} as I - for (const [key, value] of Object.entries(object)) { - if (isObject(value)) { - Object.assign(toReturn, objectFlatten(value, `${prefix}${key}.`)) - } else { - toReturn[`${prefix}${key}`] = value - } - } - return toReturn -} - -/** - * Deep clones an object - * @category Objects - */ -export function objectClone(...objects: IObject[]): I { - const toReturn = {} as I - for (const object of objects) { - for (const [key, value] of Object.entries(object)) { - toReturn[key] = typeOf(value) === 'object' ? objectClone(value) : value - } - } - return toReturn -} - -/** - * Copy object as JSON (uses JSON.parse/JSON.stringify but won't throw any errors) - * @category Objects - */ -export function objectCopy(object: I, force?: boolean): I { - const stringified = JSONStringify(object, force) || '{}' - return JSONParse(stringified) as I -} - -/** - * Merge two or more objects together - * @category Objects - */ -export function objectMerge(...objects: IObject[]): I { - let toReturn = {} as I - for (const object of objects) { - if (object && typeOf(object) === 'object') { - toReturn = {...toReturn, ...object} - } - } - return toReturn -} - -/** - * Merge two or more objects together, recursing child values - * @category Objects - */ -export function objectMergeDeep(...objects: IObject[]): I { - const toReturn = {} as I - const keys: string[] = [] - for (const object of objects) { - keys.push(...Object.keys(object)) - } - - for (const object of objects) { - for (const key of keys) { - toReturn[key] = mergeDeep(toReturn[key], object[key]) - } - } - return toReturn -} - -/** - * Returns an array of the given object's available method names - * @category Objects - */ -export function objectMethods(object: I): string[] { - const properties = new Set() - let currentObject = object - do { - Object.getOwnPropertyNames(currentObject).map(item => properties.add(item)) - // eslint-disable-next-line no-cond-assign - } while (currentObject = Object.getPrototypeOf(currentObject)) - - const keys: string[] = [...properties.keys()].map(item => item.toString()) - - const rawObjectProperties = new Set(Object.getOwnPropertyNames(Object.prototype).filter(property => Object.prototype[property] && isFunction(Object.prototype[property]))) - - return keys.filter((item: string) => object[item] && isFunction(object[item]) && !rawObjectProperties.has(item)) -} - -/** - * Remove a property from an object and return the value - * @category Objects - */ -export function objectPull(object: I, key: string): any { - if (!object || !key || !isObject(object) || !(key in object)) { - return undefined - } - const value = object[key] - delete object[key] - return value -} - -/** - * Sort an object by it's keys - * @category Objects - */ -export function objectSort(object: I): I - -/** - * Sort an object by a predicate - * @category Objects - */ -export function objectSort(object: I, sortFunction: (a: [string, unknown], b: [string, unknown]) => number): I -export function objectSort(object: I, sortFunction?: (a: [string, unknown], b: [string, unknown]) => number): I { - const toReturn = {} as I - const keys = sortFunction - ? Object.entries(object).sort((a, b) => sortFunction(a, b)).map(item => item[0]) - : Object.keys(object).sort() - for (const key of keys) { - toReturn[key] = object[key] - } - return toReturn -} - -/** - * Shallow merges multiple objects together, overwriting earlier objects' values with later objects' values. - * Null and undefined values from later objects are ignored, and not copied over. - * @category Objects - */ -export function objectOverwrite(object: I, ...objects: IObject[]): I { - for (const objectToMerge of objects) { - for (const [key, value] of Object.entries(objectToMerge)) { - if (value !== undefined && value !== null) { - object[key] = value - } - } - } - return object -} diff --git a/packages/utilities/src/parsing.ts b/packages/utilities/src/parsing.ts deleted file mode 100644 index 09ef3187..00000000 --- a/packages/utilities/src/parsing.ts +++ /dev/null @@ -1,100 +0,0 @@ -import {parseOptions} from './functions' -import {isDefined} from './validations' -import {isJSONString} from './variables' - -/** - * Parse a string into it's primitive type if possible. If not, return the original variable. - * - * @example '123' => 123 | '123.456' => 123.456 | 'true' => true | 'false' => false | 'null' => null | 'undefined' => undefined - * @category Parsing - */ -export function parse(value: any): any { - if (typeof value !== 'string') { - return value - } - - switch (value) { - case 'undefined': { - return undefined - } - case 'null': { - return null - } - case 'NaN': { - return Number.NaN - } - case 'Infinity': { - return Number.POSITIVE_INFINITY - } - case 'true': { - return true - } - case 'false': { - return false - } - } - - if (isJSONString(value)) { - return JSONParse(value) - } - - const num = Number.parseFloat(value) - if (!Number.isNaN(num) && Number.isFinite(num)) { - if (value.toLowerCase().indexOf('0x') === 0) { - return Number.parseInt(value, 16) - } - return num - } - - return value -} - -/** - * Parse a string into JSON - * @category Parsing - */ -export function JSONParse(text: string, strict?: boolean): T | undefined { - if (!isDefined(text)) { - return undefined - } - - let json: T | undefined - try { - json = JSON.parse(text) - } catch (error) { - if (strict) { - throw error - } - } - return json -} - -export type JSONStringifyOptions = boolean | {force?: boolean; pretty?: boolean | number} - -/** - * Parse a variable into a JSON string - * @category Parsing - */ -export function JSONStringify(data: T, options: JSONStringifyOptions = false): string { - if (!isDefined(data)) { - return '' - } - if (typeof options === 'boolean') { - options = {force: options} - } - - const parsedOptions = parseOptions(options, {force: false, pretty: undefined}) - parsedOptions.pretty = parsedOptions.pretty === true ? 2 : parsedOptions.pretty - - try { - return JSON.stringify(data, null, parsedOptions.pretty) - } catch { - return '' - } -} - -/** - * Pretty print a JSON string - * @category Parsing - */ -export const JSONPrettify = (data: any, spacer = 2): string => JSONStringify(data, {pretty: spacer}) diff --git a/packages/utilities/src/sleep.ts b/packages/utilities/src/sleep.ts deleted file mode 100644 index 885fa24b..00000000 --- a/packages/utilities/src/sleep.ts +++ /dev/null @@ -1,5 +0,0 @@ -/** - * sleep for a given time - * @category Misc. - */ -export const sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms)) diff --git a/packages/utilities/src/strings.ts b/packages/utilities/src/strings.ts deleted file mode 100644 index 6b189598..00000000 --- a/packages/utilities/src/strings.ts +++ /dev/null @@ -1,212 +0,0 @@ -/* eslint-disable unicorn/prefer-export-from */ - -import {default as justCamelCase} from 'just-camel-case' -import reserved from './data/reserved' - -/** - * @internal - * @category Strings - */ -export const capital_plus_lower = /[A-Z\u00C0-Ý][a-zà-ÿ]/g - -/** - * @internal - * @category Strings - */ -export const capitals = /[A-Z\u00C0-Ý]+/g - -/** - * Convert a string to snake_case - * @category Strings - */ -export const snakeCase = (text: string) => slugify(text, '_') - -/** - * Convert a string to kebab-case - * - * @param text - The string to convert - * @returns {string} - * @category Strings - */ -export const kebabCase = (text: string) => slugify(text) - -/** - * Convert a string to camelCase - * - * @see https://www.npmjs.com/package/just-camel-case - * @category Strings - */ -export const camelCase = (text: string): string => justCamelCase(text) - -/** - * Convert a string to initials - * @category Strings - */ -export const initials = (text: string): string => text - .split(/[^A-Za-z]/) - .filter(Boolean) - .map(word => word[0].toUpperCase()) - .join('') - -/** - * Limit a string to a certain length - * @category Strings - */ -export const limitString = (text: string, limit = 100, suffix = '...'): string => text.length > limit ? text.slice(0, Math.max(0, limit)) + suffix : text - -/** - * Limit a string to a certain amount of words - * @category Strings - */ -export function limitWords(text: string, limit = 100, suffix = '...'): string { - const words = text.split(/\s+/) - return words.length > limit ? words.slice(0, limit).join(' ') + suffix : text -} - -/** - * Pad a string on both sides with the given character and length - * @category Strings - */ -export function padString(text: string, padding = 2, character = ' '): string { - const pad = !Number.isNaN(padding) && padding > 0 ? character.repeat(padding) : '' - return pad + text + pad -} - -/** - * Create a safe javascript variable name from a string - * @category Strings - */ -export function safeVarName(text: string, replacer = ''): string { - // check that replacer itself is valid - replacer = replacer.split(/[\W_]/).join('') - - text = text.split(/[\W_]/) // Split on non-word characters - .join(replacer) // Join words with replacer - .replaceAll(new RegExp(replacer + replacer, 'g'), replacer) // Replace double replacer with single replacer - - // If the first character is a number or if full text is a reserved word, add a replacer in front - if (/^\d/.test(text) || reserved.includes(text)) { - // if replacer is empty, use an underscore - text = (replacer || '_') + text - } - - return text -} - -/** - * Convert a string to space-case - * @category Strings - */ -export function spaceCase(text: string): string { - // force the variable to be a string - text = String(text) - // treat cap + lower as the start of new word - text = text.replaceAll(capital_plus_lower, match => ` ${match[0].toLowerCase() || match[0]}${match[1]}`) // the match is one cap followed by one non-cap - // treat all remaining capitals as words - text = text.replaceAll(capitals, match => ` ${match.toLowerCase()}`) // match is a series of caps - return text.trim() // trim leading and trailing spaces -} - -/** - * Create slug from string - * @category Strings - */ -export function slugify(text: string, replace = '-'): string { - return spaceCase(text) - .toLowerCase() - .replaceAll(/\s+/g, replace) // Replace spaces with - - .replaceAll(/[^\w-]+/g, replace) // Remove all non-word chars - .replaceAll(new RegExp(`${replace}${replace}+`, 'g'), replace) // Replace - with a single - - .replace(new RegExp(`^${replace}+`), '') // Trim - from start of text - .replace(new RegExp(`${replace}+$`), '') // Trim - from end of text -} - -/** - * Return the index of the first difference between two strings - * @param first - * @param second - * @returns {number} -1 if no difference - * @category Strings - */ -export function findFirstDiff(first, second): number { - let index = 0 - if (first === second) { - return -1 - } - while (first[index] === second[index]) { - index++ - } - return index -} - -/** - * Get the plural version of a word - * @category Strings - * @see @snickbit/plural - * @deprecated Use @snickbit/plural instead, this will be removed in the next major version - */ -export {plural} from '@snickbit/plural' - -/** - * Get the singular version of a word - * @category Strings - * @see @snickbit/plural - * @deprecated Use @snickbit/plural instead, this will be removed in the next major version - */ -export {singular} from '@snickbit/plural' - -/** - * Wrap a string at a certain character length. Optionally add padding to each line - * @param {string} text - The text to wrap - * @param {number} characters - Number of characters to wrap at - * @param {number} [padding] - Number of characters to pad each line with - * @category Strings - */ -export function wordWrap(text: string, characters: number, padding?: number): string { - const lines: string[] = [] - const words = text.split(/\s+/) - let line = '' - for (const word of words) { - if (line.length + word.length + 1 > characters) { - lines.push(line) - line = '' - } - line += `${word} ` - } - if (line) { - lines.push(line) - } - return lines.map(line => padString(line, padding)).join('\n') -} - -/** - * Compare two strings using a "natural order" algorithm - * @param {string} str1 - * @param {string} str2 - * @param {boolean} [caseSensitive=false] - * @category Strings - */ -export function naturalSort(str1: string, str2: string, caseSensitive = false): number { - const a = caseSensitive ? str1 : str1.toLowerCase() - const b = caseSensitive ? str2 : str2.toLowerCase() - - const collator = new Intl.Collator(undefined, { - numeric: true, - sensitivity: 'base' - }) - - return collator.compare(a, b) -} - -/** - * Capitalize the first character of a string - * @param {string} text - The text to capitalize - * @param {boolean} [normalize=false] - Convert the rest of the string to lowercase - * @category Strings - */ -export function upperFirst(text: string, normalize = false) { - if (normalize) { - text = String(text).toLowerCase() - } - return String(text).charAt(0).toUpperCase() + text.slice(1) -} diff --git a/packages/utilities/src/templating.ts b/packages/utilities/src/templating.ts deleted file mode 100644 index 55e463d8..00000000 --- a/packages/utilities/src/templating.ts +++ /dev/null @@ -1,38 +0,0 @@ -import {objectFlatten} from './objects' - -/** - * escape regexp - * @param text - * @returns {any} - * @category Templating - */ -export const escapeRegExp = (text: string) => String(text).replaceAll(/[$()*+.?[\\\]^{|}]/g, '\\$&') - -/** - * escape regexp replacement string - * @param text - * @returns {any} - * @category Templating - */ -export const escapeReplacement = (text: string) => String(text).replaceAll('$', '$$$$') - -/** @category Templating */ -export type interpolateReplacements = Record - -/** - * interpolate string with data from object using `{{key}}` syntax or `${key}` syntax - * @category Templating - */ -export function interpolate(text: string, replacements: interpolateReplacements): string { - // eslint-disable-next-line prefer-const - for (let [from, to] of Object.entries(objectFlatten(replacements))) { - to = escapeReplacement(to) - if (!from.startsWith('{{')) { - text = text.replaceAll(new RegExp(escapeRegExp(`{{${from}}}`), 'g'), to) - } - if (!from.startsWith('${')) { - text = text.replaceAll(new RegExp(escapeRegExp(`\${${from}}`), 'g'), to) - } - } - return text -} diff --git a/packages/utilities/src/validations.ts b/packages/utilities/src/validations.ts deleted file mode 100644 index c5c5d9f9..00000000 --- a/packages/utilities/src/validations.ts +++ /dev/null @@ -1,166 +0,0 @@ -import {typeOf} from './variables' -import variableTypes, {BasicVariableType, PrimitiveVariableType, VariableType} from './data/variable-types' - -/** @category Validation */ -export type VariableTypeDefinition = {name: string} - -/** @category Validation */ -export type EmptyObject = Record - -/** @category Validation */ -export type EmptyArray = Array - -/** @category Validation */ -export type ArrayWithValues = [any, ...any] - -/** @category Validation */ -export interface AnyFunction { - (...args: any[]): T -} - -/** @category Validation */ -export interface AsyncFunction { - (...args: any[]): Promise -} - -/** @category Validation */ -export type AnyClass = { - new (...args: any[]): AnyClass -} - -/** - * Check if a value is undefined - * @category Validation - */ -export function isDefined(value: any): value is undefined { - return value !== undefined && value !== undefined -} - -/** - * Check if a value is empty - * @category Validation - */ -export function isEmpty(value: any): value is EmptyObject | null | undefined -export function isEmpty(value: string): value is '' -export function isEmpty(value: any[]): value is EmptyArray -export function isEmpty(value: any): value is EmptyArray | EmptyObject | '' | null | undefined { - return isNullDefined(value) || value === '' || Array.isArray(value) && !value.length || isObject(value) && !Object.keys(value).length -} - -/** - * Check if a value is null or undefined - * @category Validation - */ -export const isNullDefined = (value: any): value is null | undefined => value === null || value === undefined - -/** - * Check if a variable is a promise - * @category Validation - */ -export const isPromise = (value: any): value is Promise => value && typeof value.then === 'function' && typeof value.catch === 'function' - -/** - * Check if a variable is an async function - * @category Validation - */ -export const isAsyncFunction = (value: any): value is AsyncFunction => typeof value === 'function' && value.constructor.name === 'AsyncFunction' - -/** - * Check if a variable can be used with await (a Promise or AsyncFunction) - * @category Validation - */ -export const isAwaitable = (value: any): value is AsyncFunction | Promise => isAsyncFunction(value) || isPromise(value) - -/** - * Check if a variable is a primitive type. i.e. string, boolean, number, or bigint - * @category Validation - */ -export function isPrimitive(value: any, includeNullUndefined: true): value is BasicVariableType -export function isPrimitive(value: any, includeNullUndefined?: false): value is PrimitiveVariableType -export function isPrimitive(value: any, includeNullUndefined?: boolean): value is BasicVariableType | PrimitiveVariableType { - return includeNullUndefined ? variableTypes.primitive.includes(typeOf(value)) : variableTypes.basic.includes(typeOf(value)) -} - -/** - * Check if a variable is an object and is not null or undefined - * @category Validation - */ -export function isObject(value: any, strict?: true): value is Record -export function isObject(value: any, strict: false): value is AnyFunction | ArrayWithValues | Date | Record -export function isObject(value: any, strict = true): value is Record { - return value && typeof value === 'object' && (!strict || !(isArray(value) || isFunction(value) || isDate(value))) -} - -/** - * Checks if variable is an array and is not empty - * @category Validation - */ -export const isArray = (value: any): value is ArrayWithValues => Array.isArray(value) && !!value.length - -/** - * Check if a variable is a string - * @category Validation - */ -export const isString = (value: any): value is string => typeof value === 'string' - -/** - * Check if a variable is a number - * @category Validation - */ -export const isNumber = (value: any): value is number => !Number.isNaN(Number.parseInt(value)) - -/** - * Check if a variable is a boolean - * @category Validation - */ -export const isBoolean = (value: any): value is boolean => typeof value === 'boolean' - -/** - * Check if a variable is a function - * @category Validation - */ -export function isFunction(value: any, strict?: false): value is AnyFunction -// eslint-disable-next-line @typescript-eslint/ban-types -export function isFunction(value: any, strict: true): value is Function -// eslint-disable-next-line @typescript-eslint/ban-types -export function isFunction(value: any, strict?: boolean): value is AnyFunction | Function { - return strict ? value instanceof Function : typeof value === 'function' || typeof value?.call === 'function' && typeof value?.apply === 'function' -} - -/** - * Check if a variable is a class - * @category Validation - */ -export const isClass = (value: any): value is AnyClass => isFunction(value) && /^\s*class\s+/.test(value.toString()) - -/** - * Check if a variable is a Set - * @category Validation - */ -export const isSet = (value: any): value is Set => value instanceof Set - -/** - * Check if a variable is the given type - * @category Validation - */ -export function isType(value: any, type: VariableType | VariableTypeDefinition | string): value is VariableType { - return typeOf(value) === (isObject(type) ? (type as VariableTypeDefinition).name.toLowerCase() : type) -} - -/** - * Check if a variable is a Base64 string - * @category Validation - */ -export const isBase64 = (content: string) => /^([\d+/A-Za-z]{4})*(([\d+/A-Za-z]{2}==)|([\d+/A-Za-z]{3}=))?$/.test(content) - -/** - * Check if a variable is a valid date - * @category Validation - */ -export function isDate(value: any): value is Date { - try { - return value instanceof Date || new Date(value).toString() !== 'Invalid Date' - } catch { - return false - } -} diff --git a/packages/utilities/src/variables.ts b/packages/utilities/src/variables.ts deleted file mode 100644 index 3c596fe3..00000000 --- a/packages/utilities/src/variables.ts +++ /dev/null @@ -1,156 +0,0 @@ -import {arrayMerge, arrayMergeDeep} from './arrays' -import {parseOptions} from './functions' -import {IObject, objectFilter, objectMerge, objectMergeDeep} from './objects' -import {isArray, isAsyncFunction, isFunction, isNullDefined, isNumber, isObject, isSet} from './validations' -import variableTypes, {PrimitiveVariableType, VariableType} from './data/variable-types' - -/** - * Count the number of keys in an object \ - * Count the number of entries in an array \ - * Count the number of values in a Set \ - * Get the length of a string - * @category Variables - */ -export function count(value: any, strict = true): number { - if (isNumber(value)) { - return value - } else if (isSet(value)) { - return value.size - } else if (isObject(value)) { - if (strict) { - value = objectFilter(value, v => !isFunction(v)) - } - return Object.keys(value).length - } - return value.length -} - -/** - * Check if a variable is a JSON string - * @category Variables - */ -export function isJSONString(value: any, returnValue = false) { - try { - const result = JSON.parse(value) - return returnValue ? result : true - } catch { - return false - } -} - -/** - * Return a variable's type - * @category Variables - */ -export function typeOf(value: any): VariableType { - const varType = typeof value - if (variableTypes.primitive.includes(varType as PrimitiveVariableType)) { - return varType - } - if (Array.isArray(value)) { - return 'array' - } - if (value instanceof Date) { - return 'date' - } - if (value instanceof Promise) { - return 'promise' - } - if (varType === 'function' && value.constructor.name === 'AsyncFunction') { - return 'asyncfunction' - } - return Object.prototype.toString?.call(value).slice(8, -1) - .toLowerCase() -} - -export interface isCallableOptions { - strict: false - async: false -} - -/** - * Check if a variable is callable - * @category Variables - */ -export function isCallable(value: any, options?: Partial | boolean): boolean { - if (!value) { - return false - } - - options = parseOptions(options, - { - strict: false, - async: false - }, - 'async') as Partial - - if (options.async) { - return isAsyncFunction(value) || isFunction(value, options.strict) - } - return isFunction(value, options.strict) -} - -/** - * Merge two or more variables together - * @category Variables - */ -export function merge(...values: any[] | IObject[]): any[] | IObject { - let toReturn - let returnType - for (const value of values) { - if (!isNullDefined(value)) { - if (!returnType || typeOf(value) !== returnType) { - toReturn = value - returnType = typeOf(value) - } else if (returnType === 'array') { - toReturn ||= [] - toReturn = arrayMerge(toReturn, value) - } else if (returnType === 'object') { - toReturn ||= {} - toReturn = objectMerge(toReturn, value) - } else { - toReturn = value - } - } - } - return toReturn -} - -/** - * Merge two or more variables together, recursing child values - * @category Variables - */ -export function mergeDeep(...values: any[] | IObject[]): any[] | IObject { - let toReturn - let returnType - for (const value of values) { - if (!isNullDefined(value)) { - if (!returnType || typeOf(value) !== returnType) { - toReturn = value - returnType = typeOf(value) - } else if (returnType === 'array') { - toReturn ||= [] - toReturn = arrayMergeDeep(toReturn, value) - } else if (returnType === 'object') { - toReturn ||= {} - toReturn = objectMergeDeep(toReturn, value) - } else { - toReturn = value - } - } - } - return toReturn -} - -/** - * Clone a variable - * @category Variables - */ -export function clone(value: any): any { - if (isArray(value)) { - return [...value] - } else if (isObject(value)) { - return {...value} - } - return value -} diff --git a/packages/utilities/tsconfig.json b/packages/utilities/tsconfig.json deleted file mode 100644 index 3475b723..00000000 --- a/packages/utilities/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "include": [ - "src/**/*.ts", - "__tests__/**/*.ts" - ] -} diff --git a/packages/utilities/typedoc.json b/packages/utilities/typedoc.json deleted file mode 100644 index 44bd80f2..00000000 --- a/packages/utilities/typedoc.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": [ - "../../typedoc.json" - ], - "entryPoints": [ - "src/index.ts" - ] -} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e98ea5a6..2f80e79f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,14 +9,17 @@ importers: .: devDependencies: '@snickbit/eslint-config': - specifier: 1.5.3 - version: 1.5.3(eslint@8.45.0)(jest@29.6.1)(typescript@5.1.6) + specifier: 1.5.4 + version: 1.5.4(eslint@8.45.0)(jest@29.6.1)(typescript@5.1.6) '@snickbit/readmes': specifier: 0.0.28 version: 0.0.28 '@snickbit/semantic-release': - specifier: 1.6.6 - version: 1.6.6(semantic-release@20.1.3) + specifier: 1.6.7 + version: 1.6.7(semantic-release@20.1.3) + '@types/jest': + specifier: 29.5.3 + version: 29.5.3 eslint: specifier: 8.45.0 version: 8.45.0 @@ -25,7 +28,7 @@ importers: version: 8.0.3 jest: specifier: 29.6.1 - version: 29.6.1(@types/node@20.4.2) + version: 29.6.1 lint-staged: specifier: 13.2.3 version: 13.2.3 @@ -51,11 +54,11 @@ importers: specifier: ^3.0.27 version: 3.0.27 '@snickbit/node-utilities': - specifier: ^4.7.8 - version: link:../../packages/node-utilities + specifier: ^4.7.10 + version: 4.7.10 '@snickbit/out': - specifier: ^2.1.4 - version: 2.1.4 + specifier: ^2.2.0 + version: 2.2.0 ansi-styles-template: specifier: 1.0.0 version: 1.0.0 @@ -85,8 +88,8 @@ importers: packages/controller: dependencies: '@snickbit/utilities': - specifier: 3.11.3 - version: link:../utilities + specifier: 3.12.0 + version: 3.12.0 mitt: specifier: ~3.0.1 version: 3.0.1 @@ -107,15 +110,15 @@ importers: packages/cycle: dependencies: '@snickbit/utilities': - specifier: 3.11.3 - version: link:../utilities + specifier: 3.12.0 + version: 3.12.0 devDependencies: '@types/jest': specifier: 29.5.3 version: 29.5.3 jest: specifier: 29.6.1 - version: 29.6.1(@types/node@20.4.2) + version: 29.6.1 ts-jest: specifier: 29.1.1 version: 29.1.1(@babel/core@7.22.9)(esbuild@0.18.14)(jest@29.6.1)(typescript@5.1.6) @@ -135,11 +138,11 @@ importers: packages/dates: dependencies: '@snickbit/plural': - specifier: 1.0.18 - version: link:../plural + specifier: 1.0.19 + version: 1.0.19 '@snickbit/utilities': - specifier: 3.11.3 - version: link:../utilities + specifier: 3.12.0 + version: 3.12.0 dayjs: specifier: 1.11.9 version: 1.11.9 @@ -149,7 +152,7 @@ importers: version: 29.5.3 jest: specifier: 29.6.1 - version: 29.6.1(@types/node@20.4.2) + version: 29.6.1 ts-jest: specifier: 29.1.1 version: 29.1.1(@babel/core@7.22.9)(esbuild@0.18.14)(jest@29.6.1)(typescript@5.1.6) @@ -169,11 +172,11 @@ importers: packages/model: dependencies: '@snickbit/out': - specifier: ^2.1.4 - version: 2.1.4 + specifier: ^2.2.0 + version: 2.2.0 '@snickbit/utilities': - specifier: ^3.11.1 - version: link:../utilities + specifier: ^3.11.4 + version: 3.11.4 object-path: specifier: ^0.11.8 version: 0.11.8 @@ -186,83 +189,7 @@ importers: version: 0.11.1 jest: specifier: 29.6.1 - version: 29.6.1(@types/node@20.4.2) - ts-jest: - specifier: 29.1.1 - version: 29.1.1(@babel/core@7.22.9)(esbuild@0.18.14)(jest@29.6.1)(typescript@5.1.6) - tsup: - specifier: 7.1.0 - version: 7.1.0(typescript@5.1.6) - typedoc: - specifier: 0.24.8 - version: 0.24.8(typescript@5.1.6) - typedoc-plugin-markdown: - specifier: 3.15.3 - version: 3.15.3(typedoc@0.24.8) - typescript: - specifier: 5.1.6 - version: 5.1.6 - - packages/node-utilities: - dependencies: - '@snickbit/out': - specifier: ^2.1.4 - version: 2.1.4 - '@snickbit/utilities': - specifier: ^3.11.1 - version: link:../utilities - ansi-styles-template: - specifier: ^1.0.0 - version: 1.0.0 - cli-progress: - specifier: 3.12.0 - version: 3.12.0 - is-wsl: - specifier: ^2.2.0 - version: 2.2.0 - lodash.throttle: - specifier: ^4.1.1 - version: 4.1.1 - nanospinner: - specifier: ^1.1.0 - version: 1.1.0 - prompts: - specifier: ^2.4.2 - version: 2.4.2 - devDependencies: - '@types/jest': - specifier: 29.5.3 - version: 29.5.3 - '@types/node': - specifier: 20.4.2 - version: 20.4.2 - jest: - specifier: 29.6.1 - version: 29.6.1(@types/node@20.4.2) - ts-jest: - specifier: 29.1.1 - version: 29.1.1(@babel/core@7.22.9)(esbuild@0.18.14)(jest@29.6.1)(typescript@5.1.6) - tsup: - specifier: 7.1.0 - version: 7.1.0(typescript@5.1.6) - typedoc: - specifier: 0.24.8 - version: 0.24.8(typescript@5.1.6) - typedoc-plugin-markdown: - specifier: 3.15.3 - version: 3.15.3(typedoc@0.24.8) - typescript: - specifier: 5.1.6 - version: 5.1.6 - - packages/plural: - devDependencies: - '@types/jest': - specifier: 29.5.3 - version: 29.5.3 - jest: - specifier: 29.6.1 - version: 29.6.1(@types/node@20.4.2) + version: 29.6.1 ts-jest: specifier: 29.1.1 version: 29.1.1(@babel/core@7.22.9)(esbuild@0.18.14)(jest@29.6.1)(typescript@5.1.6) @@ -282,21 +209,21 @@ importers: packages/queue: dependencies: '@snickbit/utilities': - specifier: 3.11.3 - version: link:../utilities + specifier: 3.11.4 + version: 3.11.4 lite-fifo: specifier: 0.3.3 version: 0.3.3 devDependencies: '@snickbit/indexer': - specifier: 2.9.1 - version: 2.9.1 + specifier: 2.9.4 + version: 2.9.4 '@types/jest': specifier: 29.5.3 version: 29.5.3 jest: specifier: 29.6.1 - version: 29.6.1(@types/node@20.4.2) + version: 29.6.1 ts-jest: specifier: 29.1.1 version: 29.1.1(@babel/core@7.22.9)(esbuild@0.18.14)(jest@29.6.1)(typescript@5.1.6) @@ -319,8 +246,8 @@ importers: specifier: ^0.0.26 version: 0.0.26 '@snickbit/utilities': - specifier: 3.11.3 - version: link:../utilities + specifier: 3.12.0 + version: 3.12.0 cli-spinners: specifier: ^2.9.0 version: 2.9.0 @@ -329,8 +256,8 @@ importers: version: 4.1.5 devDependencies: '@snickbit/indexer': - specifier: 2.9.1 - version: 2.9.1 + specifier: 2.9.4 + version: 2.9.4 '@types/node': specifier: 20.4.2 version: 20.4.2 @@ -353,8 +280,8 @@ importers: packages/state: dependencies: '@snickbit/utilities': - specifier: 3.11.3 - version: link:../utilities + specifier: 3.11.4 + version: 3.11.4 mitt: specifier: 3.0.1 version: 3.0.1 @@ -364,7 +291,7 @@ importers: version: 29.5.3 jest: specifier: 29.6.1 - version: 29.6.1(@types/node@20.4.2) + version: 29.6.1 ts-jest: specifier: 29.1.1 version: 29.1.1(@babel/core@7.22.9)(esbuild@0.18.14)(jest@29.6.1)(typescript@5.1.6) @@ -388,44 +315,7 @@ importers: version: 29.5.3 jest: specifier: 29.6.1 - version: 29.6.1(@types/node@20.4.2) - ts-jest: - specifier: 29.1.1 - version: 29.1.1(@babel/core@7.22.9)(esbuild@0.18.14)(jest@29.6.1)(typescript@5.1.6) - tsup: - specifier: 7.1.0 - version: 7.1.0(typescript@5.1.6) - typedoc: - specifier: 0.24.8 - version: 0.24.8(typescript@5.1.6) - typedoc-plugin-markdown: - specifier: 3.15.3 - version: 3.15.3(typedoc@0.24.8) - typescript: - specifier: 5.1.6 - version: 5.1.6 - - packages/utilities: - dependencies: - '@lukeed/uuid': - specifier: ^2.0.1 - version: 2.0.1 - '@snickbit/plural': - specifier: 1.0.18 - version: link:../plural - just-camel-case: - specifier: 6.2.0 - version: 6.2.0 - devDependencies: - '@snickbit/indexer': - specifier: 2.9.1 - version: 2.9.1 - '@types/jest': - specifier: 29.5.3 - version: 29.5.3 - jest: - specifier: 29.6.1 - version: 29.6.1(@types/node@20.4.2) + version: 29.6.1 ts-jest: specifier: 29.1.1 version: 29.1.1(@babel/core@7.22.9)(esbuild@0.18.14)(jest@29.6.1)(typescript@5.1.6) @@ -2376,8 +2266,8 @@ packages: dependencies: '@snickbit/utilities': 3.11.1 - /@snickbit/eslint-config@1.5.3(eslint@8.45.0)(jest@29.6.1)(typescript@5.1.6): - resolution: {integrity: sha512-klqUpYcdB81jpKYcUcGKoOOhs4RR99M4ZJnpHXbmu0nnyUKx+XuGhS7FshjUP/Y6GXlbx6g1NtfETnjo+Tqwsg==} + /@snickbit/eslint-config@1.5.4(eslint@8.45.0)(jest@29.6.1)(typescript@5.1.6): + resolution: {integrity: sha512-RCzzdxt6ulQkPhQD7sO1wJkU/W4jwNY+UxA26peAt1FxTUtvTjxEpMOnZO3p7FUnC0PARTL3m1mgw6q1XCcXBw==} engines: {node: '>= 14.17'} peerDependencies: eslint: '>= 8.19.0' @@ -2403,15 +2293,15 @@ packages: - typescript dev: true - /@snickbit/indexer@2.9.1: - resolution: {integrity: sha512-/1iSpHtxtcy66k3wC6iX1T5Eny5cAahvTMkEHsFLlwKl59HN09PijGsev+EWBMjJbbU0WYM1WLNA0uZJSGIMEA==} + /@snickbit/indexer@2.9.4: + resolution: {integrity: sha512-z94+eCKeSh85JMOeT0TMfxhdHVV7YNDiysF9mhMEaFjEaODh5uCqIyGAZq6A6C8EzgbARQmDRkMcmEzph1Xb2w==} engines: {node: '>= 14'} hasBin: true dependencies: '@snickbit/node-cli': 3.0.27 - '@snickbit/node-utilities': 4.7.8 + '@snickbit/node-utilities': 4.7.10 '@snickbit/out': 2.1.4 - '@snickbit/utilities': 3.11.1 + '@snickbit/utilities': 3.11.4 chokidar: 3.5.3 esbuild: 0.18.13 fast-glob: 3.3.0 @@ -2429,12 +2319,25 @@ packages: lilconfig: 2.1.0 yargs-parser: 21.1.1 + /@snickbit/node-utilities@4.7.10: + resolution: {integrity: sha512-vY7m8/KVTY5g9LDvmaFIOjiYqlMZoUMWYg0rDze/xJ1/NQTFHJHu96ffLMJQBbH/xaMMoklpV0vAz05Eu+55bQ==} + engines: {node: '>= 14.17'} + dependencies: + '@snickbit/out': 2.2.0 + '@snickbit/utilities': 3.12.0 + ansi-styles-template: 1.0.0 + cli-progress: 3.12.0 + is-wsl: 2.2.0 + lodash.throttle: 4.1.1 + nanospinner: 1.1.0 + prompts: 2.4.2 + /@snickbit/node-utilities@4.7.8: resolution: {integrity: sha512-m+VTAGJNZ91SBEbUiwxW0uYLXKliFZV3z1Za13URl5QrmEtbi2PdlpxS4zD18ja+n8sLuvRF0Mgiroyrf2sF+Q==} engines: {node: '>= 14.17'} dependencies: - '@snickbit/out': 2.1.4 - '@snickbit/utilities': link:packages/utilities + '@snickbit/out': 2.2.0 + '@snickbit/utilities': 3.12.0 ansi-styles-template: 1.0.0 cli-progress: 3.12.0 is-wsl: 2.2.0 @@ -2454,6 +2357,26 @@ packages: node-inspect-extracted: 3.0.0 picomatch-browser: 2.2.6 + /@snickbit/out@2.2.0: + resolution: {integrity: sha512-f71lNnTCyM64OrN0XFBtmjPJJ/XQEEPZevfaGc1CK/2FrYy1RG4NGJwumdRkvxUJqlJ6Tt/e4DS/ZFqeGCw9wA==} + engines: {node: '>= 16'} + dependencies: + '@snickbit/ansi': 0.0.26 + '@snickbit/cycle': 1.0.22 + '@snickbit/utilities': 3.11.1 + ansi-styles-template: 1.0.0 + browser-or-node: 2.1.1 + node-inspect-extracted: 3.0.0 + picomatch-browser: 2.2.6 + + /@snickbit/plural@1.0.18: + resolution: {integrity: sha512-BPf935z4FabSXGA4cTT9q9GbU6K4Ykaw7dk1QtpOJmEK2u+lYog96wm5GfZ2F/ITbyl4JMRRKyWjbLllP6Z4Lw==} + engines: {node: '>= 14.17'} + + /@snickbit/plural@1.0.19: + resolution: {integrity: sha512-EObov+ryM781xd4i04JJ+FGT37dfX+82oYGjs4O4BUUwTYWpAhl+XVVkmG+h10BAKe0ASb3wIaXz1VZKkhXBOg==} + engines: {node: '>= 14.17'} + /@snickbit/readmes@0.0.28: resolution: {integrity: sha512-56ybvndejNgb73GQEWmuNueMO2rltGtRUCNSff759qJ60kgvEgcmkjl+8g8ksBcT8MPD7GzQfiZ5ZN8sANxNqA==} engines: {node: '>= 14'} @@ -2462,15 +2385,15 @@ packages: '@snickbit/node-cli': 3.0.27 '@snickbit/node-utilities': 4.7.8 '@snickbit/out': 2.1.4 - '@snickbit/upwords': link:packages/upwords + '@snickbit/upwords': 2.0.40 '@snickbit/utilities': 3.11.1 ejs: 3.1.9 fast-glob: 3.3.0 lilconfig: 2.1.0 dev: true - /@snickbit/semantic-release@1.6.6(semantic-release@20.1.3): - resolution: {integrity: sha512-oIoQssJpwUmQ1OUvkUrugvlLIpJdLg+xTEOu7URP/AEYuXfqy133gTQLy1uHgn9cFPdAN5tdM/q85ETzjHu3HA==} + /@snickbit/semantic-release@1.6.7(semantic-release@20.1.3): + resolution: {integrity: sha512-XDI4OH6dJ1oRXiPfWhh1292CAPa8PFeA+kxm1cSBIztkkroMbyjNTTh/JQ5kt0Vmi6E7+NlIgj0jwF73xoVJCw==} engines: {node: '>= 14.17'} dependencies: '@semantic-release/changelog': 6.0.3(semantic-release@20.1.3) @@ -2486,12 +2409,33 @@ packages: - supports-color dev: true + /@snickbit/upwords@2.0.40: + resolution: {integrity: sha512-wmcHsSFUxXszL2umQ2VxF2YXWu9OVcetpeDnLfJNuFsULTy2cChO50gvnilQbXAnWIv2DaFyRUyYrAwgivAzbg==} + engines: {node: '>= 14.17'} + dev: true + /@snickbit/utilities@3.11.1: resolution: {integrity: sha512-vEi4bRO/0raCVe6jAa7+9tMtVqeBGqawzbFCGm1gffwlzTVk8U4DyxJxkvuBjI1Oz8WnRrYiwZTwbHoB8Kkolw==} engines: {node: '>= 14.17'} dependencies: '@lukeed/uuid': 2.0.1 - '@snickbit/plural': link:packages/plural + '@snickbit/plural': 1.0.18 + just-camel-case: 6.2.0 + + /@snickbit/utilities@3.11.4: + resolution: {integrity: sha512-NODmhIuYFspd9UDn+pg2HCtzVa0ol1bw32H1g/Wl5wjF1D5eWPPQ4OoWcJWW5ve25fSqGsU/K3tuJ2DBGr2uWQ==} + engines: {node: '>= 14.17'} + dependencies: + '@lukeed/uuid': 2.0.1 + '@snickbit/plural': 1.0.18 + just-camel-case: 6.2.0 + + /@snickbit/utilities@3.12.0: + resolution: {integrity: sha512-wd8ZKzwjgAUAQDO0GcvrSPQlJqTrL9IdiHBs2tLhxFbiU5Jtxdl7q1vqBc08fLqZzdCMdvgjNVjwEA7ZBjhN+Q==} + engines: {node: '>= 14.17'} + dependencies: + '@lukeed/uuid': 2.0.1 + '@snickbit/plural': 1.0.19 just-camel-case: 6.2.0 /@tootallnate/once@2.0.0: @@ -3903,7 +3847,7 @@ packages: '@typescript-eslint/eslint-plugin': 5.59.5(@typescript-eslint/parser@5.59.5)(eslint@8.45.0)(typescript@5.1.6) '@typescript-eslint/utils': 5.62.0(eslint@8.45.0)(typescript@5.1.6) eslint: 8.45.0 - jest: 29.6.1(@types/node@20.4.2) + jest: 29.6.1 transitivePeerDependencies: - supports-color - typescript @@ -5022,7 +4966,7 @@ packages: - supports-color dev: true - /jest-cli@29.6.1(@types/node@20.4.2): + /jest-cli@29.6.1: resolution: {integrity: sha512-607dSgTA4ODIN6go9w6xY3EYkyPFGicx51a69H7yfvt7lN53xNswEVLovq+E77VsTRi5fWprLH0yl4DJgE8Ing==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} hasBin: true @@ -5373,7 +5317,7 @@ packages: supports-color: 8.1.1 dev: true - /jest@29.6.1(@types/node@20.4.2): + /jest@29.6.1: resolution: {integrity: sha512-Nirw5B4nn69rVUZtemCQhwxOBhm0nsp3hmtF4rzCeWD7BkjAXRIji7xWQfnTNbz9g0aVsBX6aZK3n+23LM6uDw==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} hasBin: true @@ -5386,7 +5330,7 @@ packages: '@jest/core': 29.6.1 '@jest/types': 29.6.1 import-local: 3.1.0 - jest-cli: 29.6.1(@types/node@20.4.2) + jest-cli: 29.6.1 transitivePeerDependencies: - '@types/node' - supports-color @@ -7308,7 +7252,7 @@ packages: bs-logger: 0.2.6 esbuild: 0.18.14 fast-json-stable-stringify: 2.1.0 - jest: 29.6.1(@types/node@20.4.2) + jest: 29.6.1 jest-util: 29.6.1 json5: 2.2.3 lodash.memoize: 4.1.2 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index f0709d69..2192dea6 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,4 +1,4 @@ packages: + - "scripts" - "packages/*" - "clis/*" - - "scripts"