diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 865e313..4c6eba9 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -10,7 +10,7 @@ jobs: - name: Installing node.js uses: actions/setup-node@v1 # Used to install node environment with: - node-version: '10.x' + node-version: "10.x" unit-test: name: Code coverage @@ -23,7 +23,7 @@ jobs: id: yarn-cache run: echo "::set-output name=dir::$(yarn cache dir)" - - uses: actions/cache@v1 + - uses: actions/cache@v4 with: path: ${{ steps.yarn-cache.outputs.dir }} key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} diff --git a/.github/workflows/deploy-github-pages.yml b/.github/workflows/deploy-github-pages.yml index ddb2338..4e1826a 100644 --- a/.github/workflows/deploy-github-pages.yml +++ b/.github/workflows/deploy-github-pages.yml @@ -13,7 +13,7 @@ jobs: - name: Installing node.js uses: actions/setup-node@v1 # Used to install node environment with: - node-version: '10.x' + node-version: "10.x" run-documentation: name: Run documentation @@ -26,7 +26,7 @@ jobs: id: yarn-cache run: echo "::set-output name=dir::$(yarn cache dir)" - - uses: actions/cache@v1 + - uses: actions/cache@v4 with: path: ${{ steps.yarn-cache.outputs.dir }} key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} diff --git a/.github/workflows/format-check-build.yml b/.github/workflows/format-check-build.yml index 9838273..24079bc 100644 --- a/.github/workflows/format-check-build.yml +++ b/.github/workflows/format-check-build.yml @@ -3,7 +3,7 @@ name: Running lint checks and build on: push: branches-ignore: - - 'main' + - "main" jobs: setup: @@ -13,7 +13,7 @@ jobs: - name: Installing node.js uses: actions/setup-node@v1 # Used to install node environment with: - node-version: '10.x' + node-version: "10.x" format-check: name: Check code format and build app @@ -26,7 +26,7 @@ jobs: id: yarn-cache run: echo "::set-output name=dir::$(yarn cache dir)" - - uses: actions/cache@v1 + - uses: actions/cache@v4 with: path: ${{ steps.yarn-cache.outputs.dir }} key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 8887b45..0abf7c3 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -3,7 +3,7 @@ name: Running code tests on: push: branches-ignore: - - 'main' + - "main" jobs: setup: @@ -13,7 +13,7 @@ jobs: - name: Installing node.js uses: actions/setup-node@v1 # Used to install node environment with: - node-version: '10.x' + node-version: "10.x" run-tests: name: Run code tests @@ -26,7 +26,7 @@ jobs: id: yarn-cache run: echo "::set-output name=dir::$(yarn cache dir)" - - uses: actions/cache@v1 + - uses: actions/cache@v4 with: path: ${{ steps.yarn-cache.outputs.dir }} key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} diff --git a/README.md b/README.md index 326f116..7a6b4af 100644 --- a/README.md +++ b/README.md @@ -27,11 +27,15 @@ v4 is just migrating the code base to TypeScript. Kindly refer to the [changelog Version 3 introduces a code-breaking change. Each method is exported independently instead of having them under a "category utility". Read more on how to use it [here](https://iamdevlinph.github.io/common-utils-pkg/usage.html). ## Installation + NPM + ``` npm i --save common-utils-pkg ``` + Yarn + ``` yarn add common-utils-pkg ``` @@ -82,22 +86,25 @@ Read more about the usage [here](https://iamdevlinph.github.io/common-utils-pkg/ Read more about the methods available [here](https://iamdevlinph.github.io/common-utils-pkg/docs.html) ## Features -* Transpile ES6 to ES5 using [Babel](https://github.com/babel/babel) -* Coverage using [Istanbul](https://github.com/gotwarlost/istanbul) with [nyc](https://github.com/istanbuljs/nyc) and report by [Codecov](https://github.com/codecov/codecov-node) -* Create the bundle using [webpack](https://github.com/webpack/webpack) -* Run tests using [Mocha](https://github.com/mochajs/mocha) and [chai](https://github.com/chaijs/chai) -* Lint stuff using [ESLint](https://github.com/eslint/eslint) -* Build status by [Travis](https://github.com/travis-ci/travis-ci) -* Precommit using [lint-staged](https://github.com/okonet/lint-staged) and [husky](https://github.com/typicode/husky) -* Provides TypeScript type definitions + +- Transpile ES6 to ES5 using [Babel](https://github.com/babel/babel) +- Coverage using [Istanbul](https://github.com/gotwarlost/istanbul) with [nyc](https://github.com/istanbuljs/nyc) and report by [Codecov](https://github.com/codecov/codecov-node) +- Create the bundle using [webpack](https://github.com/webpack/webpack) +- Run tests using [Mocha](https://github.com/mochajs/mocha) and [chai](https://github.com/chaijs/chai) +- Lint stuff using [ESLint](https://github.com/eslint/eslint) +- Build status by [Travis](https://github.com/travis-ci/travis-ci) +- Precommit using [lint-staged](https://github.com/okonet/lint-staged) and [husky](https://github.com/typicode/husky) +- Provides TypeScript type definitions # Contributing + 1.Create a folder under `src/` and name the folder with the same name as the method. 2.Create `methodName.js` and `methodName.spec.js` The full directory should look like this: + ``` src/ methodName/ @@ -112,20 +119,28 @@ import expects from '../expects/expects'; ``` Wrap your exported function with `expects` + ```js export default expects( methodName, 'methodName', - { // required parameters + { + // required parameters 0: 'string', // 1st parameter is required and is a string 1: 'number', // 2nd parameter is required and is a number }, - { // optional parameters - 2: 'number' // 3rd parameter is optional but is a number + { + // optional parameters + 2: 'number', // 3rd parameter is optional but is a number } -) +); ``` +### Scripts + +- `yarn docusaurus:generate` - generate new files. Will auto refresh page +- `yarn docusaurus:start` - start up the docu page + # Publishing ### Publish to NPM @@ -133,6 +148,7 @@ export default expects( To publish version, just create a relase tag and a github workflow will automatically handle the publishing to npm. ### Publish doc updates + Doc updates should be automatically be deployed once merged to main by github action. diff --git a/docs-md/api/arrayRemoveItem.md b/docs-md/api/arrayRemoveItem.md index fe023e3..c180672 100644 --- a/docs-md/api/arrayRemoveItem.md +++ b/docs-md/api/arrayRemoveItem.md @@ -6,17 +6,20 @@ Removes provided element from an array. ### Parameters -* `array` **[array][1]** of strings to remove element from -* `toRemove` **[string][2]** to remove from the array +* `array` **[array][1]** of strings | numbers to remove element from +* `toRemove` **([string][2] | [number][3])** to remove from the array ### Examples ```javascript arrayRemoveItem(['The', 'quick', 'brown'], 'The'); // => ['quick', 'brown'] + +arrayRemoveItem([2, 4, 1], 4); +// => [2, 1] ``` -Returns **[array][1]** of strings without the removed element. +Returns **[array][1]** without the removed element. **Meta** @@ -26,5 +29,7 @@ Returns **[array][1]** of strings without the removed element. [2]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String +[3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number + -* Source: [array-remove-item.ts](https://github.com/iamdevlinph/common-utils-pkg/blob/main/src/array-remove-item/array-remove-item.ts#L16-L18) \ No newline at end of file +* Source: [array-remove-item.ts](https://github.com/iamdevlinph/common-utils-pkg/blob/main/src/array-remove-item/array-remove-item.ts#L19-L24) \ No newline at end of file diff --git a/docs-md/changelog.md b/docs-md/changelog.md index 0ebb7fb..8fdd739 100644 --- a/docs-md/changelog.md +++ b/docs-md/changelog.md @@ -5,6 +5,10 @@ id: changelog # Changelog +##### 4.1.6 + +- Update `arrayRemoveItem` to support number + ##### 4.1.5 - TODO: Switch to pnpm diff --git a/docs/mapped_source.json b/docs/mapped_source.json index 5e69f54..7d6d004 100644 --- a/docs/mapped_source.json +++ b/docs/mapped_source.json @@ -4,23 +4,23 @@ "description": "Removes provided element from an array.", "args": [ { - "description": "array to remove element from", + "description": "of strings to remove element from", "param": "array", - "type": "StringArray", + "type": "array", "optional": false }, { - "description": "element to remove from the array", + "description": "to remove from the array", "param": "toRemove", - "type": "String", + "type": "string", "optional": false } ], "module": "Array", "method": "arrayRemoveItem", "returns": { - "desc": "Returns an array without the removed element.", - "type": "StringArray" + "desc": "of strings without the removed element.", + "type": "array" }, "example": "arrayRemoveItem(['The', 'quick', 'brown'], 'The');\n// => ['quick', 'brown']", "utilArgs": "arrayRemoveItem(array, toRemove)", @@ -30,23 +30,23 @@ "description": "Splits a string to an array based on the delimiter passed.", "args": [ { - "description": "string to convert to array", + "description": "to convert to array", "param": "string", - "type": "String", + "type": "string", "optional": false }, { - "description": "where to split the string", + "description": "character where to split the string", "param": "delimiter", - "type": "String", + "type": "string", "optional": false } ], "module": "Array", "method": "stringToArray", "returns": { - "desc": "Returns an array of the split string.", - "type": "StringArray" + "desc": "of the split string.", + "type": "array" }, "example": "stringToArray('apple;banana;orange', ';');\n// => ['apple', 'banana', 'orange']", "utilArgs": "stringToArray(string, delimiter)", @@ -58,23 +58,23 @@ "description": "Convert an array to a string and combine on the delimiter passed.", "args": [ { - "description": "array to convert to string", + "description": "to convert to string", "param": "array", - "type": "AnyArray", + "type": "array", "optional": false }, { - "description": "characater to use in combining to string", + "description": "characater to use in combining to string", "param": "delimiter", - "type": "String", + "type": "string", "optional": false } ], "module": "String", "method": "arrayToString", "returns": { - "desc": "Returns a string from the array.", - "type": "String" + "desc": "from the array.", + "type": "string" }, "example": "arrayToString(['The', 'quick', 'brown'], '-');\n// => 'The-brown-fox'", "utilArgs": "arrayToString(array, delimiter)", @@ -84,17 +84,17 @@ "description": "Converts a string into a slug for URL usage.", "args": [ { - "description": "string to convert to slug", + "description": "to convert to slug", "param": "string", - "type": "String", + "type": "string", "optional": false } ], "module": "String", "method": "slugify", "returns": { - "desc": "Returns slug version of the string.", - "type": "String" + "desc": "slug version of the string.", + "type": "string" }, "example": "slugify('The quick brown fox');\n// => 'the-quick-brown-fox'\n\nslugify('A. more-Complicated string!..');\n// => 'a-more-complicated-string'\n\nslugify('wïth speciäl chærs');\n// => 'with-special-chars'", "utilArgs": "slugify(string)", @@ -104,17 +104,17 @@ "description": "Converts a string to Sentence case.", "args": [ { - "description": "string to convert to Sentence case", + "description": "to convert to Sentence case", "param": "string", - "type": "String", + "type": "string", "optional": false } ], "module": "String", "method": "toSentenceCase", "returns": { - "desc": "Returns a Sentence case string.", - "type": "String" + "desc": "in sentence case.", + "type": "string" }, "example": "toSentenceCase('THE QUICK BROWN FOX');\n// => 'The quick brown fox'", "utilArgs": "toSentenceCase(string)", @@ -124,17 +124,17 @@ "description": "Converts a string to a Title Case.", "args": [ { - "description": "string to convert to Title Case", + "description": "to convert to Title Case", "param": "string", - "type": "String", + "type": "string", "optional": false } ], "module": "String", "method": "toTitleCase", "returns": { - "desc": "Returns a Tile Case string.", - "type": "String" + "desc": "in Title Case.", + "type": "string" }, "example": "toTitleCase('the quick brown fox');\n// => 'The Quick Brown Fox'", "utilArgs": "toTitleCase(string)", @@ -148,8 +148,8 @@ "module": "Browser", "method": "browserDetect", "returns": { - "desc": "Returns browser name", - "type": "String" + "desc": "of browser name.", + "type": "string" }, "example": "browserDetect();\n// => 'Chrome", "utilArgs": "browserDetect()", @@ -163,21 +163,21 @@ { "description": "HEX color to change brightness", "param": "hex", - "type": "String", + "type": "string", "optional": false }, { "description": "positive or negative percentage", "param": "amount", - "type": "Number", + "type": "number", "optional": false } ], "module": "Color", "method": "colorBrightness", "returns": { - "desc": "Returns a manipulated HEX color", - "type": "String" + "desc": "of manipulated HEX color.", + "type": "string" }, "example": "colorBrightness('#3CB878', 50);\n// => '#6EEAAA'\n\ncolorBrightness('#3CB878', -50);\n// => '#A8646'", "utilArgs": "colorBrightness(hex, amount)", @@ -189,15 +189,15 @@ { "description": "hex color to convert", "param": "hex", - "type": "String", + "type": "string", "optional": false } ], "module": "Color", "method": "invertColor", "returns": { - "desc": "Returns a HEX color string.", - "type": "String" + "desc": "of HEX color.", + "type": "string" }, "example": "invertColor('#E3CCA8');\n// => '#1C3357'\n\ninvertColor('ccc');\n// => '#333333'", "utilArgs": "invertColor(hex)", @@ -209,8 +209,8 @@ "module": "Color", "method": "randomPastelColor", "returns": { - "desc": "Returns an HSL color.", - "type": "String" + "desc": "of HSL color.", + "type": "string" }, "example": "randomPastelColor();\n// => 'hsl(85.78009756824814,31.861668997564585%,90.94781190317771%)'", "utilArgs": "randomPastelColor()", @@ -224,8 +224,8 @@ "module": "Key", "method": "guid", "returns": { - "desc": "guid string", - "type": "String" + "desc": "of guid.", + "type": "string" }, "example": "guid();\n// => \"0153a717-3ba2-b1ac-67f1-49db6551a28d\"", "utilArgs": "guid()", @@ -237,23 +237,23 @@ "description": "Converts a number of bytes to a human readable file size.", "args": [ { - "description": "number of bytes to show", + "description": "of bytes to show", "param": "bytes", - "type": "Number", + "type": "number", "optional": false }, { "description": "optional number of decimals to show", "param": "decimals", - "type": "Number", + "type": "number", "optional": true } ], "module": "File", "method": "readableBytes", "returns": { - "desc": "Returns a human readable file size.", - "type": "String" + "desc": "of human readable file size.", + "type": "string" }, "example": "readableBytes(1234);\n// => 1.205078125 kB\n\nreadableBytes(1234, 2);\n// => 1.21 kB", "utilArgs": "readableBytes(bytes, [decimals])", @@ -274,17 +274,16 @@ "description": "Retrieves data from the local storage.", "args": [ { - "description": "key to retrieve", + "description": "to retrieve", "param": "key", - "type": "String", + "type": "string", "optional": false } ], "module": "Storage", "method": "storageGet", "returns": { - "desc": "Returns data from the local storage. Returns '' if key is not found", - "type": "Any" + "desc": "data from the local storage. Returns '' if key is not found" }, "example": "storageGet('key');", "utilArgs": "storageGet(key)", @@ -294,9 +293,9 @@ "description": "Removes an entry from the local storage.", "args": [ { - "description": "key of the entry to remove", + "description": "of the entry to remove", "param": "key", - "type": "String", + "type": "string", "optional": false } ], @@ -312,7 +311,7 @@ { "description": "name of the entry", "param": "key", - "type": "String", + "type": "string", "optional": false }, { @@ -340,17 +339,17 @@ "optional": false }, { - "description": "optional array of user defined true values", + "description": "of user defined true values", "param": "trueValuesArr", - "type": "AnyArray", + "type": "array", "optional": true } ], "module": "Boolean", "method": "toBoolean", "returns": { - "desc": "Returns a boolean equivalent of the value.", - "type": "Boolean" + "desc": "equivalent of the value.", + "type": "boolean" }, "example": "toBoolean('y');\n // => true\n\ntoBoolean(null);\n// => false", "utilArgs": "toBoolean(val, [trueValuesArr])", diff --git a/docs/pull_request_template.md b/docs/pull_request_template.md index 082e586..c67a6f5 100644 --- a/docs/pull_request_template.md +++ b/docs/pull_request_template.md @@ -1,6 +1,7 @@ Closes: # ----- +--- + - [ ] This PR will add a **new method** - [ ] **New method directory** `src//` - [ ] **Created method file** under `src//.js` @@ -10,7 +11,7 @@ Closes: # - [ ] **Add entry in the typings** - [ ] **Generate docs** ----- +--- - [ ] **Bump package version to 1.0.x (patch) OR 1.x.0 (minor)** -- [ ] Update the [changelog.json](./changelog.json) +- [ ] Update the [changelog.md](../docs-md/changelog.md) diff --git a/docs/source.json b/docs/source.json index 698e857..bdf54ee 100644 --- a/docs/source.json +++ b/docs/source.json @@ -35,31 +35,31 @@ }, { "title": "param", - "description": "array to remove element from", + "description": "of strings to remove element from", "lineNumber": 6, "type": { "type": "NameExpression", - "name": "StringArray" + "name": "array" }, "name": "array" }, { "title": "param", - "description": "element to remove from the array", + "description": "to remove from the array", "lineNumber": 7, "type": { "type": "NameExpression", - "name": "String" + "name": "string" }, "name": "toRemove" }, { "title": "returns", - "description": "Returns an array without the removed element.", + "description": "of strings without the removed element.", "lineNumber": 8, "type": { "type": "NameExpression", - "name": "StringArray" + "name": "array" } }, { @@ -71,26 +71,22 @@ "loc": { "start": { "line": 1, - "column": 0, - "index": 0 + "column": 0 }, "end": { "line": 14, - "column": 3, - "index": 402 + "column": 3 } }, "context": { "loc": { "start": { "line": 16, - "column": 0, - "index": 404 + "column": 0 }, "end": { "line": 18, - "column": 2, - "index": 530 + "column": 2 } }, "file": "/home/iamdevlinph/projects/iamdevlinph/common-utils-pkg/src/array-remove-item/array-remove-item.ts" @@ -115,7 +111,7 @@ "children": [ { "type": "text", - "value": "array to remove element from" + "value": "of strings to remove element from" } ] } @@ -123,7 +119,7 @@ }, "type": { "type": "NameExpression", - "name": "StringArray" + "name": "array" } }, { @@ -138,7 +134,7 @@ "children": [ { "type": "text", - "value": "element to remove from the array" + "value": "to remove from the array" } ] } @@ -146,7 +142,7 @@ }, "type": { "type": "NameExpression", - "name": "String" + "name": "string" } } ], @@ -161,7 +157,7 @@ "children": [ { "type": "text", - "value": "Returns an array without the removed element." + "value": "of strings without the removed element." } ] } @@ -170,7 +166,7 @@ "title": "returns", "type": { "type": "NameExpression", - "name": "StringArray" + "name": "array" } } ], @@ -232,31 +228,31 @@ }, { "title": "param", - "description": "array to convert to string", + "description": "to convert to string", "lineNumber": 6, "type": { "type": "NameExpression", - "name": "AnyArray" + "name": "array" }, "name": "array" }, { "title": "param", - "description": "characater to use in combining to string", + "description": "characater to use in combining to string", "lineNumber": 7, "type": { "type": "NameExpression", - "name": "String" + "name": "string" }, "name": "delimiter" }, { "title": "returns", - "description": "Returns a string from the array.", + "description": "from the array.", "lineNumber": 8, "type": { "type": "NameExpression", - "name": "String" + "name": "string" } }, { @@ -268,26 +264,22 @@ "loc": { "start": { "line": 1, - "column": 0, - "index": 0 + "column": 0 }, "end": { "line": 14, - "column": 3, - "index": 407 + "column": 3 } }, "context": { "loc": { "start": { "line": 16, - "column": 0, - "index": 409 + "column": 0 }, "end": { "line": 17, - "column": 24, - "index": 513 + "column": 24 } }, "file": "/home/iamdevlinph/projects/iamdevlinph/common-utils-pkg/src/array-to-string/array-to-string.ts" @@ -312,7 +304,7 @@ "children": [ { "type": "text", - "value": "array to convert to string" + "value": "to convert to string" } ] } @@ -320,7 +312,7 @@ }, "type": { "type": "NameExpression", - "name": "AnyArray" + "name": "array" } }, { @@ -335,7 +327,7 @@ "children": [ { "type": "text", - "value": "characater to use in combining to string" + "value": "characater to use in combining to string" } ] } @@ -343,7 +335,7 @@ }, "type": { "type": "NameExpression", - "name": "String" + "name": "string" } } ], @@ -358,7 +350,7 @@ "children": [ { "type": "text", - "value": "Returns a string from the array." + "value": "from the array." } ] } @@ -367,7 +359,7 @@ "title": "returns", "type": { "type": "NameExpression", - "name": "String" + "name": "string" } } ], @@ -429,11 +421,11 @@ }, { "title": "returns", - "description": "Returns browser name", + "description": "of browser name.", "lineNumber": 6, "type": { "type": "NameExpression", - "name": "String" + "name": "string" } }, { @@ -445,26 +437,22 @@ "loc": { "start": { "line": 4, - "column": 0, - "index": 78 + "column": 0 }, "end": { "line": 15, - "column": 3, - "index": 273 + "column": 3 } }, "context": { "loc": { "start": { "line": 17, - "column": 0, - "index": 275 + "column": 0 }, "end": { "line": 52, - "column": 2, - "index": 1004 + "column": 2 } }, "file": "/home/iamdevlinph/projects/iamdevlinph/common-utils-pkg/src/browser-detect/browser-detect.ts" @@ -488,7 +476,7 @@ "children": [ { "type": "text", - "value": "Returns browser name" + "value": "of browser name." } ] } @@ -497,7 +485,7 @@ "title": "returns", "type": { "type": "NameExpression", - "name": "String" + "name": "string" } } ], @@ -563,7 +551,7 @@ "lineNumber": 7, "type": { "type": "NameExpression", - "name": "String" + "name": "string" }, "name": "hex" }, @@ -573,17 +561,17 @@ "lineNumber": 8, "type": { "type": "NameExpression", - "name": "Number" + "name": "number" }, "name": "amount" }, { "title": "returns", - "description": "Returns a manipulated HEX color", + "description": "of manipulated HEX color.", "lineNumber": 9, "type": { "type": "NameExpression", - "name": "String" + "name": "string" } }, { @@ -595,26 +583,22 @@ "loc": { "start": { "line": 4, - "column": 0, - "index": 109 + "column": 0 }, "end": { "line": 21, - "column": 3, - "index": 615 + "column": 3 } }, "context": { "loc": { "start": { "line": 23, - "column": 0, - "index": 617 + "column": 0 }, "end": { "line": 52, - "column": 2, - "index": 1271 + "column": 2 } }, "file": "/home/iamdevlinph/projects/iamdevlinph/common-utils-pkg/src/color-brightness/color-brightness.ts" @@ -647,7 +631,7 @@ }, "type": { "type": "NameExpression", - "name": "String" + "name": "string" } }, { @@ -670,7 +654,7 @@ }, "type": { "type": "NameExpression", - "name": "Number" + "name": "number" } } ], @@ -685,7 +669,7 @@ "children": [ { "type": "text", - "value": "Returns a manipulated HEX color" + "value": "of manipulated HEX color." } ] } @@ -694,7 +678,7 @@ "title": "returns", "type": { "type": "NameExpression", - "name": "String" + "name": "string" } } ], @@ -756,11 +740,11 @@ }, { "title": "returns", - "description": "guid string", + "description": "of guid.", "lineNumber": 6, "type": { "type": "NameExpression", - "name": "String" + "name": "string" } }, { @@ -772,26 +756,22 @@ "loc": { "start": { "line": 1, - "column": 0, - "index": 0 + "column": 0 }, "end": { "line": 12, - "column": 3, - "index": 185 + "column": 3 } }, "context": { "loc": { "start": { "line": 14, - "column": 0, - "index": 187 + "column": 0 }, "end": { "line": 20, - "column": 2, - "index": 396 + "column": 2 } }, "file": "/home/iamdevlinph/projects/iamdevlinph/common-utils-pkg/src/guid/guid.ts" @@ -815,7 +795,7 @@ "children": [ { "type": "text", - "value": "guid string" + "value": "of guid." } ] } @@ -824,7 +804,7 @@ "title": "returns", "type": { "type": "NameExpression", - "name": "String" + "name": "string" } } ], @@ -890,17 +870,17 @@ "lineNumber": 6, "type": { "type": "NameExpression", - "name": "String" + "name": "string" }, "name": "hex" }, { "title": "returns", - "description": "Returns a HEX color string.", + "description": "of HEX color.", "lineNumber": 7, "type": { "type": "NameExpression", - "name": "String" + "name": "string" } }, { @@ -912,26 +892,22 @@ "loc": { "start": { "line": 10, - "column": 0, - "index": 225 + "column": 0 }, "end": { "line": 25, - "column": 3, - "index": 514 + "column": 3 } }, "context": { "loc": { "start": { "line": 27, - "column": 0, - "index": 516 + "column": 0 }, "end": { "line": 46, - "column": 2, - "index": 1226 + "column": 2 } }, "file": "/home/iamdevlinph/projects/iamdevlinph/common-utils-pkg/src/invert-hex-color/invert-hex-color.ts" @@ -964,7 +940,7 @@ }, "type": { "type": "NameExpression", - "name": "String" + "name": "string" } } ], @@ -979,7 +955,7 @@ "children": [ { "type": "text", - "value": "Returns a HEX color string." + "value": "of HEX color." } ] } @@ -988,7 +964,7 @@ "title": "returns", "type": { "type": "NameExpression", - "name": "String" + "name": "string" } } ], @@ -1050,11 +1026,11 @@ }, { "title": "returns", - "description": "Returns an HSL color.", + "description": "of HSL color.", "lineNumber": 6, "type": { "type": "NameExpression", - "name": "String" + "name": "string" } }, { @@ -1066,26 +1042,22 @@ "loc": { "start": { "line": 1, - "column": 0, - "index": 0 + "column": 0 }, "end": { "line": 12, - "column": 3, - "index": 257 + "column": 3 } }, "context": { "loc": { "start": { "line": 13, - "column": 0, - "index": 258 + "column": 0 }, "end": { "line": 18, - "column": 2, - "index": 430 + "column": 2 } }, "file": "/home/iamdevlinph/projects/iamdevlinph/common-utils-pkg/src/random-pastel-color/random-pastel-color.ts" @@ -1109,7 +1081,7 @@ "children": [ { "type": "text", - "value": "Returns an HSL color." + "value": "of HSL color." } ] } @@ -1118,7 +1090,7 @@ "title": "returns", "type": { "type": "NameExpression", - "name": "String" + "name": "string" } } ], @@ -1180,11 +1152,11 @@ }, { "title": "param", - "description": "number of bytes to show", + "description": "of bytes to show", "lineNumber": 6, "type": { "type": "NameExpression", - "name": "Number" + "name": "number" }, "name": "bytes" }, @@ -1196,18 +1168,18 @@ "type": "OptionalType", "expression": { "type": "NameExpression", - "name": "Number" + "name": "number" } }, "name": "decimals" }, { "title": "returns", - "description": "Returns a human readable file size.", + "description": "of human readable file size.", "lineNumber": 8, "type": { "type": "NameExpression", - "name": "String" + "name": "string" } }, { @@ -1219,26 +1191,22 @@ "loc": { "start": { "line": 3, - "column": 0, - "index": 50 + "column": 0 }, "end": { "line": 19, - "column": 3, - "index": 460 + "column": 3 } }, "context": { "loc": { "start": { "line": 20, - "column": 0, - "index": 461 + "column": 0 }, "end": { "line": 30, - "column": 2, - "index": 882 + "column": 2 } }, "file": "/home/iamdevlinph/projects/iamdevlinph/common-utils-pkg/src/readable-bytes/readable-bytes.ts" @@ -1263,7 +1231,7 @@ "children": [ { "type": "text", - "value": "number of bytes to show" + "value": "of bytes to show" } ] } @@ -1271,7 +1239,7 @@ }, "type": { "type": "NameExpression", - "name": "Number" + "name": "number" } }, { @@ -1296,7 +1264,7 @@ "type": "OptionalType", "expression": { "type": "NameExpression", - "name": "Number" + "name": "number" } } } @@ -1312,7 +1280,7 @@ "children": [ { "type": "text", - "value": "Returns a human readable file size." + "value": "of human readable file size." } ] } @@ -1321,7 +1289,7 @@ "title": "returns", "type": { "type": "NameExpression", - "name": "String" + "name": "string" } } ], @@ -1383,21 +1351,21 @@ }, { "title": "param", - "description": "string to convert to slug", + "description": "to convert to slug", "lineNumber": 6, "type": { "type": "NameExpression", - "name": "String" + "name": "string" }, "name": "string" }, { "title": "returns", - "description": "Returns slug version of the string.", + "description": "slug version of the string.", "lineNumber": 7, "type": { "type": "NameExpression", - "name": "String" + "name": "string" } }, { @@ -1409,26 +1377,22 @@ "loc": { "start": { "line": 1, - "column": 0, - "index": 0 + "column": 0 }, "end": { "line": 19, - "column": 3, - "index": 453 + "column": 3 } }, "context": { "loc": { "start": { "line": 21, - "column": 0, - "index": 455 + "column": 0 }, "end": { "line": 39, - "column": 2, - "index": 1301 + "column": 2 } }, "file": "/home/iamdevlinph/projects/iamdevlinph/common-utils-pkg/src/slugify/slugify.ts" @@ -1453,7 +1417,7 @@ "children": [ { "type": "text", - "value": "string to convert to slug" + "value": "to convert to slug" } ] } @@ -1461,7 +1425,7 @@ }, "type": { "type": "NameExpression", - "name": "String" + "name": "string" } } ], @@ -1476,7 +1440,7 @@ "children": [ { "type": "text", - "value": "Returns slug version of the string." + "value": "slug version of the string." } ] } @@ -1485,7 +1449,7 @@ "title": "returns", "type": { "type": "NameExpression", - "name": "String" + "name": "string" } } ], @@ -1554,26 +1518,22 @@ "loc": { "start": { "line": 1, - "column": 0, - "index": 0 + "column": 0 }, "end": { "line": 11, - "column": 3, - "index": 155 + "column": 3 } }, "context": { "loc": { "start": { "line": 12, - "column": 0, - "index": 156 + "column": 0 }, "end": { "line": 12, - "column": 62, - "index": 218 + "column": 62 } }, "file": "/home/iamdevlinph/projects/iamdevlinph/common-utils-pkg/src/storage-clear/storage-clear.ts" @@ -1646,21 +1606,20 @@ }, { "title": "param", - "description": "key to retrieve", + "description": "to retrieve", "lineNumber": 6, "type": { "type": "NameExpression", - "name": "String" + "name": "string" }, "name": "key" }, { "title": "returns", - "description": "Returns data from the local storage. Returns '' if key is not found", + "description": "data from the local storage. Returns '' if key is not found", "lineNumber": 7, "type": { - "type": "NameExpression", - "name": "Any" + "type": "AllLiteral" } }, { @@ -1672,26 +1631,22 @@ "loc": { "start": { "line": 3, - "column": 0, - "index": 35 + "column": 0 }, "end": { "line": 14, - "column": 3, - "index": 306 + "column": 3 } }, "context": { "loc": { "start": { "line": 16, - "column": 0, - "index": 308 + "column": 0 }, "end": { "line": 25, - "column": 2, - "index": 586 + "column": 2 } }, "file": "/home/iamdevlinph/projects/iamdevlinph/common-utils-pkg/src/storage-get/storage-get.ts" @@ -1716,7 +1671,7 @@ "children": [ { "type": "text", - "value": "key to retrieve" + "value": "to retrieve" } ] } @@ -1724,7 +1679,7 @@ }, "type": { "type": "NameExpression", - "name": "String" + "name": "string" } } ], @@ -1739,7 +1694,7 @@ "children": [ { "type": "text", - "value": "Returns data from the local storage. Returns '' if key is not found" + "value": "data from the local storage. Returns '' if key is not found" } ] } @@ -1747,8 +1702,7 @@ }, "title": "returns", "type": { - "type": "NameExpression", - "name": "Any" + "type": "AllLiteral" } } ], @@ -1810,11 +1764,11 @@ }, { "title": "param", - "description": "key of the entry to remove", + "description": "of the entry to remove", "lineNumber": 6, "type": { "type": "NameExpression", - "name": "String" + "name": "string" }, "name": "key" }, @@ -1827,26 +1781,22 @@ "loc": { "start": { "line": 1, - "column": 0, - "index": 0 + "column": 0 }, "end": { "line": 11, - "column": 3, - "index": 204 + "column": 3 } }, "context": { "loc": { "start": { "line": 12, - "column": 0, - "index": 205 + "column": 0 }, "end": { "line": 13, - "column": 38, - "index": 289 + "column": 38 } }, "file": "/home/iamdevlinph/projects/iamdevlinph/common-utils-pkg/src/storage-remove/storage-remove.ts" @@ -1871,7 +1821,7 @@ "children": [ { "type": "text", - "value": "key of the entry to remove" + "value": "of the entry to remove" } ] } @@ -1879,7 +1829,7 @@ }, "type": { "type": "NameExpression", - "name": "String" + "name": "string" } } ], @@ -1947,7 +1897,7 @@ "lineNumber": 6, "type": { "type": "NameExpression", - "name": "String" + "name": "string" }, "name": "key" }, @@ -1969,26 +1919,22 @@ "loc": { "start": { "line": 3, - "column": 0, - "index": 35 + "column": 0 }, "end": { "line": 14, - "column": 3, - "index": 277 + "column": 3 } }, "context": { "loc": { "start": { "line": 15, - "column": 0, - "index": 278 + "column": 0 }, "end": { "line": 16, - "column": 76, - "index": 412 + "column": 76 } }, "file": "/home/iamdevlinph/projects/iamdevlinph/common-utils-pkg/src/storage-set/storage-set.ts" @@ -2021,7 +1967,7 @@ }, "type": { "type": "NameExpression", - "name": "String" + "name": "string" } }, { @@ -2107,31 +2053,31 @@ }, { "title": "param", - "description": "string to convert to array", + "description": "to convert to array", "lineNumber": 6, "type": { "type": "NameExpression", - "name": "String" + "name": "string" }, "name": "string" }, { "title": "param", - "description": "where to split the string", + "description": "character where to split the string", "lineNumber": 7, "type": { "type": "NameExpression", - "name": "String" + "name": "string" }, "name": "delimiter" }, { "title": "returns", - "description": "Returns an array of the split string.", + "description": "of the split string.", "lineNumber": 8, "type": { "type": "NameExpression", - "name": "StringArray" + "name": "array" } }, { @@ -2143,26 +2089,22 @@ "loc": { "start": { "line": 1, - "column": 0, - "index": 0 + "column": 0 }, "end": { "line": 14, - "column": 3, - "index": 402 + "column": 3 } }, "context": { "loc": { "start": { "line": 15, - "column": 0, - "index": 403 + "column": 0 }, "end": { "line": 16, - "column": 26, - "index": 497 + "column": 26 } }, "file": "/home/iamdevlinph/projects/iamdevlinph/common-utils-pkg/src/string-to-array/string-to-array.ts" @@ -2187,7 +2129,7 @@ "children": [ { "type": "text", - "value": "string to convert to array" + "value": "to convert to array" } ] } @@ -2195,7 +2137,7 @@ }, "type": { "type": "NameExpression", - "name": "String" + "name": "string" } }, { @@ -2210,7 +2152,7 @@ "children": [ { "type": "text", - "value": "where to split the string" + "value": "character where to split the string" } ] } @@ -2218,7 +2160,7 @@ }, "type": { "type": "NameExpression", - "name": "String" + "name": "string" } } ], @@ -2233,7 +2175,7 @@ "children": [ { "type": "text", - "value": "Returns an array of the split string." + "value": "of the split string." } ] } @@ -2242,7 +2184,7 @@ "title": "returns", "type": { "type": "NameExpression", - "name": "StringArray" + "name": "array" } } ], @@ -2340,24 +2282,25 @@ }, { "title": "param", - "description": "optional array of user defined true values", + "description": "of user defined true values", "lineNumber": 11, "type": { "type": "OptionalType", "expression": { "type": "NameExpression", - "name": "AnyArray" + "name": "array" } }, - "name": "trueValuesArr" + "name": "trueValuesArr", + "default": "true,'true','yes','y','1',1" }, { "title": "returns", - "description": "Returns a boolean equivalent of the value.", + "description": "equivalent of the value.", "lineNumber": 12, "type": { "type": "NameExpression", - "name": "Boolean" + "name": "boolean" } }, { @@ -2369,26 +2312,22 @@ "loc": { "start": { "line": 3, - "column": 0, - "index": 66 + "column": 0 }, "end": { "line": 23, - "column": 3, - "index": 575 + "column": 3 } }, "context": { "loc": { "start": { "line": 24, - "column": 0, - "index": 576 + "column": 0 }, "end": { "line": 39, - "column": 2, - "index": 911 + "column": 2 } }, "file": "/home/iamdevlinph/projects/iamdevlinph/common-utils-pkg/src/to-boolean/to-boolean.ts" @@ -2435,19 +2374,17 @@ "children": [ { "type": "text", - "value": "optional array of user defined true values" + "value": "of user defined true values" } ] } ] }, "type": { - "type": "OptionalType", - "expression": { - "type": "NameExpression", - "name": "AnyArray" - } - } + "type": "NameExpression", + "name": "array" + }, + "default": "true,'true','yes','y','1',1" } ], "properties": [], @@ -2461,7 +2398,7 @@ "children": [ { "type": "text", - "value": "Returns a boolean equivalent of the value." + "value": "equivalent of the value." } ] } @@ -2470,7 +2407,7 @@ "title": "returns", "type": { "type": "NameExpression", - "name": "Boolean" + "name": "boolean" } } ], @@ -2532,21 +2469,21 @@ }, { "title": "param", - "description": "string to convert to Sentence case", + "description": "to convert to Sentence case", "lineNumber": 6, "type": { "type": "NameExpression", - "name": "String" + "name": "string" }, "name": "string" }, { "title": "returns", - "description": "Returns a Sentence case string.", + "description": "in sentence case.", "lineNumber": 7, "type": { "type": "NameExpression", - "name": "String" + "name": "string" } }, { @@ -2558,26 +2495,22 @@ "loc": { "start": { "line": 1, - "column": 0, - "index": 0 + "column": 0 }, "end": { "line": 13, - "column": 3, - "index": 311 + "column": 3 } }, "context": { "loc": { "start": { "line": 14, - "column": 0, - "index": 312 + "column": 0 }, "end": { "line": 17, - "column": 2, - "index": 473 + "column": 2 } }, "file": "/home/iamdevlinph/projects/iamdevlinph/common-utils-pkg/src/to-sentence-case/to-sentence-case.ts" @@ -2602,7 +2535,7 @@ "children": [ { "type": "text", - "value": "string to convert to Sentence case" + "value": "to convert to Sentence case" } ] } @@ -2610,7 +2543,7 @@ }, "type": { "type": "NameExpression", - "name": "String" + "name": "string" } } ], @@ -2625,7 +2558,7 @@ "children": [ { "type": "text", - "value": "Returns a Sentence case string." + "value": "in sentence case." } ] } @@ -2634,7 +2567,7 @@ "title": "returns", "type": { "type": "NameExpression", - "name": "String" + "name": "string" } } ], @@ -2696,21 +2629,21 @@ }, { "title": "param", - "description": "string to convert to Title Case", + "description": "to convert to Title Case", "lineNumber": 6, "type": { "type": "NameExpression", - "name": "String" + "name": "string" }, "name": "string" }, { "title": "returns", - "description": "Returns a Tile Case string.", + "description": "in Title Case.", "lineNumber": 7, "type": { "type": "NameExpression", - "name": "String" + "name": "string" } }, { @@ -2722,26 +2655,22 @@ "loc": { "start": { "line": 3, - "column": 0, - "index": 47 + "column": 0 }, "end": { "line": 15, - "column": 3, - "index": 344 + "column": 3 } }, "context": { "loc": { "start": { "line": 16, - "column": 0, - "index": 345 + "column": 0 }, "end": { "line": 22, - "column": 6, - "index": 529 + "column": 6 } }, "file": "/home/iamdevlinph/projects/iamdevlinph/common-utils-pkg/src/to-title-case/to-title-case.ts" @@ -2766,7 +2695,7 @@ "children": [ { "type": "text", - "value": "string to convert to Title Case" + "value": "to convert to Title Case" } ] } @@ -2774,7 +2703,7 @@ }, "type": { "type": "NameExpression", - "name": "String" + "name": "string" } } ], @@ -2789,7 +2718,7 @@ "children": [ { "type": "text", - "value": "Returns a Tile Case string." + "value": "in Title Case." } ] } @@ -2798,7 +2727,7 @@ "title": "returns", "type": { "type": "NameExpression", - "name": "String" + "name": "string" } } ], diff --git a/docusaurus.config.ts b/docusaurus.config.ts index fbb0ab4..6b43115 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -114,51 +114,51 @@ const config: Config = { }, ], }, - footer: { - style: 'dark', - links: [ - // { - // title: 'Docs', - // items: [ - // { - // label: 'Tutorial', - // to: '/docs-md/getting-started', - // }, - // ], - // }, - // { - // title: 'Community', - // items: [ - // { - // label: 'Stack Overflow', - // href: 'https://stackoverflow.com/questions/tagged/docusaurus', - // }, - // { - // label: 'Discord', - // href: 'https://discordapp.com/invite/docusaurus', - // }, - // { - // label: 'Twitter', - // href: 'https://twitter.com/docusaurus', - // }, - // ], - // }, - // { - // title: 'More', - // items: [ - // { - // label: 'Blog', - // to: '/blog', - // }, - // { - // label: 'GitHub', - // href: 'https://github.com/facebook/docusaurus', - // }, - // ], - // }, - ], - copyright: `Copyright © ${new Date().getFullYear()} My Project, Inc. Built with Docusaurus.`, - }, + // footer: { + // style: 'dark', + // links: [ + // // { + // // title: 'Docs', + // // items: [ + // // { + // // label: 'Tutorial', + // // to: '/docs-md/getting-started', + // // }, + // // ], + // // }, + // // { + // // title: 'Community', + // // items: [ + // // { + // // label: 'Stack Overflow', + // // href: 'https://stackoverflow.com/questions/tagged/docusaurus', + // // }, + // // { + // // label: 'Discord', + // // href: 'https://discordapp.com/invite/docusaurus', + // // }, + // // { + // // label: 'Twitter', + // // href: 'https://twitter.com/docusaurus', + // // }, + // // ], + // // }, + // // { + // // title: 'More', + // // items: [ + // // { + // // label: 'Blog', + // // to: '/blog', + // // }, + // // { + // // label: 'GitHub', + // // href: 'https://github.com/facebook/docusaurus', + // // }, + // // ], + // // }, + // ], + // // copyright: `Copyright © ${new Date().getFullYear()} My Project, Inc. Built with Docusaurus.`, + // }, prism: { theme: prismThemes.github, darkTheme: prismThemes.dracula, diff --git a/package.json b/package.json index ef3a2c1..a43b7a7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "common-utils-pkg", - "version": "4.1.5", + "version": "4.1.6", "description": "A package of commonly used JavaScript utilities.", "keywords": [ "utilities", diff --git a/scripts/md-generate.mjs b/scripts/md-generate.mjs index 2d02038..52ab3e1 100644 --- a/scripts/md-generate.mjs +++ b/scripts/md-generate.mjs @@ -14,17 +14,17 @@ if (!fs.existsSync(OUTPUT_DIR)) { fs.mkdirSync(OUTPUT_DIR); } // generate the _category_.json for docusaurus again -fs.writeFileSync( - `${OUTPUT_DIR}/_category_.json`, - JSON.stringify({ - label: 'API', - position: 2, - link: { - type: 'generated-index', - description: 'API reference for available methods.', - }, - }) -); +// fs.writeFileSync( +// `${OUTPUT_DIR}/_category_.json`, +// JSON.stringify({ +// label: 'API', +// position: 2, +// link: { +// type: 'generated-index', +// description: 'API reference for available methods.', +// }, +// }) +// ); /** * Get all method paths from src/ diff --git a/src/array-remove-item/array-remove-item.test.ts b/src/array-remove-item/array-remove-item.test.ts index bf92f06..14ce3be 100644 --- a/src/array-remove-item/array-remove-item.test.ts +++ b/src/array-remove-item/array-remove-item.test.ts @@ -1,10 +1,14 @@ import { arrayRemoveItem } from './array-remove-item'; describe('arrayRemoveItem', () => { - it('should remove provided element from the array', () => { + it('should remove provided string from the array of strings', () => { expect(arrayRemoveItem(['apple', 'banana', 'cherry'], 'apple')).toEqual([ 'banana', 'cherry', ]); }); + + it('should remove provided number from the array of numbers', () => { + expect(arrayRemoveItem([2, 4, 1], 4)).toEqual([2, 1]); + }); }); diff --git a/src/array-remove-item/array-remove-item.ts b/src/array-remove-item/array-remove-item.ts index a9b92d8..df3ba1c 100644 --- a/src/array-remove-item/array-remove-item.ts +++ b/src/array-remove-item/array-remove-item.ts @@ -4,15 +4,21 @@ * @version 4.0.8 * @module Array * @name arrayRemoveItem - * @param {array} array of strings to remove element from - * @param {string} toRemove to remove from the array - * @returns {array} of strings without the removed element. + * @param {array} array of strings | numbers to remove element from + * @param {string | number} toRemove to remove from the array + * @returns {array} without the removed element. * @example * * arrayRemoveItem(['The', 'quick', 'brown'], 'The'); * // => ['quick', 'brown'] + * + * arrayRemoveItem([2, 4, 1], 4); + * // => [2, 1] */ -export const arrayRemoveItem = (array: string[], toRemove: string) => { +export const arrayRemoveItem = ( + array: T[], + toRemove: T +) => { return array.filter((item) => item !== toRemove); };