{"id":16758418,"url":"https://github.com/kessler/node-file-index","last_synced_at":"2025-06-12T14:32:17.478Z","repository":{"id":20701265,"uuid":"23984958","full_name":"kessler/node-file-index","owner":"kessler","description":"quickly create an in memory index of files and their content","archived":false,"fork":false,"pushed_at":"2017-11-02T20:47:58.000Z","size":15,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-07T13:56:17.648Z","etag":null,"topics":[],"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/kessler.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":"2014-09-13T03:36:42.000Z","updated_at":"2017-11-02T20:47:21.000Z","dependencies_parsed_at":"2022-08-19T19:30:42.462Z","dependency_job_id":null,"html_url":"https://github.com/kessler/node-file-index","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/kessler/node-file-index","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kessler%2Fnode-file-index","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kessler%2Fnode-file-index/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kessler%2Fnode-file-index/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kessler%2Fnode-file-index/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kessler","download_url":"https://codeload.github.com/kessler/node-file-index/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kessler%2Fnode-file-index/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259482487,"owners_count":22864762,"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-13T04:05:14.919Z","updated_at":"2025-06-12T14:32:17.452Z","avatar_url":"https://github.com/kessler.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# file-index\n\nQuickly create an in memory index of files and (optionally) their content\n\nUses [minimatch](https://github.com/isaacs/minimatch) to filter files included in the index\n\n### simple\n```javascript\nvar FileIndex = require('file-index')\n\nFileIndex.load(['/some/path'], function (err, results) {\n\t// loads and parses json files\n\t// loads all the rest of the files as buffers\n\t// results: { '/some/path/1.json': { a: 1}, '/some/path/2.txt': buffer }\n})\n\nFileIndex.scan(['/some/path'], function(err, files) {\n\t// scan all files in path recursively and returns an index\n\t// { '/some/path/1': stat, '/some/path/2': stat }\n\t// where stat is the result of running fs.stat on each file\n})\n```\n\n### customize\n```javascript\nfunction myCustomHandler(fullPathFilename, callback) {\n\tfs.readFile(fullPathFilename, function (err, content) {\n\t\tif (err) return callback(err)\n\n\t\tcallback(null, customParse(content))\n\t})\t\n}\n\nvar handlers = FileIndex\t\n\t.handle('*.json', FileIndex.loadJsonFile) // load and parse .json files\t\n\t.handle('*.foo', FileIndex.loadRawFile)\t// .foo as buffers\n\t.handle('*.bar', FileIndex.loadRawUtf8File) // .bar as text\n\t.handle('*', myCustomHandler) // a non mandatory fallthrough custom handler\n\t.create()\n\n// mix directories and files\nFileIndex.load(['/some/path/', '/some/file.bar', '/yet/another/path'], handlers, function(err, results) {\n\tconsole.log(err, results)\n\n\t/* \n\t\tresults:\n\t\t\n\t\t{\n\t\t\t'/some/path/1.json': { blabla: 1 },\n\t\t\t'/some/path/2.json': { blabla: 2},\n\t\t\t'/some/file.bar': 'foorbar',\n\t\t\t'/yet/another/path/x.log': 'a b c'\n\t\t}\n\t*/\n})\n```\n\n// TODO: improve test coverage\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkessler%2Fnode-file-index","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkessler%2Fnode-file-index","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkessler%2Fnode-file-index/lists"}