{"id":15760600,"url":"https://github.com/alrico88/scale-helper-functions","last_synced_at":"2026-02-13T02:02:32.117Z","repository":{"id":35023662,"uuid":"197735247","full_name":"alrico88/scale-helper-functions","owner":"alrico88","description":"Helper to create scales","archived":false,"fork":false,"pushed_at":"2023-08-17T12:41:28.000Z","size":1610,"stargazers_count":0,"open_issues_count":11,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-20T19:56:13.928Z","etag":null,"topics":["d3","dataset","dataset-extent","javascript","linear","log-scale","node","quantile-scale"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/scale-helper-functions","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/alrico88.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":"2019-07-19T08:35:04.000Z","updated_at":"2023-08-17T12:41:12.000Z","dependencies_parsed_at":"2024-10-04T11:01:11.738Z","dependency_job_id":"2a6dd246-4f49-44eb-9089-2b3be137ee5f","html_url":"https://github.com/alrico88/scale-helper-functions","commit_stats":{"total_commits":25,"total_committers":3,"mean_commits":8.333333333333334,"dds":"0.16000000000000003","last_synced_commit":"0230c78e44fca03ad722bc6bd0ad210e8f170e4b"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/alrico88/scale-helper-functions","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alrico88%2Fscale-helper-functions","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alrico88%2Fscale-helper-functions/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alrico88%2Fscale-helper-functions/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alrico88%2Fscale-helper-functions/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alrico88","download_url":"https://codeload.github.com/alrico88/scale-helper-functions/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alrico88%2Fscale-helper-functions/sbom","scorecard":{"id":186829,"data":{"date":"2025-08-11","repo":{"name":"github.com/alrico88/scale-helper-functions","commit":"81ede4555c4c3f32586b7c42e6dc4b91113cd518"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"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":"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":"Dangerous-Workflow","score":-1,"reason":"no workflows found","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":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"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":"Code-Review","score":0,"reason":"Found 0/25 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":"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":"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":"License","score":0,"reason":"license file not detected","details":["Warn: project does not have a license file"],"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 6 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":"15 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-67mh-4wv8-2f99","Warn: Project is vulnerable to: GHSA-fjxv-7rqg-78g4","Warn: Project is vulnerable to: GHSA-4q6p-r6v2-jvc5","Warn: Project is vulnerable to: GHSA-896r-f27r-55mw","Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55","Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j","Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp","Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6","Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm","Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3"],"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-16T19:56:39.735Z","repository_id":35023662,"created_at":"2025-08-16T19:56:39.735Z","updated_at":"2025-08-16T19:56:39.735Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29392819,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-13T00:53:09.511Z","status":"online","status_checked_at":"2026-02-13T02:00:10.076Z","response_time":78,"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":["d3","dataset","dataset-extent","javascript","linear","log-scale","node","quantile-scale"],"created_at":"2024-10-04T10:59:10.672Z","updated_at":"2026-02-13T02:02:32.103Z","avatar_url":"https://github.com/alrico88.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# scale-helper-functions\n\nCompendium of helpers to create scales\n\n## Installation\n\nUsing npm, `npm i scale-helper-functions`.\n\nUsing yarn, `yarn add scale-helper-functions`.\n\n## Usage\n\nUsing `import`\n\n```javascript\nimport {createLinearScale} from 'scale-helper-functions';\n\nconst domain = [0, 10];\nconst range = [0, 100];\n\nconst scale = createLinearScale(domain, range);\n\nconst transformed = scale(5); // transformed is 50\n```\n\nIn a CommonJS environment\n\n```javascript\nconst {createOrdinalScale} = require('scale-helper-functions');\n\nconst animals = ['cat', 'dog'];\nconst range = ['white', 'brown'];\n\nconst scale = createOrdinalScale(animals, range);\nconst color = scale('dog'); // color is brown\n```\n\n## Table of contents\n\n### Type aliases\n\n- [OrdinalScaleFunction](#ordinalscalefunction)\n- [ScaleFunction](#scalefunction)\n\n### Functions\n\n- [createLinearInterpolator](#createlinearinterpolator)\n- [createLinearScale](#createlinearscale)\n- [createLogScale](#createlogscale)\n- [createOpacityScale](#createopacityscale)\n- [createOrdinalScale](#createordinalscale)\n- [createQuantileScale](#createquantilescale)\n- [createQuantizeScale](#createquantizescale)\n- [getLinearDomainRange](#getlineardomainrange)\n\n## Type aliases\n\n### OrdinalScaleFunction\n\nƬ **OrdinalScaleFunction**: (`s`: _string_) =\u003e _string_\n\n#### Type declaration:\n\n▸ (`s`: _string_): _string_\n\n#### Parameters:\n\n| Name | Type     |\n| :--- | :------- |\n| `s`  | _string_ |\n\n**Returns:** _string_\n\nDefined in: [modules/types.ts:3](https://github.com/alrico88/scale-helper-functions/blob/4978647/src/modules/types.ts#L3)\n\n---\n\n### ScaleFunction\n\nƬ **ScaleFunction**: (`n`: _number_) =\u003e _number_ \\| _string_\n\n#### Type declaration:\n\n▸ (`n`: _number_): _number_ \\| _string_\n\n#### Parameters:\n\n| Name | Type     |\n| :--- | :------- |\n| `n`  | _number_ |\n\n**Returns:** _number_ \\| _string_\n\nDefined in: [modules/types.ts:1](https://github.com/alrico88/scale-helper-functions/blob/4978647/src/modules/types.ts#L1)\n\n## Functions\n\n### createLinearInterpolator\n\n▸ **createLinearInterpolator**(`domain`: _number_[]): [_ScaleFunction_](#scalefunction)\n\nFunction that given a domain, returns a scale that will trasform a number to a value between 0 and 1\n\n#### Parameters:\n\n| Name     | Type       |\n| :------- | :--------- |\n| `domain` | _number_[] |\n\n**Returns:** [_ScaleFunction_](#scalefunction)\n\nDefined in: [modules/interpolation.ts:9](https://github.com/alrico88/scale-helper-functions/blob/4978647/src/modules/interpolation.ts#L9)\n\n---\n\n### createLinearScale\n\n▸ **createLinearScale**(`domain`: _number_[], `range`: Range): [_ScaleFunction_](#scalefunction)\n\nCreates a linear scale\n\n#### Parameters:\n\n| Name     | Type       | Description                         |\n| :------- | :--------- | :---------------------------------- |\n| `domain` | _number_[] |                                     |\n| `range`  | Range      | Desired resulting values of scaling |\n\n**Returns:** [_ScaleFunction_](#scalefunction)\n\nThe scale function\n\nDefined in: [modules/scales.ts:13](https://github.com/alrico88/scale-helper-functions/blob/4978647/src/modules/scales.ts#L13)\n\n---\n\n### createLogScale\n\n▸ **createLogScale**(`domain`: _number_[], `range`: Range, `base?`: _number_): [_ScaleFunction_](#scalefunction)\n\nCreates a log scale\n\n#### Parameters:\n\n| Name     | Type       | Description                         |\n| :------- | :--------- | :---------------------------------- |\n| `domain` | _number_[] |                                     |\n| `range`  | Range      | Desired resulting values of scaling |\n| `base?`  | _number_   | -                                   |\n\n**Returns:** [_ScaleFunction_](#scalefunction)\n\nThe scale function\n\nDefined in: [modules/scales.ts:25](https://github.com/alrico88/scale-helper-functions/blob/4978647/src/modules/scales.ts#L25)\n\n---\n\n### createOpacityScale\n\n▸ **createOpacityScale**(`domain`: _number_[]): [_ScaleFunction_](#scalefunction)\n\nReturns, given a domain, a function that will convert a number to another one between 0 and 255\nUseful for calculating opacity values for RGBA strings\n\n**`export`**\n\n#### Parameters:\n\n| Name     | Type       |\n| :------- | :--------- |\n| `domain` | _number_[] |\n\n**Returns:** [_ScaleFunction_](#scalefunction)\n\nThe scale function\n\nDefined in: [modules/scales.ts:77](https://github.com/alrico88/scale-helper-functions/blob/4978647/src/modules/scales.ts#L77)\n\n---\n\n### createOrdinalScale\n\n▸ **createOrdinalScale**(`domain`: _string_[], `range`: _string_[]): [_OrdinalScaleFunction_](#ordinalscalefunction)\n\nReturns an ordinal scale\nDiscrete input and discrete output\n\n#### Parameters:\n\n| Name     | Type       | Description                             |\n| :------- | :--------- | :-------------------------------------- |\n| `domain` | _string_[] | Discrete list of values ['A', 'B', 'C'] |\n| `range`  | _string_[] | Desired resulting values of scaling     |\n\n**Returns:** [_OrdinalScaleFunction_](#ordinalscalefunction)\n\nThe scale function\n\nDefined in: [modules/scales.ts:65](https://github.com/alrico88/scale-helper-functions/blob/4978647/src/modules/scales.ts#L65)\n\n---\n\n### createQuantileScale\n\n▸ **createQuantileScale**(`dataset`: _number_[], `range`: Range): [_ScaleFunction_](#scalefunction)\n\nReturns a quantile scale based on dataset\nMaps continuous numeric input to discrete values. The domain is defined by an array of numbers:\n\n#### Parameters:\n\n| Name      | Type       | Description                         |\n| :-------- | :--------- | :---------------------------------- |\n| `dataset` | _number_[] | Full dataset to take into account   |\n| `range`   | Range      | Desired resulting values of scaling |\n\n**Returns:** [_ScaleFunction_](#scalefunction)\n\nThe scale function\n\nDefined in: [modules/scales.ts:41](https://github.com/alrico88/scale-helper-functions/blob/4978647/src/modules/scales.ts#L41)\n\n---\n\n### createQuantizeScale\n\n▸ **createQuantizeScale**(`domain`: _number_[], `range`: Range): [_ScaleFunction_](#scalefunction)\n\nReturns a quantized scale based on dataset extent\nAccepts continuous input and outputs a number of discrete quantities defined by the range.\n\n#### Parameters:\n\n| Name     | Type       | Description                         |\n| :------- | :--------- | :---------------------------------- |\n| `domain` | _number_[] |                                     |\n| `range`  | Range      | Desired resulting values of scaling |\n\n**Returns:** [_ScaleFunction_](#scalefunction)\n\nThe scale function\n\nDefined in: [modules/scales.ts:53](https://github.com/alrico88/scale-helper-functions/blob/4978647/src/modules/scales.ts#L53)\n\n---\n\n### getLinearDomainRange\n\n▸ **getLinearDomainRange**(`domain`: _number_[], `segmentsAmount`: _number_): _number_[]\n\nGets a domain of N elements from a domain with less length\n\n**`export`**\n\n#### Parameters:\n\n| Name             | Type       | Description                              |\n| :--------------- | :--------- | :--------------------------------------- |\n| `domain`         | _number_[] | The existing domain                      |\n| `segmentsAmount` | _number_   | The desired length for the linear domain |\n\n**Returns:** _number_[]\n\nThe resulting domain\n\nDefined in: [modules/helpers.ts:9](https://github.com/alrico88/scale-helper-functions/blob/4978647/src/modules/helpers.ts#L9)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falrico88%2Fscale-helper-functions","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falrico88%2Fscale-helper-functions","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falrico88%2Fscale-helper-functions/lists"}