{"id":24001716,"url":"https://github.com/p-rk/js-utility-functions","last_synced_at":"2025-09-01T18:34:05.747Z","repository":{"id":57283802,"uuid":"125971774","full_name":"p-rk/js-utility-functions","owner":"p-rk","description":null,"archived":false,"fork":false,"pushed_at":"2023-03-01T18:25:25.000Z","size":911,"stargazers_count":4,"open_issues_count":9,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-09T22:49:55.099Z","etag":null,"topics":["babel","es6","functions","javascript","javascript-helpers","js","js-functions"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/p-rk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-03-20T06:34:53.000Z","updated_at":"2022-11-18T07:20:02.000Z","dependencies_parsed_at":"2024-11-18T00:16:53.752Z","dependency_job_id":null,"html_url":"https://github.com/p-rk/js-utility-functions","commit_stats":{"total_commits":37,"total_committers":3,"mean_commits":"12.333333333333334","dds":0.05405405405405406,"last_synced_commit":"a1c23fd2dfa2ebf135eb0df8dd195e96c6b216c3"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p-rk%2Fjs-utility-functions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p-rk%2Fjs-utility-functions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p-rk%2Fjs-utility-functions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/p-rk%2Fjs-utility-functions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/p-rk","download_url":"https://codeload.github.com/p-rk/js-utility-functions/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248975316,"owners_count":21192210,"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":["babel","es6","functions","javascript","javascript-helpers","js","js-functions"],"created_at":"2025-01-08T00:37:38.831Z","updated_at":"2025-04-14T23:10:37.099Z","avatar_url":"https://github.com/p-rk.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# Javascript Utility functions\n\n[![npm][npm]][npm-url] \n[![Build Status](https://travis-ci.org/p-rk/js-utility-functions.svg?branch=master)](https://travis-ci.org/p-rk/js-utility-functions)\n[![Coverage Status](https://coveralls.io/repos/github/p-rk/js-utility-functions/badge.svg?branch=master)](https://coveralls.io/github/p-rk/js-utility-functions?branch=master)\n\n\n## Example\n\n```shell\n\n$ npm install js-utility-functions --save\n\n```\n\n## Available functions\n\n * Title Case a string\n * Convert String to an Array [Optional Remove Spaces]\n * Count Instance in an array\n * Sum of an Array [Optional Add Initial Value]\n\n * Validate Name\n * Validate Mobile number\n * Validate email\n * Validate Option\n\n```Javascript\n\n// ES 2015\nimport { titleCaseString } from 'js-utility-functions';\n\nconst formattedText = titleCaseString('hello world');\n\nconsole.log(formattedText);\n\n// Output: Hello World\n\n```\n- - - -\n\n```Javascript\n\nimport { convertStringToArray } from 'js-utility-functions';\n\nlet x = convertStringToArray('hello');\n\nNote: Second argument to convertStringToArray is optional for removing spaces default: false\n\nconsole.log(x);\n\n// Output : ['h', 'e', 'l', 'l', 'o']\n\n* Extra Remove Spaces\n\nlet y = convertStringToArray('hello world', true); // if passed true then it removes spaces\n\nconsole.log(y);\n\n// Output : ['h', 'e', 'l', 'l', 'o', 'w', 'o', 'r', 'l', 'd']\n\n```\n\n- - - -\n\n```Javascript\n\nimport { countInstanceInArray } from 'js-utility-functions';\n\nlet data = ['rama', 'dan', 'wes', 'rama', 'dan', 'wes', 'cooper', 'mark'];\n\nlet x = countInstanceInArray(data); // this will count no of times each element in array is repeated\n\nconsole.log(x);\n\n// Output : {rama: 2, dan: 2, wes: 2, cooper: 1, mark: 1}\n\n```\n\n- - - -\n\n```Javascript\n\nimport { sumOfAnArray } from 'js-utility-functions';\n\nlet data = [1, 2, 3, 4, 5, 6];\n\nlet x = sumOfAnArray(data); // this will add up all elements in an array and returns sumOfAnArray\n\n// Second argument is optional and default is 0 .\n\nconsole.log(x);\n\n// Output : 21\n\n* Extra Add Intial Value\n\n// if you want to add up some initial value you can do so by passing second argument value\n\nlet x = sumOfAnArray(data, 10);\n\nconsole.log(x);\n\n// Output : 31\n\n```\n\n- - - -\n\n```Javascript\n\nimport { validateName } from 'js-utility-functions';\n\nlet x = validateName(\"ra\", \"Enter Valid Name\", 3);\n// First argument is value\n// Second argument is your custom error message\n// Third argument is length of the value you want to validate (optional)\nconsole.log(x);\n\n// Output : {error: true, errorMessage: 'Enter Valid Name'}\n\n\nimport { validateMobile } from 'js-utility-functions';\n\nlet x = validateMobile(9999999999, 'Enter Valid Mobile Number');\n\n//validate 10 digit mobile number\n\nconsole.log(x);\n\n// Output : {error: false, errorMessage: ''}\n\n\nimport { validateEmail } from 'js-utility-functions';\n\nlet x = validateMobile('rama.ped', 'Enter Valid Email ID');\n\n//validate 10 digit mobile number\n\nconsole.log(x);\n\n// Output : {error: true, errorMessage: 'Enter Valid Email ID'}\n\n\nimport { validateOption } from 'js-utility-functions';\n\nlet x = validateOption('option', 'Select Valid Option');\n\n//validate an option select\n\nconsole.log(x);\n\n// Output : {error: false, errorMessage: ''}\n\n\nFor All Validation functions return following object\n\n  Error Case:\n\n  {error: true, errorMessage: 'Your custom message that is passed'}\n\n  No Error Case:\n\n  {error: false, errorMessage: ''}\n\n```\n\n## License\n\nMIT\n\n[npm]: https://img.shields.io/npm/v/js-utility-functions.svg\n[npm-url]: https://www.npmjs.com/package/js-utility-functions\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp-rk%2Fjs-utility-functions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fp-rk%2Fjs-utility-functions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fp-rk%2Fjs-utility-functions/lists"}