util: remove util.nextTick.

This commit is contained in:
Christopher Jeffrey 2017-06-26 03:42:51 -07:00
parent 03303d670d
commit 518484cac0
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
4 changed files with 23 additions and 30 deletions

View File

@ -7,7 +7,7 @@
'use strict';
var assert = require('assert');
var util = require('../utils/util');
var nextTick = require('../utils/nexttick');
var RBT = require('../utils/rbt');
var DUMMY = Buffer.alloc(0);
@ -130,7 +130,7 @@ MemDB.prototype.open = function open(options, callback) {
this.options = options;
util.nextTick(callback);
nextTick(callback);
};
/**
@ -139,7 +139,7 @@ MemDB.prototype.open = function open(options, callback) {
*/
MemDB.prototype.close = function close(callback) {
util.nextTick(callback);
nextTick(callback);
};
/**
@ -166,7 +166,7 @@ MemDB.prototype.get = function get(key, options, callback) {
err = new Error('MEMDB_NOTFOUND: Key not found.');
err.notFound = true;
err.type = 'NotFoundError';
util.nextTick(function() {
nextTick(function() {
callback(err);
});
return;
@ -175,7 +175,7 @@ MemDB.prototype.get = function get(key, options, callback) {
if (options.asBuffer === false)
value = value.toString('utf8');
util.nextTick(function() {
nextTick(function() {
callback(null, value);
});
};
@ -196,7 +196,7 @@ MemDB.prototype.put = function put(key, value, options, callback) {
this.insert(key, value);
util.nextTick(callback);
nextTick(callback);
};
/**
@ -214,7 +214,7 @@ MemDB.prototype.del = function del(key, options, callback) {
this.remove(key);
util.nextTick(callback);
nextTick(callback);
};
/**
@ -282,7 +282,7 @@ MemDB.prototype.approximateSize = function approximateSize(start, end, callback)
size += item.value.length;
}
util.nextTick(function() {
nextTick(function() {
callback(null, size);
});
};
@ -294,7 +294,7 @@ MemDB.prototype.approximateSize = function approximateSize(start, end, callback)
*/
MemDB.destroy = function destroy(location, callback) {
util.nextTick(callback);
nextTick(callback);
};
/**
@ -304,7 +304,7 @@ MemDB.destroy = function destroy(location, callback) {
*/
MemDB.repair = function repair(location, callback) {
util.nextTick(callback);
nextTick(callback);
};
/**
@ -355,7 +355,7 @@ Batch.prototype.write = function write(callback) {
var i, op;
if (this.written) {
util.nextTick(function() {
nextTick(function() {
callback(new Error('Already written.'));
});
return;
@ -371,7 +371,7 @@ Batch.prototype.write = function write(callback) {
this.db.remove(op.key);
break;
default:
util.nextTick(function() {
nextTick(function() {
callback(new Error('Bad operation: ' + op.type));
});
return;
@ -381,7 +381,7 @@ Batch.prototype.write = function write(callback) {
this.ops = [];
this.written = true;
util.nextTick(callback);
nextTick(callback);
return this;
};
@ -474,7 +474,7 @@ Iterator.prototype.next = function(callback) {
var key, value, result;
if (!this.iter) {
util.nextTick(function() {
nextTick(function() {
callback(new Error('Cannot call next after end.'));
});
return;
@ -510,14 +510,14 @@ Iterator.prototype.next = function(callback) {
if (!result) {
this.iter = null;
util.nextTick(callback);
nextTick(callback);
return;
}
if (options.limit !== -1) {
if (this.total >= options.limit) {
this.iter = null;
util.nextTick(callback);
nextTick(callback);
return;
}
this.total += 1;
@ -538,7 +538,7 @@ Iterator.prototype.next = function(callback) {
if (!options.valueAsBuffer)
value = value.toString('utf8');
util.nextTick(function() {
nextTick(function() {
callback(null, key, value);
});
};
@ -569,7 +569,7 @@ Iterator.prototype.seek = function seek(key) {
Iterator.prototype.end = function end(callback) {
if (this.ended) {
util.nextTick(function() {
nextTick(function() {
callback(new Error('Already ended.'));
});
return;
@ -578,7 +578,7 @@ Iterator.prototype.end = function end(callback) {
this.ended = true;
this.iter = null;
util.nextTick(callback);
nextTick(callback);
};
/**

View File

@ -139,15 +139,6 @@ util.isHex = function isHex(obj) {
&& obj.length % 2 === 0;
};
/**
* Call `setImmediate`, `process.nextTick`,
* or `setInterval` depending.
* @function
* @returns {Promise}
*/
util.nextTick = require('./nexttick');
/**
* Reverse a hex-string (used because of
* bitcoind's affinity for uint256le).

View File

@ -10,6 +10,7 @@
var assert = require('assert');
var EventEmitter = require('events').EventEmitter;
var util = require('../utils/util');
var nextTick = require('../utils/nexttick');
var Network = require('../protocol/network');
var jobs = require('./jobs');
var Parser = require('./parser-client');
@ -117,7 +118,7 @@ Master.prototype._initChildProcess = function _initChildProcess() {
process.on('uncaughtException', function(err) {
self.send(new packets.ErrorPacket(err));
util.nextTick(function() {
nextTick(function() {
process.exit(1);
});
});

View File

@ -12,6 +12,7 @@ var EventEmitter = require('events').EventEmitter;
var os = require('os');
var cp = require('child_process');
var util = require('../utils/util');
var nextTick = require('../utils/nexttick');
var co = require('../utils/co');
var Network = require('../protocol/network');
var jobs = require('./jobs');
@ -272,7 +273,7 @@ WorkerPool.prototype.execute = function execute(packet, timeout) {
if (!this.enabled || !WorkerPool.support) {
return new Promise(function(resolve, reject) {
util.nextTick(function() {
nextTick(function() {
try {
result = jobs._execute(packet);
} catch (e) {