{"id":16327057,"url":"https://github.com/mrmlnc/scandir-native","last_synced_at":"2025-03-22T22:31:09.019Z","repository":{"id":57144104,"uuid":"105386290","full_name":"mrmlnc/scandir-native","owner":"mrmlnc","description":"A fs.scandir method with some features.","archived":false,"fork":false,"pushed_at":"2019-01-08T19:34:30.000Z","size":13,"stargazers_count":8,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T15:21:31.381Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","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/mrmlnc.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":"2017-09-30T17:11:02.000Z","updated_at":"2021-06-08T05:32:06.000Z","dependencies_parsed_at":"2022-09-06T00:11:30.242Z","dependency_job_id":null,"html_url":"https://github.com/mrmlnc/scandir-native","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrmlnc%2Fscandir-native","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrmlnc%2Fscandir-native/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrmlnc%2Fscandir-native/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrmlnc%2Fscandir-native/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrmlnc","download_url":"https://codeload.github.com/mrmlnc/scandir-native/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245028490,"owners_count":20549528,"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":[],"created_at":"2024-10-10T23:10:17.833Z","updated_at":"2025-03-22T22:31:08.759Z","avatar_url":"https://github.com/mrmlnc.png","language":"C++","funding_links":["https://paypal.me/mrmlnc"],"categories":[],"sub_categories":[],"readme":"# scandir-native\n\nA `fs.scandir` method with some features.\n\n## Donate\n\nIf you want to thank me, or promote your Issue.\n\n[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://paypal.me/mrmlnc)\n\n\u003e Sorry, but I have work and support for plugins and modules requires some time after work. I will be glad of your support or PR's.\n\n## Install\n\n```\n$ npm i scandir-native\n```\n\n:warning: Compiling on Windows machines requires the [node-gyp prerequisites](https://github.com/nodejs/node-gyp#on-windows).\n\n## Supports\n\n  * Node.js (4, 6, 8 and etc.)\n  * Node.js with ChakraCore (below 8.4.0 on macOS and Linux (works fine on Windows), see this [issue](https://github.com/nodejs/node-chakracore/issues/417))\n\n## Why?\n\n  * Temporary solution for [«A proposal to add fs.scandir method to FS module»](https://github.com/nodejs/node/issues/15699).\n\n## Usage\n\n```js\nconst scandir = require('scandir-native');\n\nscandir.scandir('.', (err, entries) =\u003e {\n\tif (err) {\n\t\tconsole.error(err); // Standard FS errors\n\t\treturn;\n\t}\n\n\tconsole.dir(entries, { colors: true });\n\t// [{ name: 'filepath', type: 2 }, { name: 'dirpath', type: 1 }]\n});\n```\n\n## API\n\n#### `FS_TYPE_CONSTANTS`\n\n```js\n0 is 'FS_UNKNOWN'\n1 is 'FS_FILE'\n2 is 'FS_DIR'\n3 is 'FS_LINK'\n4 is 'FS_FIFO'\n5 is 'FS_SOCKET'\n6 is 'FS_CHAR'\n7 is 'FS_BLOCK'\n```\n\nEnum for entry type builded from and for [`uv_dirent_type_t`](https://github.com/libuv/libuv/blob/e9cda2cfe71dce809a6ecba4ff913e24e36c233e/include/uv.h#L1019-L1028).\n\n#### `IScandirEntry`\n\n  * name `String`\n  * type [`FILE_TYPE_CONSTANTS`](https://github.com/mrmlnc/scandir-native#fs_type_constants)\n\nTypeScript interface for each entry in the directory.\n\n#### `.scandir(path, callback) =\u003e void`\n\n  * path `String`\n  * callback `Function`\n    * err `Error`\n    * entries [`IScandirEntry[]`](https://github.com/mrmlnc/scandir-native#iscandirentry)\n\nAsynchronous [`scandir(3)`](http://man7.org/linux/man-pages/man3/scandir.3.html). Reads the contents of a directory. The callback gets two arguments (`err`, `entries`) where `entries` is an array of objects (`name` and `type`) of the files in the directory excluding `.` and `..`.\n\n#### `.scandirSync(path) =\u003e IScandirEntry[]`\n\n  * path `String`\n  * returns [`IScandirEntry[]`](https://github.com/mrmlnc/scandir-native#iscandirentry)\n\nSynchronous [`scandir(3)`](http://man7.org/linux/man-pages/man3/scandir.3.html). Returns an array of objects (`name` and `type`) excluding `.` and `..`.\n\n## Example\n\n```ts\nconst scandir = require('scandir-native');\n\nconst dirs: string[] = [];\nconst nonDirs: string[] = [];\n\nscandir.scandir('.', (err, entries) =\u003e {\n\tif (err) {\n\t\tconsole.error(err); // Standard FS errors\n\t\treturn;\n\t}\n\n\tentries.forEach((entry) =\u003e {\n\t\tif (entry.type === scandir.FS_TYPE_CONSTANTS.FS_DIR) {\n\t\t\tdirs.push(entry.name);\n\t\t} else {\n\t\t\tnonDirs.push(entry.name);\n\t\t}\n\t})\n});\n```\n\n## Changelog\n\nSee the [Releases section of our GitHub project](https://github.com/mrmlnc/scandir-native/releases) for changelogs for each release version.\n\n## License\n\nThis software is released under the terms of the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrmlnc%2Fscandir-native","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrmlnc%2Fscandir-native","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrmlnc%2Fscandir-native/lists"}