{"id":17472508,"url":"https://github.com/shinnn/lstat-dir","last_synced_at":"2025-04-09T23:00:21.235Z","repository":{"id":65997857,"uuid":"82037425","full_name":"shinnn/lstat-dir","owner":"shinnn","description":"Run `fs.lstat()` for all contents in a given directory","archived":false,"fork":false,"pushed_at":"2019-04-24T01:55:05.000Z","size":145,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-20T10:50:18.093Z","etag":null,"topics":["async","directory","filesystem","information","lstat","mode","promise","readdir","stat"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shinnn.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-15T08:27:16.000Z","updated_at":"2021-05-08T15:59:27.000Z","dependencies_parsed_at":"2023-03-10T23:27:44.534Z","dependency_job_id":null,"html_url":"https://github.com/shinnn/lstat-dir","commit_stats":{"total_commits":31,"total_committers":1,"mean_commits":31.0,"dds":0.0,"last_synced_commit":"2ff6dff9e892c5ca6252bb94252d83bc0b2eba5f"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Flstat-dir","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Flstat-dir/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Flstat-dir/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Flstat-dir/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shinnn","download_url":"https://codeload.github.com/shinnn/lstat-dir/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248098034,"owners_count":21047360,"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":["async","directory","filesystem","information","lstat","mode","promise","readdir","stat"],"created_at":"2024-10-18T17:25:06.319Z","updated_at":"2025-04-09T23:00:21.205Z","avatar_url":"https://github.com/shinnn.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lstat-dir\n\n[![npm version](https://img.shields.io/npm/v/lstat-dir.svg)](https://www.npmjs.com/package/lstat-dir)\n[![Build Status](https://travis-ci.com/shinnn/lstat-dir.svg?branch=master)](https://travis-ci.com/shinnn/lstat-dir)\n[![codecov](https://codecov.io/gh/shinnn/lstat-dir/branch/master/graph/badge.svg)](https://codecov.io/gh/shinnn/lstat-dir)\n\nRun [`fs.promises.lstat()`](https://nodejs.org/api/fs.html#fs_fspromises_lstat_path_options) for all contents in a given directory\n\n```javascript\nconst lstatDir = require('lstat-dir');\n\n(async () =\u003e {\n  await lstatDir('node_modules/lstat-dir'); /*=\u003e Map {\n    '/Users/example/node_modules/lstat-dir/LICENSE' =\u003e {mode: 33188, size: 1086, ...},\n    '/Users/example/node_modules/lstat-dir/README.md' =\u003e {mode: 33188, size: 2060, ...}\n    '/Users/example/node_modules/lstat-dir/index.js' =\u003e {mode: 33188, size: 124, ...}\n    '/Users/example/node_modules/lstat-dir/package.json' =\u003e {mode: 33188, size: 922, ...}\n  } */\n})();\n```\n\n## Installation\n\n[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/about-npm/).\n\n```\nnpm install lstat-dir\n```\n\n## API\n\n```javascript\nconst lstatDir = require('lstat-dir');\n```\n\n### lstatDir(*dir*, [*options*])\n\n*dir*: `string | Buffer | URL` (directory path)  \n*options*: `Object` ([`readdir-sorted`](https://github.com/shinnn/readdir-sorted) options)  \nReturn: `Promise\u003cMap\u003e`\n\nThe returned `Promise` is fulfilled with a [`Map`](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map), whose [keys](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/keys) are absolute paths of contents in the directory, and whose [values](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map/values) are [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) of contents.\n\n```javascript\n/* my-dir\n   ├── file.txt\n   ├── symlink =\u003e file.txt\n   └── tmp\n       └── debug.log\n*/\n\n(async () =\u003e {\n  const stats = await lstatDir('my-dir');\n\n  stats instanceof Map; //=\u003e true\n\n  stats.keys(); /*=\u003e MapIterator {\n    '/Users/example/my-dir/file.txt',\n    '/Users/example/my-dir/symlink',\n    '/Users/example/my-dir/tmp'\n  } */\n\n  stats.get('/Users/example/my-dir/file.txt').isFile(); //=\u003e true\n  stats.get('/Users/example/my-dir/symlink').isSymbolicLink(); //=\u003e true\n  stats.get('/Users/example/my-dir/tmp').isDirectory()(); //=\u003e true\n})();\n```\n\nOptions are directly passed to the underlying [`readdir-sorted`](https://github.com/shinnn/readdir-sorted#readdirsortedpath--options) to control the order of `keys`.\n\n```javascript\n(async() =\u003e {\n  [...(await lstatDir('/path/dir')).keys()];\n  // =\u003e ['/path/dir/10.txt', '/path/dir/2.txt', '/path/dir/ä.txt', '/path/dir/z.txt']\n\n  [...(await lstatDir('/path/dir', {\n    locale: 'sv',\n    numeric: true\n  })).keys()];\n  //=\u003e ['/path/dir/2.txt', '/path/dir/10.txt', '/path/dir/z.txt', '/path/dir/ä.txt']\n})();\n```\n\n## License\n\n[ISC License](./LICENSE) © 2017 - 2019 Shinnosuke Watanabe\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinnn%2Flstat-dir","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshinnn%2Flstat-dir","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinnn%2Flstat-dir/lists"}