JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 589
  • Score
    100M100P100Q107528F
  • License CC0-1.0

Convert a Node.js platform identifier to the human-readable platform name: `aix` → `IBM AIX`

Package Exports

  • platform-name

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (platform-name) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

read-utf8-file

NPM version Build Status Coverage Status

A Node module to read the contents of a UTF-8 file

const readUtf8File = require('read-utf8-file');

readUtf8File('/path/to/utf8-file.txt').then(contents => {
  contents; //=> 'string of file contents'
});

Installation

Use npm.

npm install read-utf8-file

API

const readUtf8File = require('read-utf8-file');

readUtf8File(filePath [, options])

filePath: String (file path)
options: Object (fs.readFile options except for encoding)
Return: Promise of String (entire file contents except for BOM)

// file-with-bom.txt: '\uFEFFabc'

readUtf8File('file-with-bom.txt').then(contents => {
  contents; //=> 'abc'
});

Note that if the file is not UTF-8 encoded, the promise will be rejected. So this module is more suitable than built-in fs.readFile for the case when your application doesn't accept non-UTF-8 files.

readUtf8File('/path/to/non-utf8-file.exe').catch(err => {
  err.message; //=> "Error: Expected a UTF-8 file, but the file at '/path/to/non-utf8-file.exe' is not UTF-8 encoded."
});

License

Copyright (c) 2016 - 2017 Shinnosuke Watanabe

Licensed under the MIT License.