Skip to content

Commit

Permalink
Use immediate in browsers, setImmediate in Node (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
nolanlawson authored Nov 19, 2016
1 parent 0fb34b3 commit 304a401
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
1 change: 1 addition & 0 deletions immediate-browser.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('immediate')
1 change: 1 addition & 0 deletions immediate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = setImmediate
6 changes: 4 additions & 2 deletions memdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ var inherits = require('inherits')
, ltgt = require('ltgt')
, createRBT = require('functional-red-black-tree')
, globalStore = {}
/* istanbul ignore next */
var setImmediate = global.setImmediate || process.nextTick

// In Node, use global.setImmediate. In the browser, use a consistent
// microtask library to give consistent microtask experience to all browsers
var setImmediate = require('./immediate')

function gt(value) {
return ltgt.compare(value, this._end) > 0
Expand Down
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
"url": "https://github.com/Level/memdown.git"
},
"dependencies": {
"inherits": "~2.0.1",
"ltgt": "~2.1.3",
"abstract-leveldown": "2.4.1",
"functional-red-black-tree": "^1.0.1",
"abstract-leveldown": "2.4.1"
"immediate": "^3.2.3",
"inherits": "~2.0.1",
"ltgt": "~2.1.3"
},
"devDependencies": {
"bench": "*",
Expand All @@ -37,7 +38,8 @@
"zuul": "^3.9.0"
},
"browser": {
"rimraf": false
"rimraf": false,
"./immediate.js": "./immediate-browser.js"
},
"scripts": {
"test": "npm run lint && node ./test.js --stderr | faucet",
Expand Down

0 comments on commit 304a401

Please sign in to comment.