{"id":19200398,"url":"https://github.com/mablay/metric-prefix","last_synced_at":"2025-02-23T05:24:11.725Z","repository":{"id":51877349,"uuid":"150689312","full_name":"mablay/metric-prefix","owner":"mablay","description":"Format numbers using only significant digits and a metric prefix.","archived":false,"fork":false,"pushed_at":"2024-06-16T21:38:52.000Z","size":72,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-04T13:06:57.983Z","etag":null,"topics":["format","metric","prefix","si","unit"],"latest_commit_sha":null,"homepage":"https://mablay.github.io/metric-prefix/","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/mablay.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}},"created_at":"2018-09-28T05:18:45.000Z","updated_at":"2021-05-16T22:01:18.000Z","dependencies_parsed_at":"2022-08-23T10:20:23.920Z","dependency_job_id":null,"html_url":"https://github.com/mablay/metric-prefix","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mablay%2Fmetric-prefix","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mablay%2Fmetric-prefix/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mablay%2Fmetric-prefix/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mablay%2Fmetric-prefix/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mablay","download_url":"https://codeload.github.com/mablay/metric-prefix/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240273028,"owners_count":19775162,"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":["format","metric","prefix","si","unit"],"created_at":"2024-11-09T12:32:50.721Z","updated_at":"2025-02-23T05:24:11.686Z","avatar_url":"https://github.com/mablay.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Metric Prefix\n\nFormat numbers using only significant digits and a [metric prefix](https://en.wikipedia.org/wiki/Metric_prefix).  \n\n    prefix(1234567890)\n    // =\u003e '1.23 G'\n\n## Install\n\n    npm i metric-prefix\n\n#### basic example\n\n    const { prefix } = require('metric-prefix')\n\n    prefix(0.123456789)\n    // =\u003e '123 m'\n\n#### with options\n\n    prefix(123456, { unit: 'Hz' })\n    // =\u003e '123 kHz'\n\n    prefix(123456, { delimiter: '' })\n    // =\u003e '123k'\n\n    prefix(123.456, { precision: 4 })\n    // =\u003e '123.4'\n\n#### cure bulky options with factory pattern\n\n    const prefix = require('metric-prefix')({\n      unit: 'W',\n      precision: 4,\n      delimiter: ''\n    })\n\n    prefix(0.0321) // =\u003e '32.10mW'\n\n#### supported value types\n\nDue to [big.js](https://github.com/MikeMcl/big.js)\nbeing used internally, all compatible data types can\nbe used.\n\n    prefix(\"100000000000000000000000000\")\n    // =\u003e 100 Y\n\n    prefix(Big(1e26))\n    // =\u003e 100 Y\n\n## Additional Notes\n\n#### Range\nNumbers from 1e-33 to 1e35 can be prefixed. Including non standard prefixes *X*, *W*, *V*. Beyond that a `?` will replace the prefix.\n\n#### Rounding\nPrefix *floors* positive and *ceils* negative numbers.\n\n#### Floating Point Arithmetic\nIn JavaScripts you might encounter situations like\n\n    0.3 - 0.1 = 0.19999999999999998\n\nthat lead to\n\n    prefix(0.3 - 0.1) // =\u003e '199 m'\n\nand can be fixed with\n\n    prefix(Big(0.3).minus(0.1)) // =\u003e '200 m'\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmablay%2Fmetric-prefix","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmablay%2Fmetric-prefix","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmablay%2Fmetric-prefix/lists"}