This repository has been archived by the owner on Dec 1, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pull LevelDOWN loader out to non-Browserified module
- Loading branch information
1 parent
ed5a542
commit 6bcd959
Showing
5 changed files
with
45 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
var LevelUPError = require('level-errors').LevelUPError | ||
, format = require('util').format | ||
, leveldown | ||
|
||
function getLevelDOWN () { | ||
if (leveldown) | ||
return leveldown | ||
|
||
var requiredVersion = require('../package.json').devDependencies.leveldown | ||
, leveldownVersion | ||
|
||
try { | ||
leveldownVersion = require('leveldown/package.json').version | ||
} catch (e) { | ||
throw requireError(e) | ||
} | ||
|
||
if (!require('semver').satisfies(leveldownVersion, requiredVersion)) { | ||
throw new LevelUPError( | ||
'Installed version of LevelDOWN (' | ||
+ leveldownVersion | ||
+ ') does not match required version (' | ||
+ requiredVersion | ||
+ ')' | ||
) | ||
} | ||
|
||
try { | ||
return leveldown = require('leveldown') | ||
} catch (e) { | ||
throw requireError(e) | ||
} | ||
} | ||
|
||
function requireError (e) { | ||
var template = 'Failed to require LevelDOWN (%s). Try `npm install leveldown` if it\'s missing' | ||
return new LevelUPError(format(template, e.message)) | ||
} | ||
|
||
module.exports = getLevelDOWN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters