A package of commonly used JavaScript utilities.
npm install common-utils-pkgA package of commonly used JavaScript utilities.
#### Package Details
[![npm version][npm-img]][npm-url]
[![node version][node-img]][node-url]
[![coverage][codecov-img]][codecov-url]
[![downloads][downloads-img]][downloads-url]
#### Repo Details
[![open issues][issues-img]][issues-url]
[![open prs][pr-img]][pr-url]
!code size
[![contributors][contributor-img]][contributor-url]
v4 is herev4 is just migrating the code base to TypeScript. Kindly refer to the changelog for more info.
v3 is hereVersion 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.
NPM
```
npm i --save common-utils-pkg
Yarn
``
yarn add common-utils-pkg
`
// Specific methods
import { randomPastelColor } from 'common-utils-pkg';
randomPastelColor();
`
`
// All methods
import * as UTILS from 'common-utils-pkg';
UTILS.randomPastelColor();
`
``
``
Read more about the usage here
Read more about the methods available here
- Transpile ES6 to ES5 using Babel
- Coverage using Istanbul with nyc and report by Codecov
- Create the bundle using webpack
- Run tests using Mocha and chai
- Lint stuff using ESLint
- Build status by Travis
- Precommit using lint-staged and husky
- Provides TypeScript type definitions
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/
- methodName.js
- methodName.spec.js
3.If the method you are authoring has expected parameters then import expects
`js`
import expects from '../expects/expects';
Wrap your exported function with expects
`js`
export default expects(
methodName,
'methodName',
{
// 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
}
);
- yarn docusaurus:generate - generate new files. Will auto refresh pageyarn docusaurus:start
- - start up the docu page
To publish version, just create a relase tag and a github workflow will automatically handle the publishing to npm.
Doc updates should be automatically be deployed once merged to main by github action.
[contributor-img]: https://img.shields.io/github/contributors/iamdevlinph/common-utils-pkg.svg?style=flat-square&maxAge=7200
[contributor-url]: https://github.com/iamdevlinph/common-utils-pkg/graphs/contributors
[deps-img]: https://img.shields.io/david/iamdevlinph/common-utils-pkg.svg?style=flat-square&maxAge=7200
[deps-url]: https://david-dm.org/iamdevlinph/common-utils-pkg
[devdeps-img]: https://img.shields.io/david/dev/iamdevlinph/common-utils-pkg.svg?style=flat-square&maxAge=7200
[devdeps-url]: https://david-dm.org/iamdevlinph/common-utils-pkg?type=dev
[downloads-img]: https://img.shields.io/npm/dm/common-utils-pkg.svg?style=flat-square&maxAge=7200
[downloads-url]: https://npmcharts.com/compare/common-utils-pkg?minimal=true
[issues-img]: https://img.shields.io/github/issues/iamdevlinph/common-utils-pkg.svg?style=flat-square&maxAge=7200
[issues-url]: https://github.com/iamdevlinph/common-utils-pkg/issues
[node-img]: https://img.shields.io/node/v/common-utils-pkg.svg?style=flat-square&maxAge=7200
[node-url]: https://nodejs.org/en/
[npm-img]: https://img.shields.io/npm/v/common-utils-pkg.svg?style=flat-square&maxAge=7200
[npm-url]: https://www.npmjs.com/package/common-utils-pkg
[pr-img]: https://img.shields.io/github/issues-pr/iamdevlinph/common-utils-pkg.svg?style=flat-square&maxAge=7200
[pr-url]: https://github.com/iamdevlinph/common-utils-pkg/pulls
[travis-img]: https://img.shields.io/travis/iamdevlinph/common-utils-pkg/master.svg?style=flat-square&maxAge=7200
[travis-url]: https://travis-ci.org/iamdevlinph/common-utils-pkg
[codecov-img]: https://img.shields.io/codecov/c/github/iamdevlinph/common-utils-pkg.svg?style=flat-square&maxAge=7200
[codecov-url]: https://codecov.io/gh/iamdevlinph/common-utils-pkg
[forks-img]: https://img.shields.io/github/forks/iamdevlinph/common-utils-pkg.svg?style=social&label=Fork&maxAge=7200
[forks-url]: https://github.com/iamdevlinph/common-utils-pkg/network/members
[stars-img]: https://img.shields.io/github/stars/iamdevlinph/common-utils-pkg.svg?style=social&label=Stars&maxAge=7200
[stars-url]: https://github.com/iamdevlinph/common-utils-pkg/stargazers