fs-readfile-promise

WebJar for fs-readfile-promise

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

fs-readfile-promise
Last Version

Last Version

2.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

fs-readfile-promise
WebJar for fs-readfile-promise
Project URL

Project URL

https://www.webjars.org
Source Code Management

Source Code Management

https://github.com/shinnn/fs-readfile-promise

Download fs-readfile-promise

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/fs-readfile-promise/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>fs-readfile-promise</artifactId>
    <version>2.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/fs-readfile-promise/
implementation 'org.webjars.npm:fs-readfile-promise:2.0.1'
// https://jarcasting.com/artifacts/org.webjars.npm/fs-readfile-promise/
implementation ("org.webjars.npm:fs-readfile-promise:2.0.1")
'org.webjars.npm:fs-readfile-promise:jar:2.0.1'
<dependency org="org.webjars.npm" name="fs-readfile-promise" rev="2.0.1">
  <artifact name="fs-readfile-promise" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='fs-readfile-promise', version='2.0.1')
)
libraryDependencies += "org.webjars.npm" % "fs-readfile-promise" % "2.0.1"
[org.webjars.npm/fs-readfile-promise "2.0.1"]

Dependencies

compile (1)

Group / Artifact Type Version
org.webjars.npm : graceful-fs jar [4.1.2,5)

Project Modules

There are no modules declared in this project.

fs-readfile-promise

npm version Build Status Build status Coverage Status

Promisified version of fs.readFile

const readFilePromise = require('fs-readfile-promise');

(async () => {
  const buffer = await readPromise('path/to/a/file');
  buffer.toString(); //=> '... file contents ...'
})();

Based on the principle of modular programming, this module has only one functionality readFile, unlike other Promise-based file system modules. If you'd like to use a bunch of other fs methods in the Promise way, choose other modules such as q-io and promise-fs.

Installation

Use npm.

npm install fs-readfile-promise

API

const readFilePromise = require('fs-readfile-promise');

readFile(path [, options])

path: string Buffer Uint8Array URL integer
options: Object (fs.readFile options) or string (encoding)
Return: Promise<Buffer|string>

(async () => {
  await readFilePromise('src.txt'); //=> <Buffer 48 69 2e>
  await readFilePromise('src.txt', 'utf8'); //=> 'Hi.'
  await readFilePromise('src.txt', {encoding: 'base64'}); //=> 'SGku'
})();

Related projects

License

ISC License © 2017 - 2018 Shinnosuke Watanabe

Versions

Version
2.0.1