Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/code-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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') }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-github-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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') }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/format-check-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Running lint checks and build
on:
push:
branches-ignore:
- 'main'
- "main"

jobs:
setup:
Expand All @@ -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
Expand All @@ -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') }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Running code tests
on:
push:
branches-ignore:
- 'main'
- "main"

jobs:
setup:
Expand All @@ -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
Expand All @@ -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') }}
Expand Down
40 changes: 28 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand Down Expand Up @@ -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
<!-- ![typedef](./docs/img/ts-type-def.png) -->

# 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/
Expand All @@ -112,27 +119,36 @@ 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

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.

<!-- Have something to pitch in? Open a [pull request](https://github.com/iamdevlinph/common-utils-pkg/pulls) or an [issue](https://github.com/iamdevlinph/common-utils-pkg/issues/new). -->
Expand Down
13 changes: 9 additions & 4 deletions docs-md/api/arrayRemoveItem.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**

Expand All @@ -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)
* Source: [array-remove-item.ts](https://github.com/iamdevlinph/common-utils-pkg/blob/main/src/array-remove-item/array-remove-item.ts#L19-L24)
4 changes: 4 additions & 0 deletions docs-md/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ id: changelog

# Changelog

##### 4.1.6

- Update `arrayRemoveItem` to support number

##### 4.1.5

- TODO: Switch to pnpm
Expand Down
Loading
Loading