This repository has been archived by the owner on Dec 2, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 44
use Standard #112
Merged
Merged
use Standard #112
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f890f26
add and use standard
ralphtheninja 7188e7d
standard: ignore test/util/idb-shim.js
ralphtheninja 486e7cc
standard --fix
ralphtheninja b9f5cbb
split initialized var declarations into multiple statements
ralphtheninja a43861e
specify indexedDB as an expected global
ralphtheninja 322c9f2
specify IDBKeyRange as an expected global
ralphtheninja 2f1b4c5
remove unused level variable
ralphtheninja c9fa559
constructor should not start with lower case
ralphtheninja cc4febc
disable warning on using new Boolean() / new String()
ralphtheninja File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
/* global indexedDB */ | ||
|
||
'use strict' | ||
|
||
var support = require('../util/support') | ||
|
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 |
---|---|---|
@@ -1,94 +1,90 @@ | ||
var dbidx = 0 | ||
, leveljs = require('../..') | ||
, location = function () { | ||
return '_leveldown_test_db_' + dbidx++ | ||
} | ||
var leveljs = require('../..') | ||
var location = function () { | ||
return '_leveldown_test_db_' + dbidx++ | ||
} | ||
|
||
, lastLocation = function () { | ||
return '_leveldown_test_db_' + dbidx | ||
} | ||
var lastLocation = function () { | ||
return '_leveldown_test_db_' + dbidx | ||
} | ||
|
||
, cleanup = function (callback) { | ||
var list = [] | ||
if (dbidx === 0) return callback() | ||
for (var i = 0; i < dbidx; i++) { | ||
list.push('_leveldown_test_db_' + i) | ||
} | ||
var cleanup = function (callback) { | ||
var list = [] | ||
if (dbidx === 0) return callback() | ||
for (var i = 0; i < dbidx; i++) { | ||
list.push('_leveldown_test_db_' + i) | ||
} | ||
|
||
function destroy() { | ||
var f = list.pop() | ||
if (list.length === 0) return callback() | ||
leveljs.destroy(f, destroy) | ||
} | ||
function destroy () { | ||
var f = list.pop() | ||
if (list.length === 0) return callback() | ||
leveljs.destroy(f, destroy) | ||
} | ||
|
||
destroy() | ||
} | ||
destroy() | ||
} | ||
|
||
, setUp = function (t) { | ||
cleanup(function (err) { | ||
t.notOk(err, 'cleanup returned an error') | ||
t.end() | ||
}) | ||
} | ||
var setUp = function (t) { | ||
cleanup(function (err) { | ||
t.notOk(err, 'cleanup returned an error') | ||
t.end() | ||
}) | ||
} | ||
|
||
, tearDown = function (t) { | ||
setUp(t) // same cleanup! | ||
} | ||
var tearDown = function (t) { | ||
setUp(t) // same cleanup! | ||
} | ||
|
||
, collectEntries = function (iterator, callback) { | ||
var data = [] | ||
, next = function () { | ||
iterator.next(function (err, key, value) { | ||
if (err) return callback(err) | ||
if (!arguments.length) { | ||
return iterator.end(function (err) { | ||
callback(err, data) | ||
}) | ||
} | ||
data.push({ key: key, value: value }) | ||
process.nextTick(next) | ||
}) | ||
} | ||
next() | ||
} | ||
var collectEntries = function (iterator, callback) { | ||
var data = [] | ||
var next = function () { | ||
iterator.next(function (err, key, value) { | ||
if (err) return callback(err) | ||
if (!arguments.length) { | ||
return iterator.end(function (err) { | ||
callback(err, data) | ||
}) | ||
} | ||
data.push({ key: key, value: value }) | ||
process.nextTick(next) | ||
}) | ||
} | ||
next() | ||
} | ||
|
||
, makeExistingDbTest = function (name, test, leveldown, testFn) { | ||
test(name, function (t) { | ||
cleanup(function () { | ||
var loc = location() | ||
, db = leveldown(loc) | ||
, done = function (close) { | ||
if (close === false) | ||
return cleanup(t.end.bind(t)) | ||
db.close(function (err) { | ||
t.notOk(err, 'no error from close()') | ||
cleanup(t.end.bind(t)) | ||
}) | ||
} | ||
db.open(function (err) { | ||
t.notOk(err, 'no error from open()') | ||
db.batch( | ||
[ | ||
{ type: 'put', key: 'one', value: '1' } | ||
, { type: 'put', key: 'two', value: '2' } | ||
, { type: 'put', key: 'three', value: '3' } | ||
] | ||
, function (err) { | ||
t.notOk(err, 'no error from batch()') | ||
testFn(db, t, done, loc) | ||
} | ||
) | ||
}) | ||
var makeExistingDbTest = function (name, test, leveldown, testFn) { | ||
test(name, function (t) { | ||
cleanup(function () { | ||
var loc = location() | ||
var db = leveldown(loc) | ||
var done = function (close) { | ||
if (close === false) { return cleanup(t.end.bind(t)) } | ||
db.close(function (err) { | ||
t.notOk(err, 'no error from close()') | ||
cleanup(t.end.bind(t)) | ||
}) | ||
} | ||
db.open(function (err) { | ||
t.notOk(err, 'no error from open()') | ||
db.batch([ | ||
{ type: 'put', key: 'one', value: '1' }, | ||
{ type: 'put', key: 'two', value: '2' }, | ||
{ type: 'put', key: 'three', value: '3' } | ||
], function (err) { | ||
t.notOk(err, 'no error from batch()') | ||
testFn(db, t, done, loc) | ||
}) | ||
}) | ||
} | ||
}) | ||
}) | ||
} | ||
|
||
module.exports = { | ||
location : location | ||
, cleanup : cleanup | ||
, lastLocation : lastLocation | ||
, setUp : setUp | ||
, tearDown : tearDown | ||
, collectEntries : collectEntries | ||
, makeExistingDbTest : makeExistingDbTest | ||
location: location, | ||
cleanup: cleanup, | ||
lastLocation: lastLocation, | ||
setUp: setUp, | ||
tearDown: tearDown, | ||
collectEntries: collectEntries, | ||
makeExistingDbTest: makeExistingDbTest | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gah. Wrong commit message.