Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/shinnn/assert-fs-readfile-option
Test if value is valid for fs.readFile option
https://github.com/shinnn/assert-fs-readfile-option
assertion fs invalidation javascript nodejs readfile validation
Last synced: 27 days ago
JSON representation
Test if value is valid for fs.readFile option
- Host: GitHub
- URL: https://github.com/shinnn/assert-fs-readfile-option
- Owner: shinnn
- License: isc
- Created: 2014-11-20T04:15:24.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2019-01-08T08:23:55.000Z (almost 6 years ago)
- Last Synced: 2024-10-11T14:08:11.505Z (about 1 month ago)
- Topics: assertion, fs, invalidation, javascript, nodejs, readfile, validation
- Language: JavaScript
- Size: 41 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# assert-fs-readfile-option
[![npm version](https://img.shields.io/npm/v/assert-fs-readfile-option.svg)](https://www.npmjs.com/package/assert-fs-readfile-option)
[![Build Status](https://travis-ci.com/shinnn/assert-fs-readfile-option.svg?branch=master)](https://travis-ci.com/shinnn/assert-fs-readfile-option)Test if a value is valid for [`fs.readFile()`][fs.readFile] options
```javascript
const assertFsReadFileOption = require('assert-fs-readfile-option');assertFsReadFileOption({encoding: 'utf8', flag: 'r'});
// doesn't throwassertFsReadFileOption({flag: 'foo'});
// throws `TypeError [ERR_INVALID_OPT_VALUE]: The value "foo" is invalid for option "flags"`assertFsReadFileOption('base64');
// doesn't throwassertFsReadFileOption('base65');
// throws `TypeError [ERR_INVALID_OPT_VALUE_ENCODING]: The value "base65" is invalid for option "encoding"`assertFsReadFileOption();
// doesn't throw
```## Installation
[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/about-npm/).
```
npm install assert-fs-readfile-option
```## API
```javascript
const assertFsReadFileOption = require('assert-fs-readfile-option');
```### assertFsReadFileOption([*maybeOption*])
*maybeOption*: any types
It throws an error when the provided argument is not a valid value for [`fs.readFile()`][fs.readFile] options.
## License
[ISC License](./LICENSE) © 2017 - 2019 Shinnosuke Watanabe
[fs.readFile]: https://nodejs.org/api/fs.html#fs_fs_readfile_path_options_callback