{"id":21885523,"url":"https://github.com/iamdevlinph/common-utils-pkg","last_synced_at":"2025-04-15T07:40:54.643Z","repository":{"id":33819410,"uuid":"138673717","full_name":"iamdevlinph/common-utils-pkg","owner":"iamdevlinph","description":"A package of commonly used utilities","archived":false,"fork":false,"pushed_at":"2024-12-05T01:51:36.000Z","size":2260,"stargazers_count":5,"open_issues_count":6,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-12T06:18:55.472Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://common-utils-pkg.js.org/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iamdevlinph.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-26T02:23:39.000Z","updated_at":"2025-04-04T07:12:45.000Z","dependencies_parsed_at":"2024-06-21T18:56:42.568Z","dependency_job_id":"b8f1e617-5e42-47a4-85f6-04c3a5700462","html_url":"https://github.com/iamdevlinph/common-utils-pkg","commit_stats":{"total_commits":337,"total_committers":2,"mean_commits":168.5,"dds":"0.014836795252225476","last_synced_commit":"3425f33652a02ce226371355f9d8a28b68955ad9"},"previous_names":[],"tags_count":31,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamdevlinph%2Fcommon-utils-pkg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamdevlinph%2Fcommon-utils-pkg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamdevlinph%2Fcommon-utils-pkg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iamdevlinph%2Fcommon-utils-pkg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iamdevlinph","download_url":"https://codeload.github.com/iamdevlinph/common-utils-pkg/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249030262,"owners_count":21201220,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-28T10:24:36.737Z","updated_at":"2025-04-15T07:40:54.638Z","avatar_url":"https://github.com/iamdevlinph.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Common Utilities Package\n\nA package of commonly used JavaScript utilities.\n\n[Site](https://iamdevlinph.github.io/common-utils-pkg/) | [Docs](https://iamdevlinph.github.io/common-utils-pkg/docs.html)\n\n#### Package Details\n\n[![npm version][npm-img]][npm-url]\n[![node version][node-img]][node-url]\n[![coverage][codecov-img]][codecov-url]\n[![downloads][downloads-img]][downloads-url]\n\n#### Repo Details\n\n[![open issues][issues-img]][issues-url]\n[![open prs][pr-img]][pr-url]\n![code size](https://img.shields.io/github/languages/code-size/iamdevlinph/common-utils-pkg.svg?style=flat-square\u0026maxAge=7200)\n[![contributors][contributor-img]][contributor-url]\n\n# :tada: `v4` is here\n\nv4 is just migrating the code base to TypeScript. Kindly refer to the [changelog](https://common-utils-pkg.js.org/changelog) for more info.\n\n## `v3` is here\n\nVersion 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).\n\n## Installation\nNPM\n```\nnpm i --save common-utils-pkg\n```\nYarn\n```\nyarn add common-utils-pkg\n```\n\n## Usage\n\n### ES6\n\n```\n// Specific methods\n\nimport { randomPastelColor } from 'common-utils-pkg';\nrandomPastelColor();\n```\n\n```\n// All methods\n\nimport * as UTILS from 'common-utils-pkg';\nUTILS.randomPastelColor();\n```\n\n### Browser\n\n```\n\u003cscript src=\"https://unpkg.com/common-utils-pkg\"\u003e\u003c/script\u003e\n\u003cscript\u003e\n  // Specific methods\n\n  const randomPastelColor = window['common-utils-pkg].randomPastelColor;\n  randomPastelColor();\n\u003c/script\u003e\n```\n\n```\n\u003cscript\u003e\n  // All methods\n\n  const UTILS = window['common-utils-pkg'];\n  UTILS.randomPastelColor();\n\u003c/script\u003e\n```\n\nRead more about the usage [here](https://iamdevlinph.github.io/common-utils-pkg/usage.html)\n\n## Available Methods\n\nRead more about the methods available [here](https://iamdevlinph.github.io/common-utils-pkg/docs.html)\n\n## Features\n* Transpile ES6 to ES5 using [Babel](https://github.com/babel/babel)\n* 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)\n* Create the bundle using [webpack](https://github.com/webpack/webpack)\n* Run tests using [Mocha](https://github.com/mochajs/mocha) and [chai](https://github.com/chaijs/chai)\n* Lint stuff using [ESLint](https://github.com/eslint/eslint)\n* Build status by [Travis](https://github.com/travis-ci/travis-ci)\n* Precommit using [lint-staged](https://github.com/okonet/lint-staged) and [husky](https://github.com/typicode/husky)\n* Provides TypeScript type definitions\n\u003c!-- ![typedef](./docs/img/ts-type-def.png) --\u003e\n\n# Contributing\n1.Create a folder under `src/` and name the folder with the same name as the method.\n\n2.Create `methodName.js` and `methodName.spec.js`\n\nThe full directory should look like this:\n```\nsrc/\n  methodName/\n    - methodName.js\n    - methodName.spec.js\n```\n\n3.If the method you are authoring has expected parameters then import `expects`\n\n```js\nimport expects from '../expects/expects';\n```\n\nWrap your exported function with `expects`\n```js\nexport default expects(\n  methodName,\n  'methodName',\n  { // required parameters\n    0: 'string', // 1st parameter is required and is a string\n    1: 'number', // 2nd parameter is required and is a number\n  },\n  { // optional parameters\n    2: 'number' // 3rd parameter is optional but is a number\n  }\n)\n```\n\n# Publishing\n\n### Publish to NPM\n\nTo publish version, just create a relase tag and a github workflow will automatically handle the publishing to npm.\n\n### Publish doc updates\nDoc updates should be automatically be deployed once merged to main by github action.\n\n\u003c!-- 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). --\u003e\n\n\u003c!-- ## Commands\nRun by `npm run \u003cscript\u003e`\n* `build:clean` - Deletes the build folder.\n* `build` - Builds `dev` and `prod` ready files.\n* `cover:serve` - Serve the coverage report page. Open at `http://localhost:8080/`.\n* `cover` - Run coverage tool.\n* `docu:serve` - Serve the documentation page. Open at `http://localhost:8080/`.\n* `docu` - Generated a `.json` documentation file that will be used by the `docs.html` page.\n* `lint:install` - Install precommit related tools. It sometimes doesn't install properly.\n* `lint` - Runs the ESLint linter on the `src/` folder.\n* `precommit` - The precommit hook which runs `lint-staged` to lint staged files on commit.\n* `prepare` - Runs `build` before publishing a new version of the package.\n* `test:watch` - Re-run tests on file changes.\n* `test` - Run the tests --\u003e\n\n\u003c!-- ## To Do's\n- [ ] Immutable arrays and objects\n- [ ] Update `takes(func, [...required])` to `takes(func, [...required], [...optional])`\n- [ ] Update `takes` to support `typeof` `any`\n- [ ] Update `argTypesMatch` to support `typeof` `any` --\u003e\n\n[contributor-img]: https://img.shields.io/github/contributors/iamdevlinph/common-utils-pkg.svg?style=flat-square\u0026maxAge=7200\n[contributor-url]: https://github.com/iamdevlinph/common-utils-pkg/graphs/contributors\n[deps-img]: https://img.shields.io/david/iamdevlinph/common-utils-pkg.svg?style=flat-square\u0026maxAge=7200\n[deps-url]: https://david-dm.org/iamdevlinph/common-utils-pkg\n[devdeps-img]: https://img.shields.io/david/dev/iamdevlinph/common-utils-pkg.svg?style=flat-square\u0026maxAge=7200\n[devdeps-url]: https://david-dm.org/iamdevlinph/common-utils-pkg?type=dev\n[downloads-img]: https://img.shields.io/npm/dm/common-utils-pkg.svg?style=flat-square\u0026maxAge=7200\n[downloads-url]: https://npmcharts.com/compare/common-utils-pkg?minimal=true\n[issues-img]: https://img.shields.io/github/issues/iamdevlinph/common-utils-pkg.svg?style=flat-square\u0026maxAge=7200\n[issues-url]: https://github.com/iamdevlinph/common-utils-pkg/issues\n[node-img]: https://img.shields.io/node/v/common-utils-pkg.svg?style=flat-square\u0026maxAge=7200\n[node-url]: https://nodejs.org/en/\n[npm-img]: https://img.shields.io/npm/v/common-utils-pkg.svg?style=flat-square\u0026maxAge=7200\n[npm-url]: https://www.npmjs.com/package/common-utils-pkg\n[pr-img]: https://img.shields.io/github/issues-pr/iamdevlinph/common-utils-pkg.svg?style=flat-square\u0026maxAge=7200\n[pr-url]: https://github.com/iamdevlinph/common-utils-pkg/pulls\n[travis-img]: https://img.shields.io/travis/iamdevlinph/common-utils-pkg/master.svg?style=flat-square\u0026maxAge=7200\n[travis-url]: https://travis-ci.org/iamdevlinph/common-utils-pkg\n[codecov-img]: https://img.shields.io/codecov/c/github/iamdevlinph/common-utils-pkg.svg?style=flat-square\u0026maxAge=7200\n[codecov-url]: https://codecov.io/gh/iamdevlinph/common-utils-pkg\n[forks-img]: https://img.shields.io/github/forks/iamdevlinph/common-utils-pkg.svg?style=social\u0026label=Fork\u0026maxAge=7200\n[forks-url]: https://github.com/iamdevlinph/common-utils-pkg/network/members\n[stars-img]: https://img.shields.io/github/stars/iamdevlinph/common-utils-pkg.svg?style=social\u0026label=Stars\u0026maxAge=7200\n[stars-url]: https://github.com/iamdevlinph/common-utils-pkg/stargazers\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamdevlinph%2Fcommon-utils-pkg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiamdevlinph%2Fcommon-utils-pkg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiamdevlinph%2Fcommon-utils-pkg/lists"}