{"id":21874328,"url":"https://github.com/sadorlovsky/strunit","last_synced_at":"2026-04-11T11:04:57.220Z","repository":{"id":44012011,"uuid":"234385542","full_name":"sadorlovsky/strunit","owner":"sadorlovsky","description":"got a unit 📐","archived":false,"fork":false,"pushed_at":"2023-01-05T05:17:16.000Z","size":860,"stargazers_count":2,"open_issues_count":8,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-07T14:09:40.485Z","etag":null,"topics":["browser","css","nodejs","unit"],"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/sadorlovsky.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-16T18:31:55.000Z","updated_at":"2023-03-08T04:06:22.000Z","dependencies_parsed_at":"2023-02-03T12:46:25.422Z","dependency_job_id":null,"html_url":"https://github.com/sadorlovsky/strunit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sadorlovsky/strunit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sadorlovsky%2Fstrunit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sadorlovsky%2Fstrunit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sadorlovsky%2Fstrunit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sadorlovsky%2Fstrunit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sadorlovsky","download_url":"https://codeload.github.com/sadorlovsky/strunit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sadorlovsky%2Fstrunit/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265508512,"owners_count":23779165,"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":["browser","css","nodejs","unit"],"created_at":"2024-11-28T07:12:01.108Z","updated_at":"2025-10-17T06:28:32.521Z","avatar_url":"https://github.com/sadorlovsky.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# strunit [![build](https://github.com/sadorlovsky/strunit/workflows/build/badge.svg)](#strunit) [![codecov](https://codecov.io/gh/sadorlovsky/strunit/branch/master/graph/badge.svg)](https://codecov.io/gh/sadorlovsky/strunit)\n\n\u003e ends a value with a unit\n\nDo that?\n\n```js\nconst width = 100\ndocument.querySelector('div').style.width = `${width}px`\n```\n\nPlease, don't. Use `strunit`!\n\n## Usage\n\n```bash\nyarn add strunit\n```\n\n```ts\nimport { px } from 'strunit'\n\nconst width = 100\ndocument.querySelector('div').style.width = px(width)\n```\n\n## API\n\n### px(value: string | number): string\n\nPixels\n\n```ts\npx(42)                // =\u003e '42px'\npx('69')              // =\u003e '69px'\n```\n\n### pt(value: string | number): string\n\nPoints\n\n```ts\npt(4.20)              // =\u003e '4.20pt'\npt('3.141592653')     // =\u003e '3.141592653pt'\n```\n\n### pct(value: string | number): string\n\nPercents\n\n```ts\npct(7)                // =\u003e '7%'\npct('13')             // =\u003e '13%'\n```\n\n### cm(value: string | number): string\n\nCentimeters\n\n```ts\ncm(123)               // =\u003e '123cm'\ncm('4815162342')      // =\u003e '4815162342cm'\n```\n\n### mm(value: string | number): string\n\nMillimeters\n\n```ts\nmm(2012)              // =\u003e '2012mm'\nmm('88005553535')     // =\u003e '88005553535mm'\n```\n\n### em(value: string | number): string\n\nFont size of the parent element\n\n```ts\nem(666)               // =\u003e '666em'\nem('911')             // =\u003e '911em'\n```\n\n\n### rem(value: string | number): string\n\nFont size of the root element\n\n```ts\nrem(21)               // =\u003e '21rem'\nrem('777')            // =\u003e '777rem'\n```\n\n### vw(value: string | number): string\n\n1% of the viewport's width\n\n```ts\nvw(100)               // =\u003e '100vw'\nvw('100')             // =\u003e '100vw'\n```\n\n### vh(value: string | number): string\n\n1% of the viewport's height\n\n```ts\nvh(100)               // =\u003e '100vh'\nvh('100')             // =\u003e '100vh'\n```\n\n### vmin(value: string | number): string\n\n1% of the viewport's smaller dimension\n\n```ts\nvmin(1)               // =\u003e '1vmin'\nvmin('1')             // =\u003e '1vmin'\n```\n\n### vmax(value: string | number): string\n\n1% of the viewport's larger dimension\n\n```ts\nvmax(99)              // =\u003e '99vmax'\nvmax('99')            // =\u003e '99vmax'\n```\n\n### inch(value: string | number): string\n\nInches\n\n```ts\ninch(9)               // =\u003e '9in'\ninch('3.5')           // =\u003e '3.5in'\n```\n\n### pc(value: string | number): string\n\nPicas\n\n```ts\npc(1881)              // =\u003e '1881pc'\npc('1973')            // =\u003e '1973pc'\n```\n\n### Q(value: string | number): string\n\nQuarter-millimeters\n\n```ts\nQ(3.79)               // =\u003e '3.79Q'\nQ('4.79')             // =\u003e '4.79Q'\n```\n\n### ex(value: string | number): string\n\nX-height of the element's font\n\n```ts\nex(1)                 // =\u003e '1ex'\nex('s')               // =\u003e 'sex'\n```\n\n### ch(value: string | number): string\n\nThe advance measure (width) of the glyph \"0\" of the element's font\n\n```ts\nch(0)                 // =\u003e '0ch'\nch('not')             // =\u003e 'notch'\n```\n\n### custom(value: string | number, unit: string): string\n\n```ts\ncustom(63, 'region')  // =\u003e '63region'\ncustom(43, '°C')      // =\u003e '43°C'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsadorlovsky%2Fstrunit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsadorlovsky%2Fstrunit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsadorlovsky%2Fstrunit/lists"}