util: remove util.nextTick.
This commit is contained in:
parent
03303d670d
commit
518484cac0
@ -7,7 +7,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
var util = require('../utils/util');
|
var nextTick = require('../utils/nexttick');
|
||||||
var RBT = require('../utils/rbt');
|
var RBT = require('../utils/rbt');
|
||||||
var DUMMY = Buffer.alloc(0);
|
var DUMMY = Buffer.alloc(0);
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ MemDB.prototype.open = function open(options, callback) {
|
|||||||
|
|
||||||
this.options = options;
|
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) {
|
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 = new Error('MEMDB_NOTFOUND: Key not found.');
|
||||||
err.notFound = true;
|
err.notFound = true;
|
||||||
err.type = 'NotFoundError';
|
err.type = 'NotFoundError';
|
||||||
util.nextTick(function() {
|
nextTick(function() {
|
||||||
callback(err);
|
callback(err);
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@ -175,7 +175,7 @@ MemDB.prototype.get = function get(key, options, callback) {
|
|||||||
if (options.asBuffer === false)
|
if (options.asBuffer === false)
|
||||||
value = value.toString('utf8');
|
value = value.toString('utf8');
|
||||||
|
|
||||||
util.nextTick(function() {
|
nextTick(function() {
|
||||||
callback(null, value);
|
callback(null, value);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -196,7 +196,7 @@ MemDB.prototype.put = function put(key, value, options, callback) {
|
|||||||
|
|
||||||
this.insert(key, value);
|
this.insert(key, value);
|
||||||
|
|
||||||
util.nextTick(callback);
|
nextTick(callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -214,7 +214,7 @@ MemDB.prototype.del = function del(key, options, callback) {
|
|||||||
|
|
||||||
this.remove(key);
|
this.remove(key);
|
||||||
|
|
||||||
util.nextTick(callback);
|
nextTick(callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -282,7 +282,7 @@ MemDB.prototype.approximateSize = function approximateSize(start, end, callback)
|
|||||||
size += item.value.length;
|
size += item.value.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
util.nextTick(function() {
|
nextTick(function() {
|
||||||
callback(null, size);
|
callback(null, size);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -294,7 +294,7 @@ MemDB.prototype.approximateSize = function approximateSize(start, end, callback)
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
MemDB.destroy = function destroy(location, 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) {
|
MemDB.repair = function repair(location, callback) {
|
||||||
util.nextTick(callback);
|
nextTick(callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -355,7 +355,7 @@ Batch.prototype.write = function write(callback) {
|
|||||||
var i, op;
|
var i, op;
|
||||||
|
|
||||||
if (this.written) {
|
if (this.written) {
|
||||||
util.nextTick(function() {
|
nextTick(function() {
|
||||||
callback(new Error('Already written.'));
|
callback(new Error('Already written.'));
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@ -371,7 +371,7 @@ Batch.prototype.write = function write(callback) {
|
|||||||
this.db.remove(op.key);
|
this.db.remove(op.key);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
util.nextTick(function() {
|
nextTick(function() {
|
||||||
callback(new Error('Bad operation: ' + op.type));
|
callback(new Error('Bad operation: ' + op.type));
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@ -381,7 +381,7 @@ Batch.prototype.write = function write(callback) {
|
|||||||
this.ops = [];
|
this.ops = [];
|
||||||
this.written = true;
|
this.written = true;
|
||||||
|
|
||||||
util.nextTick(callback);
|
nextTick(callback);
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
@ -474,7 +474,7 @@ Iterator.prototype.next = function(callback) {
|
|||||||
var key, value, result;
|
var key, value, result;
|
||||||
|
|
||||||
if (!this.iter) {
|
if (!this.iter) {
|
||||||
util.nextTick(function() {
|
nextTick(function() {
|
||||||
callback(new Error('Cannot call next after end.'));
|
callback(new Error('Cannot call next after end.'));
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@ -510,14 +510,14 @@ Iterator.prototype.next = function(callback) {
|
|||||||
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
this.iter = null;
|
this.iter = null;
|
||||||
util.nextTick(callback);
|
nextTick(callback);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.limit !== -1) {
|
if (options.limit !== -1) {
|
||||||
if (this.total >= options.limit) {
|
if (this.total >= options.limit) {
|
||||||
this.iter = null;
|
this.iter = null;
|
||||||
util.nextTick(callback);
|
nextTick(callback);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.total += 1;
|
this.total += 1;
|
||||||
@ -538,7 +538,7 @@ Iterator.prototype.next = function(callback) {
|
|||||||
if (!options.valueAsBuffer)
|
if (!options.valueAsBuffer)
|
||||||
value = value.toString('utf8');
|
value = value.toString('utf8');
|
||||||
|
|
||||||
util.nextTick(function() {
|
nextTick(function() {
|
||||||
callback(null, key, value);
|
callback(null, key, value);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@ -569,7 +569,7 @@ Iterator.prototype.seek = function seek(key) {
|
|||||||
|
|
||||||
Iterator.prototype.end = function end(callback) {
|
Iterator.prototype.end = function end(callback) {
|
||||||
if (this.ended) {
|
if (this.ended) {
|
||||||
util.nextTick(function() {
|
nextTick(function() {
|
||||||
callback(new Error('Already ended.'));
|
callback(new Error('Already ended.'));
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@ -578,7 +578,7 @@ Iterator.prototype.end = function end(callback) {
|
|||||||
this.ended = true;
|
this.ended = true;
|
||||||
this.iter = null;
|
this.iter = null;
|
||||||
|
|
||||||
util.nextTick(callback);
|
nextTick(callback);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -139,15 +139,6 @@ util.isHex = function isHex(obj) {
|
|||||||
&& obj.length % 2 === 0;
|
&& 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
|
* Reverse a hex-string (used because of
|
||||||
* bitcoind's affinity for uint256le).
|
* bitcoind's affinity for uint256le).
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
var assert = require('assert');
|
var assert = require('assert');
|
||||||
var EventEmitter = require('events').EventEmitter;
|
var EventEmitter = require('events').EventEmitter;
|
||||||
var util = require('../utils/util');
|
var util = require('../utils/util');
|
||||||
|
var nextTick = require('../utils/nexttick');
|
||||||
var Network = require('../protocol/network');
|
var Network = require('../protocol/network');
|
||||||
var jobs = require('./jobs');
|
var jobs = require('./jobs');
|
||||||
var Parser = require('./parser-client');
|
var Parser = require('./parser-client');
|
||||||
@ -117,7 +118,7 @@ Master.prototype._initChildProcess = function _initChildProcess() {
|
|||||||
|
|
||||||
process.on('uncaughtException', function(err) {
|
process.on('uncaughtException', function(err) {
|
||||||
self.send(new packets.ErrorPacket(err));
|
self.send(new packets.ErrorPacket(err));
|
||||||
util.nextTick(function() {
|
nextTick(function() {
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -12,6 +12,7 @@ var EventEmitter = require('events').EventEmitter;
|
|||||||
var os = require('os');
|
var os = require('os');
|
||||||
var cp = require('child_process');
|
var cp = require('child_process');
|
||||||
var util = require('../utils/util');
|
var util = require('../utils/util');
|
||||||
|
var nextTick = require('../utils/nexttick');
|
||||||
var co = require('../utils/co');
|
var co = require('../utils/co');
|
||||||
var Network = require('../protocol/network');
|
var Network = require('../protocol/network');
|
||||||
var jobs = require('./jobs');
|
var jobs = require('./jobs');
|
||||||
@ -272,7 +273,7 @@ WorkerPool.prototype.execute = function execute(packet, timeout) {
|
|||||||
|
|
||||||
if (!this.enabled || !WorkerPool.support) {
|
if (!this.enabled || !WorkerPool.support) {
|
||||||
return new Promise(function(resolve, reject) {
|
return new Promise(function(resolve, reject) {
|
||||||
util.nextTick(function() {
|
nextTick(function() {
|
||||||
try {
|
try {
|
||||||
result = jobs._execute(packet);
|
result = jobs._execute(packet);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user