{"id":21074795,"url":"https://github.com/dawsbot/file-bytes","last_synced_at":"2025-05-16T06:31:29.626Z","repository":{"id":47421289,"uuid":"58428483","full_name":"dawsbot/file-bytes","owner":"dawsbot","description":"Get a file's size with Node.js","archived":false,"fork":false,"pushed_at":"2022-12-03T06:33:48.000Z","size":389,"stargazers_count":5,"open_issues_count":5,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-01T06:36:05.128Z","etag":null,"topics":["bytes","filebytes","filesize","filesystem","fs","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/dawsbot.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-10T03:56:43.000Z","updated_at":"2023-03-04T06:16:17.000Z","dependencies_parsed_at":"2023-01-22T15:10:10.964Z","dependency_job_id":null,"html_url":"https://github.com/dawsbot/file-bytes","commit_stats":null,"previous_names":["dawsonbotsford/file-bytes"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawsbot%2Ffile-bytes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawsbot%2Ffile-bytes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawsbot%2Ffile-bytes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dawsbot%2Ffile-bytes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dawsbot","download_url":"https://codeload.github.com/dawsbot/file-bytes/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225411493,"owners_count":17470246,"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":["bytes","filebytes","filesize","filesystem","fs","nodejs"],"created_at":"2024-11-19T19:18:01.734Z","updated_at":"2024-11-19T19:18:02.434Z","avatar_url":"https://github.com/dawsbot.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# file-bytes\n[![npm version](https://img.shields.io/npm/v/file-bytes.svg)](https://www.npmjs.com/package/file-bytes)\n[![Build status](https://ci.appveyor.com/api/projects/status/7vxahu1f0s0k9isc?svg=true)](https://ci.appveyor.com/project/dawsonbotsford/file-bytes)\n[![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)\n\n\u003e In JavaScript - Get the bytes size of a file\n\n\u003cbr\u003e\n\n## Install\n\n```\nnpm install --save file-bytes\n```\n\n\u003cbr\u003e\n\n## Usage\n\n```js\nconst fileBytes = require('file-bytes');\n\nfileBytes('README.md').then(size =\u003e {\n  console.log(`README.md is ${size} bytes`);\n});\n//=\u003e \"README.md\" is 1806 bytes\n\n\n// sync\nconsole.log(`README.md is ${fileBytes.sync('README.md')} bytes`);\n//=\u003e \"README.md\" is 1806 bytes\n```\n\n\u003cbr\u003e\n\n## API\n\n### fileBytes(filename)\n\nReturns a promise for the filename's file size as a `number`.\n\n### fileBytes.sync(filename)\n\nReturn's the filename's file size as a `number`.\n\n#### filename\n\nType: `string`\n\n\u003cbr\u003e\n\n## Examples\n\n* Convert the output into human style using [pretty-bytes](https://github.com/sindresorhus/pretty-bytes)\n\n```js\nconst fileBytes = require('file-bytes');\nconst prettyBytes = require('pretty-bytes');\n\nconsole.log(prettyBytes(fileBytes.sync('example.txt')));\n//=\u003e 1.34 kB\n```\n\n\u003cbr\u003e\n\n* Get the file sizes of everything in the current repo with [glob](https://github.com/isaacs/node-glob)\n\n```js\nconst fileBytes = require('file-bytes');\nconst glob = require('glob');\n\nglob('./*', (err, files) =\u003e {\n  // files is an array of filenames.\n  for (let file of files) {\n    const size = fileBytes.sync(file);\n    console.log(`\"${file}\" is ${size} bytes`);\n  }\n});\n//=\u003e \"README.md\" is 1806 bytes\n//=\u003e \"package.json\" is 122 bytes\n//=\u003e \"index.js\" is 497 bytes\n```\n\n\u003cbr\u003e\n\n## License\n\nMIT © [Dawson Botsford](https://dawsbot.com)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdawsbot%2Ffile-bytes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdawsbot%2Ffile-bytes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdawsbot%2Ffile-bytes/lists"}