{"id":24698440,"url":"https://github.com/zero-dependency/utils","last_synced_at":"2025-03-22T03:41:34.374Z","repository":{"id":109547499,"uuid":"551466237","full_name":"zero-dependency/utils","owner":"zero-dependency","description":"🛠 Additional utilities","archived":false,"fork":false,"pushed_at":"2024-06-09T14:04:31.000Z","size":124,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-27T04:18:30.376Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/zero-dependency.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2022-10-14T13:01:58.000Z","updated_at":"2024-06-09T14:04:34.000Z","dependencies_parsed_at":"2023-04-06T10:26:17.883Z","dependency_job_id":"39f466a9-5375-45d3-98f9-212b4851ae9f","html_url":"https://github.com/zero-dependency/utils","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":"zero-dependency/template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zero-dependency%2Futils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zero-dependency%2Futils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zero-dependency%2Futils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zero-dependency%2Futils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zero-dependency","download_url":"https://codeload.github.com/zero-dependency/utils/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244902929,"owners_count":20529114,"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":"2025-01-27T04:18:34.984Z","updated_at":"2025-03-22T03:41:34.346Z","avatar_url":"https://github.com/zero-dependency.png","language":"TypeScript","readme":"# @zero-dependency/utils\n\n[![npm version](https://img.shields.io/npm/v/@zero-dependency/utils)](https://npm.im/@zero-dependency/utils)\n[![npm bundle size (scoped)](https://img.shields.io/bundlephobia/minzip/@zero-dependency/utils)](https://bundlephobia.com/package/@zero-dependency/utils@latest)\n![npm license](https://img.shields.io/npm/l/@zero-dependency/utils)\n\n## Installation\n\n```sh\nnpm install @zero-dependency/utils\n```\n\n```sh\nyarn add @zero-dependency/utils\n```\n\n```sh\npnpm add @zero-dependency/utils\n```\n\n## Usage\n\n```ts\nimport {\n  hexToRgb,\n  rgbToHex,\n  isHexColor,\n  debounce,\n  throttle,\n  toNumber,\n  addZero,\n  entries,\n  pick,\n  omit,\n  pluralize,\n  randomNum,\n  randomToken,\n  generateChars,\n  capitalize\n  wait,\n  match\n} from '@zero-dependency/utils'\n\n// hex\nconsole.log(hexToRgb('#000')) // { r: 0, g: 0, b: 0 }\nconsole.log(rgbToHex({ r: 0, g: 0, b: 0 })) // #000000\nconsole.log(isHexColor('#000')) // RegExpExecArray\nconsole.log(isHexColor('wrong')) // null\n\n// debounce\nconst debounced = debounce((msg) =\u003e console.log(msg), 1000)\n\n// throttle\nconst throttled = throttle((msg) =\u003e console.log(msg), 1000)\n\n// number\nconsole.log(toNumber('1')) // 1\nconsole.log(addZero(1)) // '01'\nconsole.log(randomNum(1, 10))\n\n// object\nconsole.log(entries({ a: 1, b: 2 })) // [['a', 1], ['b', 2]]\nconsole.log(pick({ a: 1, b: 2 }, ['a'])) // { a: 1 }\nconsole.log(omit({ a: 1, b: 2 }, ['a'])) // { b: 2 }\n\n// pluralize\nconst tasksPluralize = pluralize({\n  one: 'задание',\n  two: 'задания',\n  few: 'заданий',\n  prefix: true\n})\n\nconsole.log(tasksPluralize(1)) // '1 задание'\nconsole.log(tasksPluralize(3)) // '3 задания'\nconsole.log(tasksPluralize(5)) // '5 заданий'\nconsole.log(tasksPluralize(999)) // '999 заданий'\n\n// string\nconsole.log(randomToken()) // 'vpxi4hpzmy'\nconsole.log(generateChars('a', 'd')) // ['a', 'b', 'c', 'd']\nconsole.log(capitalize('hello')) // 'Hello'\n\n// wait\nawait wait(1000)\nconsole.log('resolve after 1s')\n\n// pattern matching\nconst matcher = match\u003c[string, string], string\u003e((test) =\u003e ({\n  [test((firstName) =\u003e !firstName)]: 'User not found',\n  [test((firstName) =\u003e firstName.length \u003c 8)]: (firstName, lastName) =\u003e `${firstName} ${lastName}`,\n  [test((firstName) =\u003e firstName.length \u003e= 8)]: (firstName) =\u003e firstName\n}))\n\nmatcher('', 'Doe') // 'User not found'\nmatcher('John', 'Doe') // 'John Doe'\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzero-dependency%2Futils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzero-dependency%2Futils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzero-dependency%2Futils/lists"}