Share code from lib/async.js instead of inlining nextTick in Memory provider
This commit is contained in:
parent
a7a1f4b82e
commit
64a52b7d00
|
@ -1,26 +1,7 @@
|
||||||
define(function(require) {
|
define(function(require) {
|
||||||
var FILE_SYSTEM_NAME = require('src/constants').FILE_SYSTEM_NAME;
|
var FILE_SYSTEM_NAME = require('src/constants').FILE_SYSTEM_NAME;
|
||||||
|
|
||||||
// Based on https://github.com/caolan/async/blob/master/lib/async.js
|
var asyncCallback = require('async').nextTick;
|
||||||
var nextTick = (function() {
|
|
||||||
if (typeof process === 'undefined' || !(process.nextTick)) {
|
|
||||||
if (typeof setImmediate === 'function') {
|
|
||||||
return function (fn) {
|
|
||||||
// not a direct alias for IE10 compatibility
|
|
||||||
setImmediate(fn);
|
|
||||||
};
|
|
||||||
} else {
|
|
||||||
return function (fn) {
|
|
||||||
setTimeout(fn, 0);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return process.nextTick;
|
|
||||||
}());
|
|
||||||
|
|
||||||
function asyncCallback(callback) {
|
|
||||||
nextTick(callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
function MemoryContext(db, readOnly) {
|
function MemoryContext(db, readOnly) {
|
||||||
this.readOnly = readOnly;
|
this.readOnly = readOnly;
|
||||||
|
|
Loading…
Reference in New Issue