This repository was archived by the owner on Dec 2, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 40
Merged
Support clear() #182
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,36 @@ | ||
| 'use strict' | ||
|
|
||
| var setImmediate = require('./immediate') | ||
|
|
||
| module.exports = function clear (db, location, keyRange, options, callback) { | ||
| if (options.limit === 0) return setImmediate(callback) | ||
|
|
||
| var transaction = db.db.transaction([location], 'readwrite') | ||
| var store = transaction.objectStore(location) | ||
| var count = 0 | ||
|
|
||
| transaction.oncomplete = function () { | ||
| callback() | ||
|
vweevers marked this conversation as resolved.
|
||
| } | ||
|
|
||
| transaction.onabort = function () { | ||
| callback(transaction.error || new Error('aborted by user')) | ||
| } | ||
|
|
||
| // A key cursor is faster (skips reading values) but not supported by IE | ||
| var method = store.openKeyCursor ? 'openKeyCursor' : 'openCursor' | ||
| var direction = options.reverse ? 'prev' : 'next' | ||
|
|
||
| store[method](keyRange, direction).onsuccess = function (ev) { | ||
| var cursor = ev.target.result | ||
|
|
||
| if (cursor) { | ||
| // Wait for a request to complete before continuing, saving CPU. | ||
| store.delete(cursor.key).onsuccess = function () { | ||
| if (options.limit <= 0 || ++count < options.limit) { | ||
| cursor.continue() | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or 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,23 @@ | ||
| /* global IDBKeyRange */ | ||
|
|
||
| 'use strict' | ||
|
|
||
| var ltgt = require('ltgt') | ||
| var NONE = {} | ||
|
|
||
| module.exports = function createKeyRange (options) { | ||
| var lower = ltgt.lowerBound(options, NONE) | ||
| var upper = ltgt.upperBound(options, NONE) | ||
| var lowerOpen = ltgt.lowerBoundExclusive(options, NONE) | ||
| var upperOpen = ltgt.upperBoundExclusive(options, NONE) | ||
|
|
||
| if (lower !== NONE && upper !== NONE) { | ||
| return IDBKeyRange.bound(lower, upper, lowerOpen, upperOpen) | ||
| } else if (lower !== NONE) { | ||
| return IDBKeyRange.lowerBound(lower, lowerOpen) | ||
| } else if (upper !== NONE) { | ||
| return IDBKeyRange.upperBound(upper, upperOpen) | ||
| } else { | ||
| return null | ||
| } | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.