{"id":21301711,"url":"https://github.com/funbox/diamonds","last_synced_at":"2026-03-11T03:31:07.711Z","repository":{"id":42717537,"uuid":"282198039","full_name":"funbox/diamonds","owner":"funbox","description":"A pile of shiny typed JS helpers for everyday usage","archived":false,"fork":false,"pushed_at":"2023-07-18T23:12:32.000Z","size":660,"stargazers_count":21,"open_issues_count":2,"forks_count":3,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-11-06T04:13:31.891Z","etag":null,"topics":["helpers-library","js-utils","typescript-helpers","utilities"],"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/funbox.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":"2020-07-24T11:06:41.000Z","updated_at":"2024-01-19T00:48:00.000Z","dependencies_parsed_at":"2024-06-19T00:12:32.243Z","dependency_job_id":"58b76eca-23ca-4bb3-9081-01a7ebc5637d","html_url":"https://github.com/funbox/diamonds","commit_stats":{"total_commits":210,"total_committers":5,"mean_commits":42.0,"dds":0.5714285714285714,"last_synced_commit":"06086546e4fdef6bdfa4c3f38c60acce123be235"},"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"purl":"pkg:github/funbox/diamonds","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funbox%2Fdiamonds","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funbox%2Fdiamonds/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funbox%2Fdiamonds/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funbox%2Fdiamonds/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/funbox","download_url":"https://codeload.github.com/funbox/diamonds/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/funbox%2Fdiamonds/sbom","scorecard":{"id":413722,"data":{"date":"2025-08-11","repo":{"name":"github.com/funbox/diamonds","commit":"6b4b3c2e96d7df22be3d442e3203f615a5493b40"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.7,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":0,"reason":"Found 0/2 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/publish.yml:1","Warn: no topLevel permission defined: .github/workflows/tests.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":3,"reason":"dependency not pinned by hash detected -- score normalized to 3","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/funbox/diamonds/publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/funbox/diamonds/publish.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/funbox/diamonds/tests.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/tests.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/funbox/diamonds/tests.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/tests.yml:39: update your workflow using https://app.stepsecurity.io/secureworkflow/funbox/diamonds/tests.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/tests.yml:50: update your workflow using https://app.stepsecurity.io/secureworkflow/funbox/diamonds/tests.yml/master?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/tests.yml:31","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned","Info:   2 out of   3 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 30 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":0,"reason":"21 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-968p-4wvh-cqc8","Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-434g-2637-qmqr","Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m","Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw","Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p","Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747","Warn: Project is vulnerable to: GHSA-vjh7-7g9h-fjfh","Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55","Warn: Project is vulnerable to: GHSA-h7cp-r72f-jxh6","Warn: Project is vulnerable to: GHSA-v62p-rq8g-8h59","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-76p7-773f-r4q5","Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986","Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-18T23:18:01.462Z","repository_id":42717537,"created_at":"2025-08-18T23:18:01.462Z","updated_at":"2025-08-18T23:18:01.462Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30369379,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T21:41:54.280Z","status":"online","status_checked_at":"2026-03-11T02:00:07.027Z","response_time":84,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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":["helpers-library","js-utils","typescript-helpers","utilities"],"created_at":"2024-11-21T15:50:30.656Z","updated_at":"2026-03-11T03:31:07.681Z","avatar_url":"https://github.com/funbox.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @funboxteam/diamonds\n\n\u003cimg align=\"right\" width=\"192\" height=\"192\"\n     alt=\"Set of diamonds\"\n     src=\"./logo.png\"\u003e\n\n[![npm](https://img.shields.io/npm/v/@funboxteam/diamonds.svg)](https://www.npmjs.com/package/@funboxteam/diamonds)\n\nThis is a set of helpers that we use in the current projects and will probably use in the future ones. \n\nAll helpers are independent of each other, which means that your project's bundle won't be bloated by useless code. \n\n[По-русски](./README.ru.md)\n\n## Contents\n\n- [Rationale](#rationale)\n- [Installation](#installation)\n- [List of helpers](#list-of-helpers)\n  - [base64ToUint8Array](#base64touint8array)\n  - [disableBodyScroll, enableBodyScroll](#disablebodyscroll-enableBodyScroll)\n  - [camelToKebab](#cameltokebab)\n  - [colorize](#colorize)\n  - [datauriToBlob](#datauritoblob)\n  - [debounce](#debounce)\n  - [deepClone](#deepclone)\n  - [equals](#equals)\n  - [findLast](#findLast)\n  - [formatBytes](#formatBytes)\n  - [formatNumberString](#formatnumberstring)\n  - [formatPhoneNumberString](#formatphonenumberstring)\n  - [getBrowserScrollbarWidth](#getbrowserscrollbarwidth)\n  - [getDisplayName](#getdisplayname)\n  - [getImageOrientation](#getimageorientation)\n  - [getObjectPath](#getobjectpath)\n  - [getPlural](#getplural)\n  - [getRandomNum](#getrandomnum)\n  - [getUniqueId](#getuniqueid)\n  - [hexToRgb](#hextorgb)\n  - [isElementInViewport](#iselementinviewport)\n  - [isEmailValid](#isemailvalid)\n  - [isInputTypeSupported](#isinputtypesupported)\n  - [isMobile](#ismobile)\n  - [kebabToCamel](#kebabtocamel)\n  - [objectToQueryString](#objecttoquerystring)\n  - [omit](#omit)\n  - [pick](#pick)\n  - [queryStringToObject](#querystringtoobject)\n  - [rgbToHex](#rgbtohex)\n  - [shuffle](#shuffle)\n  - [sleep](#sleep)\n  - [storage](#storage)\n  - [throttle](#throttle)\n- [Credits](#credits)\n\n## Rationale\n\nWhen developers create projects they use a lot of small functions that are not connected to the project itself.\nUsually such functions are stored in folders like `utils` or `helpers`. \n\nTo prevent copy-pasting between a huge amount of projects we've created this package.\n\nThese functions are not aimed to be absolutely safe to unexpected usage. \nThey do exactly what they say they do, and nothing else.  \n\n## Installation\n\nAdd the package to deps:\n\n```sh\nnpm install --save @funboxteam/diamonds \n```\n\nImport functions:\n\n```js\nimport { getUniqueId } from '@funboxteam/diamonds';\n```\n\n## List of helpers\n\nIt's easier to check every helper's source code rather than reading docs. But if you want some, here they are. \n\n### [base64ToUint8Array](./lib/base64-to-uint8array.ts)\n\nConverts Base64 string to a [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array).\n\n### [disableBodyScroll, enableBodyScroll](./lib/body-scroll.ts)\n\nThe first function disables scroll on the current page with the possibility to save the current scrolled position,\nthe second one enables the scroll and restores its position if it was saved.\n\nIt's useful when you want to disable scroll e.g. while opening sidebar and enable it while closing. \n\n### [camelToKebab](./lib/camel-to-kebab.ts)\n\nConverts camelCase string into kebab-case.\n\n### [capitalize](./lib/capitalize.ts)\n\nChange the passed strings's first letter case to upper.\n\n### [colorize](./lib/colorize.ts)\n\nReturns passed params as string with color tags inside.\n\nIt's useful when you want to colorize logs in terminal.\n\n### [cookieStringToObject](./lib/cookie-string-to-object.ts)\n\nConverts cookie string (usually, the one you get from `document.cookie`) into an object.\n\n### [datauriToBlob](./lib/datauri-to-blob.ts)\n\nConverts DataURI string into Blob instance.\n\nIt's useful when you need to send an image from online editor to the server.\n\n### [debounce](./lib/debounce.ts)\n\nReturns a debounced function that delays invoking callback until passed seconds have elapsed since the last time \nthe debounced function was invoked. \n\nIt's useful when you have to handle flow of events but want to fire callback after the flow finishes.\n\n### [deepClone](./lib/deep-clone.ts)\n\nReturns deep clone of the passed object. Does not work with circular links.\n\nIt's useful when you need to deeply clone an object. `Object.assign` does not work in this case,\nbecause it creates a shadow copy.\n\n### [equals](./lib/equals.ts)\n\nDeeply compares passed params.\n\n### [findLast](./lib/find-last.ts)\n\nReturns the value of the last element in the provided array that satisfies the provided testing function.\nOtherwise `undefined`.\n\n### [formatBytes](./lib/format-bytes.ts)\n\nConverts size in bytes to KB, MB, GB, etc.\n\n### [formatNumberString](./lib/format-number-string.ts)\n\nFormats a number (or a string with a number inside) using the passed format.\n\nIt's useful when you need to format, let's say, the cost of something.\n\n### [formatPhoneNumberString](./lib/format-phone-number-string.ts)\n\nFormats a number (or a string with a number inside) by the mask of Russian MSISDNs. \n\n### [getBrowserScrollbarWidth](./lib/get-browser-scrollbar-width.ts)\n\nReturns browser scrollbar width.\n\n### [getDisplayName](./lib/get-display-name.ts)\n\nReturns [displayName](https://reactjs.org/docs/higher-order-components.html#convention-wrap-the-display-name-for-easy-debugging)\nfor React HOC.\n\n### [getImageOrientation](./lib/get-image-orientation.ts)\n\nExtracts orientation from the passed images EXIF.\n\nExample:\n\n```js\ngetImageOrientation.call(this, image, orientation =\u003e {\n  let rotate;\n\n  switch (orientation) {\n    case 8:\n      rotate = 270;\n      break;\n    case 6:\n      rotate = 90;\n      break;\n    case 3:\n      rotate = 180;\n      break;\n    default:\n      rotate = 0;\n  }\n\n  this.setState({ rotate });\n});\n```\n\n### [getObjectPath](./lib/get-object-path.ts)\n\nGets the value at path of object.\n\nIt's useful when you have to work with highly nested objects and don't want to write long conditionals.\n`getObjectPath(obj, 'key1.key2.key3')` and the work is done. \n\n### [getPlural](./lib/get-plural.ts)\n\nPicks and returns a correct unit name for the passed number (according to Russian lang rules).\n\nIt's useful when it's important to pick correct unit name. E.g. “1 day”, “2 days”, etc.\n\n### [getRandomNum](./lib/get-random-num.ts)\n\nReturns [pseudorandom number](https://en.wikipedia.org/wiki/Pseudorandom_number_generator) from the passed range.\n\n### [getUniqueId](./lib/get-unique-id.ts)\n\nReturns a string generated by the pattern `prefix-number` where prefix is the passed param,\nbut number is unique.\n\nIt's useful when you need a unique string that can be namespaced. E.g. for generating unique IDs for DOM elements.\n\n### [hexToRgb](./lib/hex-to-rgb.ts)\n\nConverts HEX color string to RGB object.\n\n### [isElementInViewport](./lib/is-element-in-viewport.ts)\n\nReturns `true` when the passed DOM node is visible in the viewport \n(fully or partially depending on the params). \n\n### [isEmailValid](./lib/is-email-valid.ts)\n\nReturns `true` when the passed string is a valid email.\n\n### [isInputTypeSupported](./lib/is-input-type-supported.ts)\n\nChecks browser support of the passed `type` attribute value for `input` tag.\n\nIt's useful when you deal with old browsers.\n\n### [isMobile](./lib/is-mobile.ts)\n\nReturns `true` when UA is similar to mobile.\n\nIt is useful when you don't need a precise check (the checks that are used inside the script are quite simple).\n\n### [kebabToCamel](./lib/kebab-to-camel.ts)\n\nConverts kebab-case string into camelCase.\n\n### [objectToQueryString](./lib/object-to-query-string.ts)\n\nConverts the passed object which contains primitive values or arrays of primitive values into the query string. \n\n### [omit](./lib/omit.ts)\n\nReturns shallow copy of the passed object but without the passed keys.\n\nE.g. in React: `omit(this.props, 'mods', 'mix')`.\n\n### [pick](./lib/pick.ts)\n\nReturns shallow copy of the passed object but with the passed keys only.\n\n### [queryStringToObject](./lib/query-string-to-object.ts)\n\nConverts query-string into object.\n\n### [rgbToHex](./lib/rgb-to-hex.ts)\n\nTransforms RBG color object into HEX string.\n\n### [shuffle](./lib/shuffle.ts)\n\nShuffles the passed array and returns it.\n\n### [sleep](./lib/sleep.ts)\n\nReturns Promise which waits for the passed amount of ms before resolving.\n\n### [storage](./lib/storage.ts)\n\nMakes it possible to use `localStorage` safely.\n\n### [throttle](./lib/throttle.ts)\n\nTransforms the passed callback into the function that delays callback firing.\n\nIt's useful when you want to react on some events but no than once an N ms. \n\n## Credits\n\nCute picture for the project was made by [Igor Garybaldi](http://pandabanda.com/).\n\n[![Sponsored by FunBox](https://funbox.ru/badges/sponsored_by_funbox_centered.svg)](https://funbox.ru)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunbox%2Fdiamonds","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffunbox%2Fdiamonds","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffunbox%2Fdiamonds/lists"}