Socket
Socket
Sign inDemoInstall

read-chunk

Package Overview
Dependencies
2
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 2.1.0

8

index.js
'use strict';
const fs = require('fs');
const pify = require('pify');
const Buffer = require('safe-buffer').Buffer;
const fsP = pify(fs);

@@ -8,3 +10,3 @@ const fsReadP = pify(fs.read, {multiArgs: true});

module.exports = (filepath, pos, len) => {
const buf = new Buffer(len);
const buf = Buffer.alloc(len);

@@ -18,3 +20,3 @@ return fsP.open(filepath, 'r')

.then(readArgs => {
// TODO: use destructuring when Node.js 6 is target
// TODO: Use destructuring when Node.js 6 is target
const bytesRead = readArgs[0];

@@ -32,3 +34,3 @@ let buf = readArgs[1];

module.exports.sync = (filepath, pos, len) => {
let buf = new Buffer(len);
let buf = Buffer.alloc(len);

@@ -35,0 +37,0 @@ const fd = fs.openSync(filepath, 'r');

{
"name": "read-chunk",
"version": "2.0.0",
"version": "2.1.0",
"description": "Read a chunk from a file",

@@ -36,3 +36,4 @@ "license": "MIT",

"dependencies": {
"pify": "^2.3.0"
"pify": "^3.0.0",
"safe-buffer": "^5.1.1"
},

@@ -42,6 +43,3 @@ "devDependencies": {

"xo": "*"
},
"xo": {
"esnext": true
}
}

@@ -5,3 +5,3 @@ # read-chunk [![Build Status](https://travis-ci.org/sindresorhus/read-chunk.svg?branch=master)](https://travis-ci.org/sindresorhus/read-chunk)

Because the built-in way is too much boilerplate.
Because the built-in way requires way too much boilerplate.

@@ -12,3 +12,3 @@

```
$ npm install --save read-chunk
$ npm install read-chunk
```

@@ -33,7 +33,7 @@

Returns a promise for a buffer.
Returns a `Promise<Buffer>`.
### readChunk.sync(filepath, position, length)
Returns a buffer.
Returns a `Buffer`.

@@ -40,0 +40,0 @@ #### filepath

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc