{"name":"filesize","version":"11.0.20","keywords":["file","filesize","size","readable","file system","bytes","diff"],"author":{"name":"Jason Mulligan","email":"jason.mulligan@avoidwork.com"},"license":"BSD-3-Clause","_id":"filesize@11.0.20","maintainers":[{"name":"avoidwork","email":"jason.mulligan@avoidwork.com"}],"homepage":"https://filesizejs.com","bugs":{"url":"https://github.com/avoidwork/filesize.js/issues"},"dist":{"shasum":"2ca341131eb0a3cd5b01c766cfa35953e5c3d0b4","tarball":"http://registry-npm.ywwl.com/filesize/download/filesize-11.0.20.tgz","fileCount":6,"integrity":"sha512-dN6Ck5Gpabbq0Eh7qm5Swe2dThHx33g4BqSlqcpBSR6Re0caofGBegUGbj1ISke/x223B7BMqqckGrx0hkKeBg==","signatures":[{"sig":"MEYCIQD78Z98tNmu+2yXnmCk9V29yPJgXjc9kwn9W4IBSeHknQIhAMh7ik1+duVBSbwi32uJbwfm5+sUKOIaJY+hxIiHvarG","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":57039,"size":10873,"noattachment":false,"key":"/filesize/-/filesize-11.0.20.tgz"},"main":"dist/filesize.cjs","type":"module","types":"types/filesize.d.ts","module":"dist/filesize.js","source":"src/filesize.js","engines":{"node":">= 10.8.0"},"exports":{"types":"./types/filesize.d.ts","import":"./dist/filesize.js","require":"./dist/filesize.cjs"},"gitHead":"2d468a97ad49a2c20070145a457e528ffa62af87","scripts":{"dev":"npm run build:watch","fix":"npx oxlint --fix *.js benchmarks src tests && npx oxfmt *.js benchmarks src tests/unit --write","lint":"npx oxlint *.js benchmarks src tests && npx oxfmt *.js benchmarks src tests/unit --check","test":"npm run lint && node --test --experimental-test-coverage tests/**/*.js","build":"npm run rollup","rollup":"rollup --config","prepack":"npm run build","prepare":"husky","coverage":"node --test --experimental-test-coverage --test-coverage-exclude=dist/** --test-coverage-exclude=tests/** --test-reporter=spec tests/**/*.test.js 2>&1 | grep -A 1000 \"start of coverage report\" > coverage.txt","benchmark":"node benchmarks/index.js","changelog":"auto-changelog -p","test:watch":"node --test --watch tests/**/*.js","build:watch":"rollup --config --watch","analyze:size":"echo 'Bundle size analysis:' && du -h dist/* && echo 'Gzipped sizes:' && gzip -c dist/filesize.min.js | wc -c | awk '{print $1\" bytes (gzipped)\"}' && gzip -c dist/filesize.umd.min.js | wc -c | awk '{print $1\" bytes (umd gzipped)\"}'","benchmark:gc":"node --expose-gc benchmarks/index.js","build:analyze":"npm run rollup && npm run analyze:size","benchmark:basic":"node benchmarks/basic-performance.js","benchmark:stress":"node benchmarks/stress-test.js","benchmark:options":"node benchmarks/options-benchmark.js","benchmark:partial":"node benchmarks/partial-benchmark.js"},"_npmUser":{"name":"avoidwork","email":"jason.mulligan@avoidwork.com"},"repository":{"url":"git://github.com/avoidwork/filesize.js.git","type":"git"},"sourceType":"module","_npmVersion":"11.11.0","description":"Lightweight, zero-dependency JavaScript utility to convert bytes to human-readable strings with localization support","directories":{},"_nodeVersion":"25.8.1","_hasShrinkwrap":false,"devDependencies":{"husky":"^9.1.7","oxfmt":"^0.57.0","oxlint":"^1.57.0","rollup":"^4.52.0","auto-changelog":"^2.5.0","@rollup/plugin-terser":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/filesize_11.0.20_1783594476997_0.6521920381136441","host":"s3://npm-registry-packages-npm-production"},"readme":"# filesize\n[![npm version](https://badge.fury.io/js/filesize.svg)](https://www.npmjs.com/package/filesize)\n[![Node.js Version](https://img.shields.io/node/v/filesize.svg)](https://nodejs.org/)\n[![License](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)\n[![Build Status](https://github.com/avoidwork/filesize.js/actions/workflows/ci.yml/badge.svg)](https://github.com/avoidwork/filesize.js/actions)\n\nA lightweight, high-performance file size utility that converts bytes to human-readable strings. Zero dependencies. 100% test coverage.\n\n## Why filesize?\n\n- **Zero dependencies** - Pure JavaScript, no external packages\n- **100% test coverage** - Reliable, well-tested codebase\n- **TypeScript ready** - Full type definitions included\n- **Multiple standards** - SI, IEC, and JEDEC support\n- **Localization** - Intl API for international formatting\n- **BigInt support** - Handle extremely large file sizes\n- **Functional API** - Partial application for reusable formatters\n- **Browser & Node.js** - Works everywhere\n\n## Installation\n\n```bash\nnpm install filesize\n```\n\n## TypeScript\n\nFully typed with TypeScript definitions included:\n\n```typescript\nimport { filesize, partial } from 'filesize';\n\nconst result: string = filesize(1024);\nconst formatted: { value: number; symbol: string; exponent: number; unit: string } = filesize(1024, { output: 'object' });\n\nconst formatter: (arg: number | bigint) => string = partial({ standard: 'iec' });\n```\n\n## Usage\n\n```javascript\nimport {filesize, partial} from \"filesize\";\n\nfilesize(1024); // \"1.02 kB\"\nfilesize(265318); // \"265.32 kB\"\nfilesize(1024, {standard: \"iec\"}); // \"1 KiB\"\nfilesize(1024, {bits: true}); // \"8.19 kbit\"\n```\n\n### Partial Application\n\n```javascript\nimport {partial} from \"filesize\";\n\nconst formatBinary = partial({standard: \"iec\"});\nformatBinary(1024); // \"1 KiB\"\nformatBinary(1048576); // \"1 MiB\"\n```\n\n## Options\n\n| Option | Type | Default | Description |\n|--------|------|---------|-------------|\n| `bits` | boolean | `false` | Calculate bits instead of bytes |\n| `base` | number | `-1` | Number base (2 for binary, 10 for decimal, -1 for auto) |\n| `round` | number | `2` | Decimal places to round |\n| `locale` | string\\|boolean | `\"\"` | Locale for formatting, `true` for system locale |\n| `localeOptions` | Object | `{}` | Additional locale options |\n| `separator` | string | `\"\"` | Custom decimal separator |\n| `spacer` | string | `\" \"` | Value-unit separator |\n| `symbols` | Object | `{}` | Custom unit symbols |\n| `standard` | string | `\"\"` | Unit standard (`si`, `iec`, `jedec`) |\n| `output` | string | `\"string\"` | Output format (`string`, `array`, `object`, `exponent`) |\n| `fullform` | boolean | `false` | Use full unit names |\n| `fullforms` | Array | `[]` | Custom full unit names |\n| `exponent` | number | `-1` | Force specific exponent (-1 for auto) |\n| `roundingMethod` | string | `\"round\"` | Math method (`round`, `floor`, `ceil`) |\n| `precision` | number | `0` | Significant digits (0 for auto) |\n| `pad` | boolean | `false` | Pad decimal places |\n\n## Output Formats\n\n```javascript\n// String (default)\nfilesize(1536); // \"1.54 kB\"\n\n// Array\nfilesize(1536, {output: \"array\"}); // [1.54, \"kB\"]\n\n// Object\nfilesize(1536, {output: \"object\"});\n// {value: 1.54, symbol: \"kB\", exponent: 1, unit: \"kB\"}\n\n// Exponent\nfilesize(1536, {output: \"exponent\"}); // 1\n```\n\n## Standards\n\n```javascript\n// SI (default, base 10)\nfilesize(1000); // \"1 kB\"\n\n// IEC (binary, requires base: 2)\nfilesize(1024, {base: 2, standard: \"iec\"}); // \"1 KiB\"\n\n// JEDEC (binary calculation, traditional symbols)\nfilesize(1024, {standard: \"jedec\"}); // \"1 KB\"\n```\n\n## Examples\n\n```javascript\n// Bits\nfilesize(1024, {bits: true}); // \"8.19 kbit\"\nfilesize(1024, {bits: true, base: 2}); // \"8 Kibit\"\n\n// Full form\nfilesize(1024, {fullform: true}); // \"1.02 kilobytes\"\nfilesize(1024, {base: 2, fullform: true}); // \"1 kibibyte\"\n\n// Custom separator\nfilesize(265318, {separator: \",\"}); // \"265,32 kB\"\n\n// Padding\nfilesize(1536, {round: 3, pad: true}); // \"1.536 kB\"\n\n// Precision\nfilesize(1536, {precision: 3}); // \"1.54 kB\"\n\n// Locale\nfilesize(265318, {locale: \"de\"}); // \"265,32 kB\"\n\n// Custom symbols\nfilesize(1, {symbols: {B: \"Б\"}}); // \"1 Б\"\n\n// BigInt support\nfilesize(BigInt(1024)); // \"1.02 kB\"\n\n// Negative numbers\nfilesize(-1024); // \"-1.02 kB\"\n```\n\n## Error Handling\n\n```javascript\ntry {\n  filesize(\"invalid\");\n} catch (error) {\n  // TypeError: \"Invalid number\"\n}\n\ntry {\n  filesize(1024, {roundingMethod: \"invalid\"});\n} catch (error) {\n  // TypeError: \"Invalid rounding method\"\n}\n```\n\n## Testing\n\n```bash\nnpm test              # Run all tests (lint + node:test)\nnpm run test:watch    # Live test watching\n```\n\n**100% test coverage** with 149 tests:\n\n```\n--------------|---------|----------|---------|---------|-------------------\nFile          | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s \n--------------|---------|----------|---------|---------|-------------------\nAll files     |     100 |      100 |     100 |     100 |                   \n constants.js |     100 |      100 |     100 |     100 |                   \n filesize.js  |     100 |      100 |     100 |     100 |                   \n helpers.js   |     100 |      100 |     100 |     100 |                   \n--------------|---------|----------|---------|---------|-------------------\n```\n\n## Development\n\n```bash\nnpm install         # Install dependencies\nnpm run dev         # Development mode with live reload\nnpm run build       # Build distributions\nnpm run lint        # Check code style\nnpm run lint:fix    # Auto-fix linting issues\n```\n\n### Project Structure\n\n```\nfilesize.js/\n├── src/\n│   ├── filesize.js      # Main implementation (285 lines)\n│   ├── helpers.js       # Helper functions (215 lines)\n│   └── constants.js     # Constants (81 lines)\n├── tests/\n│   └── unit/\n├── dist/                # Built distributions\n└── types/               # TypeScript definitions\n```\n\n## Performance\n\n- **Basic conversions**: ~16-27M ops/sec\n- **With options**: ~5-13M ops/sec\n- **Locale formatting**: ~91K ops/sec (use sparingly)\n\n**Optimization tips:**\n1. Cache `partial()` formatters for reuse\n2. Avoid locale formatting in performance-critical code\n3. Use `object` output for fastest structured data access\n\n## Contributing\n\nWe welcome contributions! Please see our [Contributing Guidelines](https://github.com/avoidwork/filesize.js/blob/master/CONTRIBUTING.md) for details.\n\n## Changelog\n\nSee [CHANGELOG.md](https://github.com/avoidwork/filesize.js/blob/master/CHANGELOG.md) for a history of changes.\n\n## License\n\nCopyright (c) 2026 Jason Mulligan  \nLicensed under the BSD-3 license.\n","publish_time":1783594477147,"_cnpm_publish_time":1783594477147,"dist-tags":{"latest":"11.0.32"}}