{"id":16760311,"url":"https://github.com/ryanve/wtb","last_synced_at":"2025-03-16T09:16:36.302Z","repository":{"id":46171419,"uuid":"256110000","full_name":"ryanve/wtb","owner":"ryanve","description":"what the box dimension parser","archived":false,"fork":false,"pushed_at":"2021-11-09T16:50:34.000Z","size":22,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-15T21:51:24.002Z","etag":null,"topics":["dimension","dimensions","funny","javascript","node-module","parser"],"latest_commit_sha":null,"homepage":"https://ryanve.dev/wtb/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"0bsd","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ryanve.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"ryanve"}},"created_at":"2020-04-16T04:35:08.000Z","updated_at":"2023-09-30T12:55:34.000Z","dependencies_parsed_at":"2022-09-26T21:31:32.679Z","dependency_job_id":null,"html_url":"https://github.com/ryanve/wtb","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Fwtb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Fwtb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Fwtb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ryanve%2Fwtb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ryanve","download_url":"https://codeload.github.com/ryanve/wtb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243847056,"owners_count":20357317,"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":["dimension","dimensions","funny","javascript","node-module","parser"],"created_at":"2024-10-13T04:23:05.855Z","updated_at":"2025-03-16T09:16:36.269Z","avatar_url":"https://github.com/ryanve.png","language":"JavaScript","funding_links":["https://github.com/sponsors/ryanve"],"categories":[],"sub_categories":[],"readme":"# wtb\n\n[\u003cb\u003ewhat the box\u003c/b\u003e](https://ryanve.github.io/wtb) JavaScript dimension parser\n\n```\nnpm install wtb --save\n```\n\n```js\nconst wtb = require(\"wtb\")\n```\n\n### `wtb(dimensions=0)`\n\n* dimensions are accepted in many formats shown in examples\n* defaults to square\n* negatives become positive\n* handles any input without throwing errors\n* string delimiter is any non numeric portion\n* supports JavaScript number formats including integers, decimals, scientific notation\n* plain objects support owned values while null objects support any depth\n* returns an object with calculated properties whose values range from `0` to `Infinity`\n  * `area` is the calculated `width * height`\n  * `aspect` is the calculated aspect ratio `width / height`\n  * `height` is the parsed `height`\n  * `width` is the parsed `width`\n\n### squares\n\nthese examples are equivalent `30x30` squares\n\n```js\nwtb(30)\nwtb(-30)\nwtb(3e2)\nwtb(3E2)\nwtb(30.0)\nwtb(\"30\")\nwtb(\"30x30\")\nwtb(\"30X30\")\nwtb(\"30,30\")\nwtb(\"30_30\")\nwtb(\"30 30\")\nwtb(\"30  30\")\nwtb([30])\nwtb([30, 30])\nwtb({ width: 30 })\nwtb({ height: 30 })\nwtb({ width: () =\u003e 30 })\n```\n\nthey return a square object\n\n```js\n{\n  area: 900,\n  aspect: 1,\n  width: 30,\n  height: 30\n}\n```\n\n### rectangles\n\nthese examples are equivalent rectangles\n\n```js\n\nwtb(\"30x20\")\nwtb(\"30 20\")\nwtb(\"30x20\")\nwtb(\"3e2x2e2\")\nwtb([30, 20])\nwtb([30, 30])\nwtb({ width: 30, height: 20 })\nwtb({ width: () =\u003e 30, height: () =\u003e 20 })\n```\n\nthey return a rectangular object\n\n```js\n{\n  area: 600,\n  aspect: 1.5,\n  width: 30,\n  height: 20\n}\n```\n\n\n### aspect ratio\n\n`aspect` can determine portrait vs landscape orientation\n\n```js\nconst orientation = wtb().aspect \u003e 1 ? \"landscape\" : \"portrait\"\n```\n\n### [c11y](https://s9a.page/c11y)\n\n* compatible in Node.js or CommonJS or any web browser\n* uses universal module definition pattern\n* if online unbundled then `wtb === window.wtb`\n\n[\u003cb\u003ehave fun =)\u003c/b\u003e](https://ryanve.github.io/wtb)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanve%2Fwtb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fryanve%2Fwtb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fryanve%2Fwtb/lists"}