{"id":16818570,"url":"https://github.com/rubiin/helper-fns","last_synced_at":"2026-02-12T22:04:41.544Z","repository":{"id":41469080,"uuid":"331324613","full_name":"rubiin/helper-fns","owner":"rubiin","description":"Handy js utilities","archived":false,"fork":false,"pushed_at":"2025-07-19T01:15:14.000Z","size":1087,"stargazers_count":10,"open_issues_count":9,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-19T05:59:45.770Z","etag":null,"topics":["javascript","lodash","typescript","underscore","utilities"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/rubiin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null},"funding":{"github":["rubiin"],"patreon":null,"open_collective":null,"ko_fi":"rubiin","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"buy_me_a_coffee":"rubiin","thanks_dev":"rubiin"}},"created_at":"2021-01-20T14:04:48.000Z","updated_at":"2025-04-12T23:04:07.000Z","dependencies_parsed_at":"2023-02-16T22:15:47.967Z","dependency_job_id":"c59c47dd-feb1-4e86-81e3-126d87284559","html_url":"https://github.com/rubiin/helper-fns","commit_stats":{"total_commits":48,"total_committers":2,"mean_commits":24.0,"dds":0.125,"last_synced_commit":"bc4c7a19e0d08bb5aa08f34d484214a316af7319"},"previous_names":[],"tags_count":98,"template":false,"template_full_name":null,"purl":"pkg:github/rubiin/helper-fns","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubiin%2Fhelper-fns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubiin%2Fhelper-fns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubiin%2Fhelper-fns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubiin%2Fhelper-fns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rubiin","download_url":"https://codeload.github.com/rubiin/helper-fns/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubiin%2Fhelper-fns/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266726615,"owners_count":23974926,"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","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["javascript","lodash","typescript","underscore","utilities"],"created_at":"2024-10-13T10:50:31.784Z","updated_at":"2026-02-12T22:04:36.521Z","avatar_url":"https://github.com/rubiin.png","language":"TypeScript","funding_links":["https://github.com/sponsors/rubiin","https://ko-fi.com/rubiin","https://buymeacoffee.com/rubiin","https://thanks.dev/rubiin"],"categories":[],"sub_categories":[],"readme":"# helper-fns\n\n\u003e JavaScript Utilities\n\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/rubiin/js-utils/actions/workflows/release.yml\"\u003e\u003cimg src=\"https://github.com/rubiin/js-utils/actions/workflows/release.yml/badge.svg\" alt=\"Build\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://img.shields.io/npm/v/helper-fns\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/helper-fns\" alt=\"NPM Version\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://img.shields.io/npm/l/helper-fns\"\u003e\u003cimg src=\"https://img.shields.io/npm/l/helper-fns\" alt=\"Package License\" /\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/helper-fns\"\u003e\u003cimg src=\"https://img.shields.io/npm/dm/helper-fns\" alt=\"NPM Downloads\" /\u003e\u003c/a\u003e\n\n\n# INSTALLAION\n\n```\nnpm i helper-fns\nyarn add helper-fns\n\n```\n\nCommon JavaScript packages and utilities used across my projects.\n\n# isEmpty\n\nChecks if the a value is an empty object/collection, has no enumerable properties or is any type that is not considered a collection.\n\n```js\nisEmpty([]) // true\nisEmpty({}) // true\nisEmpty('') // true\nisEmpty([1, 2]) // false\nisEmpty({ a: 1, b: 2 }) // false\nisEmpty('text') // false\nisEmpty(123) // false - type is not considered a collection\nisEmpty(true) // false\n```\n\n# orderedToken\n\nGenerates token based on user defined format\n\n```js\norderedToken('RU-XXXXX') // RU-16891\n```\n\n\n# pick\n\nPicks the key-value pairs corresponding to the given keys from an object.\n\n```js\npick({ a: 1, b: '2', c: 3 }, ['a', 'c']) // { 'a': 1, 'c': 3 }\n```\n\n# omit\n\nOmits the key-value pairs corresponding to the given keys from an object.\n\n```js\nomit({ a: 1, b: '2', c: 3 }, ['b']) // { 'a': 1, 'c': 3 }\n```\n\n# sumOfAnArray\n\nCalculates the sum of two or more numbers/arrays.\n\n```js\nsumOfAnArray(1, 2, 3, 4) // 10\n```\n\n# pipeFunctions\n\nPerforms left-to-right function composition.\n\n```js\nconst add5 = x =\u003e x + 5\nconst multiply = (x, y) =\u003e x * y\nconst multiplyAndAdd5 = pipeFunctions(multiply, add5)\nmultiplyAndAdd5(5, 2) // 15\n```\n\n# renameKeys\n\nReplaces the names of multiple object keys with the values provided.\n\n```js\nconst obj = { name: 'Bobo', job: 'Front-End Master', shoeSize: 100 }\nrenameKeys({ name: 'firstName', job: 'passion' }, obj)\n// { firstName: 'Bobo', passion: 'Front-End Master', shoeSize: 100 }\n```\n\n# objectArrayToArray\n\nCreates an array of key-value pair arrays from an object.\n\n```js\nobjectToEntries({ a: 1, b: 2 }) // [ ['a', 1], ['b', 2] ]\n```\n\n# clone\n\nCreates a shallow clone of value.\n\n```js\nconst objects = [{ a: 1 }, { b: 2 }]\n\nconst shallow = clone(objects)\nconsole.log(shallow[0] === objects[0])\n```\n\n# difference\n\nCalculates the difference between two arrays, without filtering duplicate values.\n\n```js\ndifference([1, 2, 3, 3], [1, 2, 4]) // [3, 3]\n```\n\n# union\n\nReturns every element that exists in any of the two arrays at least once.\n\n```js\nunion([1, 2, 3], [4, 3, 2]) // [1, 2, 3, 4]\n```\n\n# isDate\n\nChecks if gicen string is date\n\n```js\nconsole.log(isDate('not-date'))\n// false\n\nconsole.log(isDate('2019-01-10'))\n// true\n```\n\n# groupBy\n\nGroups the elements of an array based on the given function.\n\n```js\ngroupBy([6.1, 4.2, 6.3], Math.floor) // {4: [4.2], 6: [6.1, 6.3]}\ngroupBy(['one', 'two', 'three'], 'length') // {3: ['one', 'two'], 5: ['three']}\n```\n\n# orderBy\n\nSorts an array of objects, ordered by properties and orders.\n\n```js\nconst users = [\n  { name: 'fred', age: 48 },\n  { name: 'barney', age: 36 },\n  { name: 'fred', age: 40 },\n]\norderBy(users, ['name', 'age'], ['asc', 'desc'])\n// [{name: 'barney', age: 36}, {name: 'fred', age: 48}, {name: 'fred', age: 40}]\norderBy(users, ['name', 'age'])\n// [{name: 'barney', age: 36}, {name: 'fred', age: 40}, {name: 'fred', age: 48}]\n```\n\n# randomNumber\n\nGenerates random number of between a min number and a max number.\n\n\n```js\nconsole.log(randomNumber(0, 6)) // integer between 0 and 6\n// 5\n```\n\n\n# enumToString\n\nGenerates random number of between a min number and a max number.\n\n```ts\nexport enum AppRoles {\n  AUTHOR = 'AUTHOR',\n  ADMIN = 'ADMIN'\n}\n\nconsole.log(enumToString(AppRoles))\n// [\"AUTHOR\", \"ADMIN\"]\n```\n\n# randomString\n\nGenerates random string of giben length\n\n```js\nconsole.log(randomString(6))\n// a1t4ry\n```\n\n# strAfter\n\nGet string after a substring\n\n```js\nstrAfter('pineapple', 'pine') // apple\n```\n\n# strBefore\n\nGet string before a substring\n\n```js\nstrBefore('pineapple', 'apple') // pine\n```\n\n\n# isObject\n\nChecks if the passed value is an object or not.\n\n```js\nisObject([1, 2, 3, 4]) // true\nisObject([]) // true\nisObject(['Hello!']) // true\nisObject({ a: 1 }) // true\nisObject({}) // true\nisObject(true) // false\n```\n\n# fixedDecimal\n\nGet a number after truncating it from the decimal point. No round off is done\n\n```js\nfixedDecimal(3.141525, 3) // 3.141\n```\n\n# generateRandomString\n\nGet a random string of defined length\n\n```js\ngenerateRandomString(6) // fd84bg\n```\n\n# slugify\n\nGenerate a slug from a string\n\n```js\nslugify('i love javascript') // i-love-javascript\n```\n\n# capitalizeEveryWord\n\n```js\ncapitalizeEveryWord('hello world!') // 'Hello World!'\n```\n\n# throttle\n\n```js\nwindow.addEventListener(\n  'resize',\n  throttle((evt) =\u003e {\n    console.log(window.innerWidth)\n    console.log(window.innerHeight)\n  }, 250),\n) // Will log the window dimensions at most every 250ms\n```\n\n# unescapeHTML\n\n```js\nunescapeHTML('\u0026lt;a href=\u0026quot;#\u0026quot;\u0026gt;Me \u0026amp; you\u0026lt;/a\u0026gt;')\n// '\u003ca href=\"#\"\u003eMe \u0026 you\u003c/a\u003e'\n```\n\n# timeTaken\n\n```js\ntimeTaken(() =\u003e 2 ** 10) // 1024, (logged): timeTaken: 0.02099609375ms\n```\n\n# formatDuration\n\n```js\nformatDuration(1001) // '1 second, 1 millisecond'\nformatDuration(34325055574)\n// '397 days, 6 hours, 44 minutes, 15 seconds, 574 milliseconds'\n```\n\n# template\n\n```js\ntemplate('Hello, {{name}}!', { name: 'world' })\n// =\u003e Hello, world!\n\ntemplate('Howdy, {{0}}! {{1}}', ['partner', '🤠'])\n// =\u003e Howdy, partner! 🤠\n\ntemplate('foo: \"{{foo}}\"; bar: \"{{bar}}\";', { foo: 123 })\n// =\u003e foo: \"123\"; bar: \"\";\n\ntemplate(\n\t`\n  Name: {{name.last}}, {{name.first}}\n  Location: {{address.city}} ({{address.country}})\n  Hobbies: {{hobbies.0}}, {{hobbies.1}}, {{hobbies.2}}\n`,\n\t{\n\t  name: {\n\t    first: 'Luke',\n\t    last: 'Edwards',\n\t  },\n\t  address: {\n\t    city: 'Los Angeles',\n\t    country: 'USA',\n\t  },\n\t  hobbies: ['eat', 'sleep', 'repeat'],\n\t},\n)\n```\n\n# encrypt and decrypt\n\n```\n  console.log(encrypt('hello','32 bytes hex key','16 bytes hex iv'))\n  // p5HX3eMlroLYJPhXr2zARg==\n\n console.log(decrypt('p5HX3eMlroLYJPhXr2zARg==','32 bytes hex key','16 bytes hex iv'))\n// hello\n\n```\n\n## Contributing\n\nAny types of contributions are welcome. Feel free to send pull requests or create issues.\n\n## License\n\nLicensed under [The MIT License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubiin%2Fhelper-fns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubiin%2Fhelper-fns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubiin%2Fhelper-fns/lists"}