fix new Buffer() deprecation warning
This commit is contained in:
parent
4eb6d8999a
commit
f0f56ddb72
|
@ -1,7 +1,9 @@
|
|||
language: node_js
|
||||
node_js:
|
||||
- '10'
|
||||
- '9'
|
||||
- '8'
|
||||
- '7'
|
||||
- '6'
|
||||
- '5'
|
||||
- '4'
|
||||
- '0.12'
|
||||
|
|
|
@ -289,6 +289,10 @@ See [bench/README](bench).
|
|||
|
||||
## Changes
|
||||
|
||||
1.2.0
|
||||
- Fix `new Buffer()` deprecation warning.
|
||||
- Fix npm audit vulnerabilities
|
||||
|
||||
1.1.6
|
||||
- Fix #25 rand().then with no args
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "wordpos",
|
||||
"version": "1.1.6",
|
||||
"version": "1.2.0-beta.1",
|
||||
"description": "wordpos is a set of part-of-speech utilities for Node.js using the WordNet database.",
|
||||
"author": "Moos <mooster@42at.com>",
|
||||
"keywords": [
|
||||
|
@ -14,7 +14,7 @@
|
|||
],
|
||||
"homepage": "https://github.com/moos/wordpos",
|
||||
"engines": {
|
||||
"node": ">=0.12"
|
||||
"node": ">=4"
|
||||
},
|
||||
"bin": "./bin/wordpos-cli.js",
|
||||
"dependencies": {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*!
|
||||
* dataFile.js
|
||||
*
|
||||
* Copyright (c) 2012-2016 mooster@42at.com
|
||||
* Copyright (c) 2012-2018 mooster@42at.com
|
||||
* https://github.com/moos/wordpos
|
||||
*
|
||||
* Portions: Copyright (c) 2011, Chris Umbel
|
||||
|
@ -96,7 +96,7 @@ function readLocation(location, callback) {
|
|||
file = this,
|
||||
str = '',
|
||||
len = file.nominalLineLength,
|
||||
buffer = new Buffer(len); // TODO @deprecated as of node 6.0
|
||||
buffer = new Buffer.alloc(len);
|
||||
|
||||
readChunk(location, function(err, count) {
|
||||
if (err) {
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
*
|
||||
* implements fast index lookup of WordNet's index files
|
||||
*
|
||||
* Copyright (c) 2012-2016 mooster@42at.com
|
||||
* Copyright (c) 2012-2018 mooster@42at.com
|
||||
* https://github.com/moos/wordpos
|
||||
*
|
||||
* Portions: Copyright (c) 2011, Chris Umbel
|
||||
|
@ -53,7 +53,7 @@ function readIndexForKey(key, index, callback) {
|
|||
nextKey = data.offsets[key][1],
|
||||
nextOffset = data.offsets[nextKey][0],
|
||||
len = nextOffset - offset - 1,
|
||||
buffer = new Buffer(len);
|
||||
buffer = new Buffer.alloc(len);
|
||||
|
||||
fs.read(index.fd, buffer, 0, len, offset, function(err, count){
|
||||
if (err) return console.log(err);
|
||||
|
@ -79,7 +79,7 @@ function readIndexBetweenKeys(keyStart, keyEnd, index, callback) {
|
|||
nextKey = data.offsets[end][1],
|
||||
nextOffset = data.offsets[nextKey][0],
|
||||
len = nextOffset - offset - 1,
|
||||
buffer = new Buffer(len);
|
||||
buffer = new Buffer.alloc(len);
|
||||
|
||||
//console.log('### readIndexBetweenKeys', keyStart, keyEnd, nextKey, len)
|
||||
fs.read(index.fd, buffer, 0, len, offset, function(err, count){
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
* @version 0.2.0
|
||||
*
|
||||
* Forked: https://github.com/moos/Node-BufferedReader
|
||||
* 2018-09-02: use Buffer.alloc()
|
||||
*/
|
||||
"use strict";
|
||||
|
||||
|
@ -248,7 +249,7 @@ BufferedReader.prototype._readBytes = function (bytes, cb){
|
|||
bytes = max < bytes ? max : bytes;
|
||||
if (bytes === 0) return cb (null, null, 0);
|
||||
|
||||
var data = new Buffer (bytes);
|
||||
var data = new Buffer.alloc(bytes);
|
||||
var len = me._buffer.length;
|
||||
|
||||
if (bytes <= len){
|
||||
|
@ -320,7 +321,7 @@ BufferedReader.prototype.readBytes = function (bytes, cb){
|
|||
if (error) return cb (error, null, -1);
|
||||
|
||||
me._fd = fd;
|
||||
me._buffer = new Buffer (me._settings.bufferSize);
|
||||
me._buffer = new Buffer.alloc(me._settings.bufferSize);
|
||||
me._read (function (error){
|
||||
if (error) return cb (error, null, -1);
|
||||
me._readBytes (bytes, cb);
|
||||
|
|
Loading…
Reference in New Issue