{"_id":"format-byte-size","_rev":"3-ce7df5c58aed7a3313fb98a2b1469851","name":"format-byte-size","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"format-byte-size","version":"1.0.0","keywords":["bytes","format","parse","filesize","human-readable","storage","memory","data","size","utility","kb","mb","gb","kib","mib","gib","typescript","converter"],"author":{"name":"Venkata Phanindra Kumar Janapareddy"},"license":"MIT","_id":"format-byte-size@1.0.0","maintainers":[{"name":"zenluv","email":"venkatajanapareddy9@gmail.com"}],"homepage":"https://github.com/venkatajanapareddy/format-byte-size#readme","bugs":{"url":"https://github.com/venkatajanapareddy/format-byte-size/issues"},"dist":{"shasum":"3a1e6fa9d7e07853d49f7a849356ce4fe65640bc","tarball":"https://registry.npmjs.org/format-byte-size/-/format-byte-size-1.0.0.tgz","fileCount":9,"integrity":"sha512-fL8FcadxJPU40M3lRRdeBYdnjeBK+zukTcj67BMgW/LL6IejzEPHrdoJC3FwSm3LsQ0IptWFoLYlGvOpXAvg/w==","signatures":[{"sig":"MEQCICzbfZuUh7wEMnjX8Pch2bm5UX93qkuSlpVEWkPwQ2VDAiA1LsVqo9j3eGozSxSh+GDJHrfmjvJZiI8NtrB6X0QgPA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":29178},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs"}},"gitHead":"c7d4812d7e2b67430a3e3b4966786d03234dc4c6","scripts":{"dev":"vitest","lint":"eslint . --ext .ts,.tsx --fix","test":"vitest run","build":"tsup src/index.ts --format esm,cjs --dts --clean","format":"prettier --write \"src/**/*.ts\" \"tests/**/*.ts\" \"*.json\" \"*.md\"","prepare":"husky","format:check":"prettier --check \"src/**/*.ts\" \"tests/**/*.ts\" \"*.json\" \"*.md\"","test:coverage":"vitest run --coverage","prepublishOnly":"npm run build"},"_npmUser":{"name":"zenluv","email":"venkatajanapareddy9@gmail.com"},"deprecated":"Package deprecated. Use 'pretty-bytes' instead: https://www.npmjs.com/package/pretty-bytes","repository":{"url":"git+ssh://git@github.com/venkatajanapareddy/format-byte-size.git","type":"git"},"_npmVersion":"10.9.2","description":"A TypeScript library to format byte values into human-readable strings and parse them back.","directories":{},"lint-staged":{"*.{ts,tsx}":["eslint --fix","prettier --write"],"*.{json,md}":["prettier --write"]},"_nodeVersion":"22.15.0","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.0.1","husky":"^8.0.3","eslint":"^8.56.0","vitest":"^1.2.1","prettier":"^3.2.4","typescript":"^5.3.3","@types/node":"^20.11.0","lint-staged":"^15.2.0","@vitest/coverage-v8":"^1.2.1","eslint-config-prettier":"^9.1.0","eslint-plugin-prettier":"^5.1.3","@typescript-eslint/parser":"^6.19.0","@typescript-eslint/eslint-plugin":"^6.19.0"},"_npmOperationalInternal":{"tmp":"tmp/format-byte-size_1.0.0_1748405205217_0.15615774457303688","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"format-byte-size","version":"1.0.1","description":"[DEPRECATED] A TypeScript library to format byte values into human-readable strings and parse them back.","type":"module","main":"./dist/index.cjs","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs"}},"scripts":{"dev":"vitest","test":"vitest run","test:coverage":"vitest run --coverage","build":"tsup src/index.ts --format esm,cjs --dts --clean","lint":"eslint . --ext .ts,.tsx --fix","format":"prettier --write \"src/**/*.ts\" \"tests/**/*.ts\" \"*.json\" \"*.md\"","format:check":"prettier --check \"src/**/*.ts\" \"tests/**/*.ts\" \"*.json\" \"*.md\"","prepare":"husky","prepublishOnly":"npm run build"},"keywords":["bytes","format","parse","filesize","human-readable","storage","memory","data","size","utility","kb","mb","gb","kib","mib","gib","typescript","converter"],"author":{"name":"Venkata Phanindra Kumar Janapareddy"},"license":"MIT","devDependencies":{"@types/node":"^20.11.0","@typescript-eslint/eslint-plugin":"^6.19.0","@typescript-eslint/parser":"^6.19.0","@vitest/coverage-v8":"^1.2.1","eslint":"^8.56.0","eslint-config-prettier":"^9.1.0","eslint-plugin-prettier":"^5.1.3","husky":"^8.0.3","lint-staged":"^15.2.0","prettier":"^3.2.4","tsup":"^8.0.1","typescript":"^5.3.3","vitest":"^1.2.1"},"lint-staged":{"*.{ts,tsx}":["eslint --fix","prettier --write"],"*.{json,md}":["prettier --write"]},"_id":"format-byte-size@1.0.1","gitHead":"c7d4812d7e2b67430a3e3b4966786d03234dc4c6","_nodeVersion":"23.9.0","_npmVersion":"10.9.2","dist":{"integrity":"sha512-jq3c6V0eBmDlXipeuue6OrJTvDY77aeyj49mfpbDMPxsMu5xxQzuXCT/YXU0/2rxqWjPEqYAqTVmfrzJY5K2jg==","shasum":"5b694a77d592f8f97c2bc23abd0396aff9c85c5e","tarball":"https://registry.npmjs.org/format-byte-size/-/format-byte-size-1.0.1.tgz","fileCount":9,"unpackedSize":28909,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIBujdzWs73oZ03cLwXXZynhSWhMXWeEK+ke+aqxPRaHpAiEAjE3Yl7BRR5JXywtq6yKswuk1LmZnpEDTXd0JRUDjMlk="}]},"_npmUser":{"name":"zenluv","email":"venkatajanapareddy9@gmail.com"},"directories":{},"maintainers":[{"name":"zenluv","email":"venkatajanapareddy9@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/format-byte-size_1.0.1_1749918481798_0.8436834152599308"},"_hasShrinkwrap":false}},"time":{"created":"2025-05-28T04:06:45.160Z","modified":"2025-06-14T16:28:02.167Z","1.0.0":"2025-05-28T04:06:45.444Z","1.0.1":"2025-06-14T16:28:01.994Z"},"author":{"name":"Venkata Phanindra Kumar Janapareddy"},"license":"MIT","keywords":["bytes","format","parse","filesize","human-readable","storage","memory","data","size","utility","kb","mb","gb","kib","mib","gib","typescript","converter"],"description":"[DEPRECATED] A TypeScript library to format byte values into human-readable strings and parse them back.","maintainers":[{"name":"zenluv","email":"venkatajanapareddy9@gmail.com"}],"readme":"# ⚠️ DEPRECATED\n\n**This package is no longer maintained.**\n\nPlease use html-entities instead.\nSee: https://www.npmjs.com/package/html-entities\n\n---\n\nOriginal README below:\n\n---\n\n# format-byte-size\n\n\n[![npm version](https://badge.fury.io/js/format-byte-size.svg)](https://badge.fury.io/js/format-byte-size)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Bundle Size](https://img.shields.io/bundlephobia/minzip/format-byte-size)](https://bundlephobia.com/package/format-byte-size)\n\nA TypeScript library to format byte values into human-readable strings and parse them back.\n\n## Features\n\n- 🎯 Format bytes to human-readable strings (e.g., \"1.23 MB\", \"512 KiB\")\n- 🔄 Parse human-readable strings back to numeric byte values\n- 📊 Support for both decimal (KB, MB, GB) and binary (KiB, MiB, GiB) units\n- 🎨 Customizable formatting options (decimal places, spacing, fixed decimals)\n- 📦 Zero runtime dependencies\n- 🌳 Tree-shakeable ESM and CommonJS builds\n- 💪 Full TypeScript support with strict typing\n- ✅ Thoroughly tested\n\n## Installation\n\n```bash\nnpm install format-byte-size\n```\n\n## Usage\n\n### Basic Usage\n\n```typescript\nimport { formatBytes, parseBytes } from 'format-byte-size';\n\n// Format bytes to human-readable strings\nformatBytes(1234); // \"1.23 KB\"\nformatBytes(1234567890); // \"1.23 GB\"\nformatBytes(1024); // \"1.02 KB\"\n\n// Parse human-readable strings to bytes\nparseBytes('1.23 KB'); // 1230\nparseBytes('512 MiB'); // 536870912\nparseBytes('1GB'); // 1000000000\n```\n\n### Formatting Options\n\n```typescript\n// Use binary units (base 1024)\nformatBytes(1024, { useBinary: true }); // \"1 KiB\"\nformatBytes(1048576, { useBinary: true }); // \"1 MiB\"\n\n// Control decimal places\nformatBytes(1234, { decimalPlaces: 0 }); // \"1 KB\"\nformatBytes(1234, { decimalPlaces: 3 }); // \"1.234 KB\"\n\n// Always show fixed decimal places\nformatBytes(1000, { fixedDecimals: true }); // \"1.00 KB\"\nformatBytes(1500, { fixedDecimals: true }); // \"1.50 KB\"\n\n// Remove space between number and unit\nformatBytes(1234, { includeUnitSpace: false }); // \"1.23KB\"\n\n// Combine multiple options\nformatBytes(1536, {\n  useBinary: true,\n  decimalPlaces: 1,\n  fixedDecimals: true,\n  includeUnitSpace: false,\n}); // \"1.5KiB\"\n```\n\n### Parsing Examples\n\n```typescript\n// Parse various formats\nparseBytes('100'); // 100 (plain number)\nparseBytes('100B'); // 100\nparseBytes('100 bytes'); // 100\nparseBytes('1.5 KB'); // 1500\nparseBytes('1.5KB'); // 1500 (no space)\nparseBytes('1kb'); // 1000 (case insensitive)\nparseBytes('1 KiB'); // 1024 (binary unit)\n\n// Invalid inputs return null\nparseBytes('abc'); // null\nparseBytes(''); // null\nparseBytes('1.2.3MB'); // null\n```\n\n## Understanding Decimal vs Binary Units\n\nThis library supports both decimal (base 1000) and binary (base 1024) units:\n\n### Decimal Units (Base 1000)\n\n- Used by hard drive manufacturers and in networking\n- 1 KB = 1,000 bytes\n- 1 MB = 1,000,000 bytes\n- 1 GB = 1,000,000,000 bytes\n\n### Binary Units (Base 1024)\n\n- Used by operating systems for RAM and file sizes\n- 1 KiB = 1,024 bytes\n- 1 MiB = 1,048,576 bytes\n- 1 GiB = 1,073,741,824 bytes\n\n```typescript\n// Decimal units (default)\nformatBytes(1000); // \"1 KB\"\nformatBytes(1000000); // \"1 MB\"\n\n// Binary units\nformatBytes(1024, { useBinary: true }); // \"1 KiB\"\nformatBytes(1048576, { useBinary: true }); // \"1 MiB\"\n```\n\n## API Reference\n\n### `formatBytes(bytes: number, options?: FormatBytesOptions): string`\n\nFormats a number of bytes into a human-readable string.\n\n**Parameters:**\n\n- `bytes` - The number of bytes to format\n- `options` - Optional formatting configuration\n\n**Options:**\n\n- `decimalPlaces` (default: `2`) - Number of decimal places to include\n- `useBinary` (default: `false`) - Use binary (KiB, MiB) vs decimal (KB, MB) units\n- `fixedDecimals` (default: `false`) - Always show the specified decimal places\n- `includeUnitSpace` (default: `true`) - Include space between number and unit\n\n**Returns:** A human-readable string representation\n\n**Throws:** `TypeError` if input is not a number\n\n### `parseBytes(sizeString: string): number | null`\n\nParses a human-readable byte string into a number of bytes.\n\n**Parameters:**\n\n- `sizeString` - The string to parse (e.g., \"512KB\", \"1.5 GiB\")\n\n**Returns:** The number of bytes, or `null` if unparseable\n\n**Throws:** `TypeError` if input is not a string\n\n## License\n\nMIT\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n","readmeFilename":"README.md"}