{"id":15732631,"url":"https://github.com/jonschlinkert/glob-size","last_synced_at":"2025-07-06T00:33:43.112Z","repository":{"id":65990687,"uuid":"83451295","full_name":"jonschlinkert/glob-size","owner":"jonschlinkert","description":"Get the total size of a glob of files.","archived":false,"fork":false,"pushed_at":"2018-05-16T16:51:08.000Z","size":17,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-24T03:45:49.155Z","etag":null,"topics":["bytes","cli","du","files","glob","ls","size","space"],"latest_commit_sha":null,"homepage":"https://github.com/jonschlinkert/glob-size","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/jonschlinkert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-28T15:55:22.000Z","updated_at":"2021-04-12T22:25:52.000Z","dependencies_parsed_at":"2023-06-05T15:00:41.567Z","dependency_job_id":null,"html_url":"https://github.com/jonschlinkert/glob-size","commit_stats":{"total_commits":10,"total_committers":1,"mean_commits":10.0,"dds":0.0,"last_synced_commit":"52bad8d04e05a16c6f7c0baac50129339fb5c578"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fglob-size","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fglob-size/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fglob-size/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jonschlinkert%2Fglob-size/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jonschlinkert","download_url":"https://codeload.github.com/jonschlinkert/glob-size/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250559998,"owners_count":21450168,"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","cli","du","files","glob","ls","size","space"],"created_at":"2024-10-04T00:21:23.317Z","updated_at":"2025-04-24T03:45:57.555Z","avatar_url":"https://github.com/jonschlinkert.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# glob-size [![NPM version](https://img.shields.io/npm/v/glob-size.svg?style=flat)](https://www.npmjs.com/package/glob-size) [![NPM monthly downloads](https://img.shields.io/npm/dm/glob-size.svg?style=flat)](https://npmjs.org/package/glob-size) [![NPM total downloads](https://img.shields.io/npm/dt/glob-size.svg?style=flat)](https://npmjs.org/package/glob-size) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/glob-size.svg?style=flat\u0026label=Travis)](https://travis-ci.org/jonschlinkert/glob-size)\n\n\u003e Get the total size of a glob of files.\n\nPlease consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/):\n\n```sh\n$ npm install --save glob-size\n```\n\nThis is similar to the UNIX `du` command (try `du -sh *` for example), but has a JavaScript API. This can be used in linters or build tools, etc. (this is also similar to doing something like `ls -l *`).\n\n## CLI usage\n\n```sh\n$ gs\n$ gs *\n$ gs \"**\" -t\n$ gs \"**\" -d node_modules\n\nOptions:\n  --cwd, -d      directory to search from                         [default: \".\"]\n  --pattern, -p  one or more glob patterns, comma-separated\n  --table, -t    Show a text table of files sorted by size\n  --stats, -s    log out the entire stats object with all files\n  --help         Show help                                             [boolean]\n```\n\n## API usage\n\n```js\nconst size = require('glob-size');\n```\n\n**Params**\n\n* `patterns` **{string|array}**\n* `options` **{object}**\n* `returns` **{promise}**\n\n**Example**\n\n```js\n// get the size of all files in the cwd\nsize('*')\n  .then(console.log)\n  .catch(console.error)\n```\n\n### [.sync](index.js#L93)\n\nSynchronously get the size of all files that match the given glob `patterns`.\n\n**Params**\n\n* `patterns` **{String|Array}**\n* `options` **{Object}**\n* `returns` **{Object}**\n\n**Example**\n\n```js\n// get the size of all files in the cwd\nconst stats = size.sync('*');\nconsole.log(stats);\n```\n\n### [.stats.top](index.js#L114)\n\nReturns the top `n` files by size, sorted in ascending order. _(this method is exposed on the returned stats object)_\n\n**Params**\n\n* `n` **{Number}**: The number of files to return.\n* `returns` **{Array}**: Array of the top `n` files\n\n**Example**\n\n```js\nsize('node_modules/**')\n  .then(stats =\u003e console.log(stats.top(25)))\n  .catch(console.error);\n```\n\n### [.stats.tableize](index.js#L151)\n\nCreate a text table from the `stats.files` array returned by the main export, or from the [.top](#top) method. _(this method is exposed on the returned stats object)_\n\n**Params**\n\n* `files` **{Array}**\n* `returns` **{String}**\n\n**Example**\n\n```js\n// tableize the 3 largest files in \"node_modules/**\"\nsize('node_modules/**')\n  .then(stats =\u003e console.log(stats.table(stats.top(3))))\n  .catch(console.error);\n\n// tableize all files\nsize('node_modules/**')\n  .then(stats =\u003e console.log(stats.table(stats.files)))\n  .catch(console.error);\n```\n\n## Examples\n\nThe following examples assume the code is inside an `async` function.\n\n```js\n// get the size of all `.js` files in the cwd\nconsole.log(await size('*.js'));\n\n// get the size of all `.js` files in \"./foo\"\nconsole.log(await size('*.js', { cwd: 'foo' }));\n\n// show the 25 largest files in \"node_modules/**\"\nconst stats = await size('node_modules/**');\nconsole.log(stats.top(25));\n\n// show the 3 largest files in \"node_modules/**\"\nconst stats = await size('node_modules/**');\nconsole.log(stats.top(3));\n\n// show the 3 largest files in \"node_modules/**\"\nconst stats = await size('node_modules/**');\nconsole.log(stats.top(3));\n\n// tableize the 3 largest files in \"node_modules/**\"\nconst stats = await size('node_modules/**');\nconsole.log(stats.table(stats.top(50)));\n\n// tableize all files\nconst stats = await size('node_modules/**');\nconsole.log(stats.table(stats.files));\n```\n\n## About\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eContributing\u003c/strong\u003e\u003c/summary\u003e\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).\n\nPlease read the [contributing guide](.github/contributing.md) for advice on opening issues, pull requests, and coding standards.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eRunning Tests\u003c/strong\u003e\u003c/summary\u003e\n\nRunning and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:\n\n```sh\n$ npm install \u0026\u0026 npm test\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eBuilding docs\u003c/strong\u003e\u003c/summary\u003e\n\n_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_\n\nTo generate the readme, run the following command:\n\n```sh\n$ npm install -g verbose/verb#dev verb-generate-readme \u0026\u0026 verb\n```\n\n\u003c/details\u003e\n\n### Author\n\n**Jon Schlinkert**\n\n* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)\n* [GitHub Profile](https://github.com/jonschlinkert)\n* [Twitter Profile](https://twitter.com/jonschlinkert)\n\n### License\n\nCopyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).\nReleased under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on May 16, 2018._","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fglob-size","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonschlinkert%2Fglob-size","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonschlinkert%2Fglob-size/lists"}