{"name":"filesize","version":"11.0.10","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.10","maintainers":[{"name":"avoidwork","email":"jason.mulligan@avoidwork.com"}],"homepage":"https://filesizejs.com","bugs":{"url":"https://github.com/avoidwork/filesize.js/issues"},"dist":{"shasum":"271298a6f57c3e4d1f36d7cf9784a0411fbf21fb","tarball":"http://registry-npm.ywwl.com/filesize/download/filesize-11.0.10.tgz","fileCount":7,"integrity":"sha512-uasnz3C/UdPRVlmtkDz4SfaIm7IOT+UYpH8xbmn6EaXRBQ22hGoc64UtflHOqV+BlVDsTcz2pI94P/Zzzm5Rpw==","signatures":[{"sig":"MEUCIQDc+seZlqMNBZ4DSDO3ra9umN5RrvOUE/iOOIu90XqknQIgVpwMzVkvbJ9ARnsmvN+UG/nRqvv3xBhLfnfy+1j7Mws=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":43753,"size":10542,"noattachment":false,"key":"/filesize/-/filesize-11.0.10.tgz"},"main":"dist/filesize.cjs","type":"module","types":"types/filesize.d.ts","module":"dist/filesize.js","source":"src/filesize.js","engines":{"node":">= 10.4.0"},"exports":{"types":"./types/filesize.d.ts","import":"./dist/filesize.js","require":"./dist/filesize.cjs"},"gitHead":"cc9e109fda32f5949c4315b752c7d6baa5393482","scripts":{"fix":"eslint --fix *.js src/*.js tests/**/*.js","lint":"eslint *.js src/*.js tests/**/*.js","test":"npm run lint && npm run mocha","build":"npm run rollup","mocha":"c8 mocha tests/**/*.js","rollup":"rollup --config","prepare":"husky","benchmark":"node benchmarks/index.js","changelog":"auto-changelog -p","benchmark:gc":"node --expose-gc benchmarks/index.js","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.6.0","description":"JavaScript library to generate a human readable String describing the file size","directories":{},"_nodeVersion":"24.8.0","_hasShrinkwrap":false,"devDependencies":{"c8":"^10.1.3","husky":"^9.1.7","mocha":"^11.7.1","eslint":"^9.30.1","rollup":"^4.44.2","auto-changelog":"^2.5.0","@rollup/plugin-terser":"^0.4.4"},"_npmOperationalInternal":{"tmp":"tmp/filesize_11.0.10_1758330179238_0.05609953397039158","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":1758330179459,"_cnpm_publish_time":1758330179459,"dist-tags":{"latest":"11.0.32"}}