{"id":18249273,"url":"https://github.com/rferro/normat","last_synced_at":"2025-04-04T15:32:52.157Z","repository":{"id":20169910,"uuid":"23440692","full_name":"rferro/normat","owner":"rferro","description":"Generic javascript number/string formatting (bytes, milliseconds, ...).","archived":false,"fork":false,"pushed_at":"2019-12-28T05:00:44.000Z","size":768,"stargazers_count":34,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-19T06:56:06.519Z","etag":null,"topics":["bytes","coffeescript","milliseconds","nodejs"],"latest_commit_sha":null,"homepage":"http://rferro.github.io/normat","language":"CoffeeScript","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/rferro.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","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":"2014-08-28T19:42:43.000Z","updated_at":"2021-12-28T09:16:50.000Z","dependencies_parsed_at":"2022-09-02T18:51:12.945Z","dependency_job_id":null,"html_url":"https://github.com/rferro/normat","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rferro%2Fnormat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rferro%2Fnormat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rferro%2Fnormat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rferro%2Fnormat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rferro","download_url":"https://codeload.github.com/rferro/normat/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246869584,"owners_count":20847154,"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":["bytes","coffeescript","milliseconds","nodejs"],"created_at":"2024-11-05T09:39:37.759Z","updated_at":"2025-04-04T15:32:47.136Z","avatar_url":"https://github.com/rferro.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# normat\n\ngeneric javascript number/string formatting (bytes, milliseconds...)\n\n[![NPM](https://nodei.co/npm/normat.png)](https://nodei.co/npm/normat/)\n\n## Install\n\n```shell\nnpm install normat\n```\n\nor\n\n```shell\nbower install normat\n```\n\n## Examples\n\n```js\nvar normat = require(\"normat\")\nvar ms = normat.ms;\nvar b  = normat.b;\n```\n```js\n// milliseconds parser\n\nms(123);                        // 123ms\nms(1000);                       // 1s\nms(10000);                      // 10s\nms(1000 * 60 * 60 * 12);        // 12h\nms(1000 * 60 * 60 * 24 * 1500); // 4y\n```\n```js\n// bytes parser\n\nb(123);                         // 123b\nb(1024);                        // 1kb\nb(10240);                       // 10kb\nb(100000);                      // 97kb\nb(123123124);                   // 117mb\nb(1231423525142134);            // 1119tb\n```\n```js\n// seconds parser\n\nnormat.s()\n```\n```js\n// minutes parser\n\nnormat.m()\n```\n```js\n// kbytes parser\n\nnormat.kb()\n```\n\n## Create new parsers\n\n```js\nvar normat = require(\"normat\");\n\nvar my_parser = normat([\n  ['u',  10],\n  ['d',  10],\n  ['c',  10],\n  ['m',  1000],\n  ['mi', 1000],\n  ['b',  1000],\n  ['t']\n]);\n\nmy_parser(1);           // 1u\nmy_parser(10);          // 1d\nmy_parser(100);         // 1c\nmy_parser(1000);        // 1m\nmy_parser(1000000);     // 1mi\nmy_parser(2000000);     // 2mi\nmy_parser(10000000);    // 10mi\nmy_parser(100000000);   // 100mi\nmy_parser(9900000000);  // 9b\nmy_parser(19000000000); // 19b\n```\n```js\n// bytes\n\nb = normat ([\n  ['b',  1024]\n  ['kb', 1024]\n  ['mb', 1024]\n  ['gb', 1024]\n  ['tb']\n]);\n```\n```js\n// milliseconds\n\nms = normat([\n  ['ms', 1000]\n  ['s',  60]\n  ['m',  60]\n  ['h',  24]\n  ['d',  365]\n  ['y']\n]);\n```\n\n## Reverse Mode\n\n```js\nvar normat = require(\"normat\");\n\nvar my_parser = normat([\n  ['u',  10],\n  ['d',  10],\n  ['c',  10],\n  ['m',  1000],\n  ['mi', 1000],\n  ['b',  1000],\n  ['t']\n]);\n\nmy_parser('1u');      // 1\nmy_parser('1d');      // 10\nmy_parser('1c');      // 100\nmy_parser('1m');      // 1000\nmy_parser('1mi');     // 1000000\n```\n\n## Tests\n\n```shell\ngulp test\n```\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frferro%2Fnormat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frferro%2Fnormat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frferro%2Fnormat/lists"}