https://github.com/vweevers/fs-read-exactly
Read exactly n bytes of an fd or file
https://github.com/vweevers/fs-read-exactly
Last synced: 11 months ago
JSON representation
Read exactly n bytes of an fd or file
- Host: GitHub
- URL: https://github.com/vweevers/fs-read-exactly
- Owner: vweevers
- License: mit
- Created: 2016-12-19T21:10:22.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2020-12-11T17:48:03.000Z (over 5 years ago)
- Last Synced: 2025-06-27T06:47:02.182Z (12 months ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# fs-read-exactly
**Read exactly n bytes of an fd or file**
[](https://www.npmjs.org/package/fs-read-exactly) [](https://www.npmjs.org/package/fs-read-exactly) [](http://travis-ci.org/vweevers/fs-read-exactly) [](https://ci.appveyor.com/project/vweevers/fs-read-exactly) [](https://david-dm.org/vweevers/fs-read-exactly)
## example
```js
const readExactly = require('fs-read-exactly')
readExactly('readme.md', 0, 15, function (err, chunk) {
console.log(err) // null
console.log(chunk.toString()) // '# fs-read-exact'
})
readExactly('readme.md', 0, 1e4, function (err, chunk) {
console.log(err.code) // 'EOF'
})
```
## `readExactly(mixed, pos, length, callback)`
Where `mixed` is either a filename or a file descriptor.
## install
With [npm](https://npmjs.org) do:
```
npm install fs-read-exactly
```
## license
[MIT](http://opensource.org/licenses/MIT) © Vincent Weevers