{"id":13511916,"url":"https://github.com/shinnn/fs-readfile-promise","last_synced_at":"2025-04-09T23:02:24.180Z","repository":{"id":19443762,"uuid":"22687731","full_name":"shinnn/fs-readfile-promise","owner":"shinnn","description":"Promisified version of fs.readFile","archived":false,"fork":false,"pushed_at":"2018-10-12T07:36:02.000Z","size":64,"stargazers_count":49,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-18T19:57:30.729Z","etag":null,"topics":["javascript","promise"],"latest_commit_sha":null,"homepage":"https://nodejs.org/api/fs.html#fs_fs_readfile_path_options_callback","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}},"created_at":"2014-08-06T15:27:48.000Z","updated_at":"2022-07-09T06:39:50.000Z","dependencies_parsed_at":"2022-08-21T09:40:56.782Z","dependency_job_id":null,"html_url":"https://github.com/shinnn/fs-readfile-promise","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Ffs-readfile-promise","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Ffs-readfile-promise/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Ffs-readfile-promise/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Ffs-readfile-promise/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shinnn","download_url":"https://codeload.github.com/shinnn/fs-readfile-promise/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248125581,"owners_count":21051768,"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":["javascript","promise"],"created_at":"2024-08-01T03:01:18.755Z","updated_at":"2025-04-09T23:02:24.139Z","avatar_url":"https://github.com/shinnn.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# fs-readfile-promise\n\n[![npm version](https://img.shields.io/npm/v/fs-readfile-promise.svg)](https://www.npmjs.com/package/fs-readfile-promise)\n[![Build Status](https://travis-ci.org/shinnn/fs-readfile-promise.svg?branch=master)](https://travis-ci.org/shinnn/fs-readfile-promise)\n[![Build status](https://ci.appveyor.com/api/projects/status/5sacvq0w9x7mwkwd?svg=true)](https://ci.appveyor.com/project/ShinnosukeWatanabe/fs-readfile-promise)\n[![Coverage Status](https://img.shields.io/coveralls/shinnn/fs-readfile-promise.svg)](https://coveralls.io/github/shinnn/fs-readfile-promise?branch=master)\n\nPromisified version of [`fs.readFile`][fs.readfile]\n\n```javascript\nconst readFilePromise = require('fs-readfile-promise');\n\n(async () =\u003e {\n  const buffer = await readPromise('path/to/a/file');\n  buffer.toString(); //=\u003e '... file contents ...'\n})();\n```\n\nBased on the principle of [*modular programming*](https://en.wikipedia.org/wiki/Modular_programming), this module has only one functionality [`readFile`][fs.readfile], unlike other Promise-based file system modules. If you'd like to use a bunch of other [`fs`](http://nodejs.org/api/fs.html) methods in the Promise way, choose other modules such as [q-io](https://github.com/kriskowal/q-io) and [promise-fs](https://github.com/octet-stream/promise-fs).\n\n## Installation\n\n[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/getting-started/what-is-npm).\n\n```\nnpm install fs-readfile-promise\n```\n\n## API\n\n```javascript\nconst readFilePromise = require('fs-readfile-promise');\n```\n\n### readFile(*path* [, *options*])\n\n*path*: `string` `Buffer` `Uint8Array` `URL` `integer`  \n*options*: `Object` ([fs.readFile] options) or `string` (encoding)  \nReturn: `Promise\u003cBuffer|string\u003e`\n\n```javascript\n(async () =\u003e {\n  await readFilePromise('src.txt'); //=\u003e \u003cBuffer 48 69 2e\u003e\n  await readFilePromise('src.txt', 'utf8'); //=\u003e 'Hi.'\n  await readFilePromise('src.txt', {encoding: 'base64'}); //=\u003e 'SGku'\n})();\n```\n\n## Related projects\n\n* [read-utf8-file](https://github.com/shinnn/read-utf8-file) — Promisified `fs.readFile` with automatic [BOM](https://unicode.org/faq/utf_bom.html) stripping, encoding validation and stringification\n* [read-multiple-files](https://github.com/shinnn/read-multiple-files) — Read multiple files [Observable](https://github.com/tc39/proposal-observable) way\n\n## License\n\n[ISC License](./LICENSE) © 2017 - 2018 Shinnosuke Watanabe\n\n[fs.readfile]: https://nodejs.org/api/fs.html#fs_fs_readfile_path_options_callback\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinnn%2Ffs-readfile-promise","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshinnn%2Ffs-readfile-promise","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinnn%2Ffs-readfile-promise/lists"}