mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-05 19:42:38 +02:00
New updates and modules
This commit is contained in:
parent
4d5d408898
commit
0abf0f90f6
959 changed files with 364301 additions and 17493 deletions
77
node_modules/abstract-leveldown/abstract-iterator.js
generated
vendored
Normal file
77
node_modules/abstract-leveldown/abstract-iterator.js
generated
vendored
Normal file
|
@ -0,0 +1,77 @@
|
|||
var nextTick = require('./next-tick')
|
||||
|
||||
function AbstractIterator (db) {
|
||||
if (typeof db !== 'object' || db === null) {
|
||||
throw new TypeError('First argument must be an abstract-leveldown compliant store')
|
||||
}
|
||||
|
||||
this.db = db
|
||||
this._ended = false
|
||||
this._nexting = false
|
||||
}
|
||||
|
||||
AbstractIterator.prototype.next = function (callback) {
|
||||
var self = this
|
||||
|
||||
if (typeof callback !== 'function') {
|
||||
throw new Error('next() requires a callback argument')
|
||||
}
|
||||
|
||||
if (self._ended) {
|
||||
nextTick(callback, new Error('cannot call next() after end()'))
|
||||
return self
|
||||
}
|
||||
|
||||
if (self._nexting) {
|
||||
nextTick(callback, new Error('cannot call next() before previous next() has completed'))
|
||||
return self
|
||||
}
|
||||
|
||||
self._nexting = true
|
||||
self._next(function () {
|
||||
self._nexting = false
|
||||
callback.apply(null, arguments)
|
||||
})
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
AbstractIterator.prototype._next = function (callback) {
|
||||
nextTick(callback)
|
||||
}
|
||||
|
||||
AbstractIterator.prototype.seek = function (target) {
|
||||
if (this._ended) {
|
||||
throw new Error('cannot call seek() after end()')
|
||||
}
|
||||
if (this._nexting) {
|
||||
throw new Error('cannot call seek() before next() has completed')
|
||||
}
|
||||
|
||||
target = this.db._serializeKey(target)
|
||||
this._seek(target)
|
||||
}
|
||||
|
||||
AbstractIterator.prototype._seek = function (target) {}
|
||||
|
||||
AbstractIterator.prototype.end = function (callback) {
|
||||
if (typeof callback !== 'function') {
|
||||
throw new Error('end() requires a callback argument')
|
||||
}
|
||||
|
||||
if (this._ended) {
|
||||
return nextTick(callback, new Error('end() already called on iterator'))
|
||||
}
|
||||
|
||||
this._ended = true
|
||||
this._end(callback)
|
||||
}
|
||||
|
||||
AbstractIterator.prototype._end = function (callback) {
|
||||
nextTick(callback)
|
||||
}
|
||||
|
||||
// Expose browser-compatible nextTick for dependents
|
||||
AbstractIterator.prototype._nextTick = nextTick
|
||||
|
||||
module.exports = AbstractIterator
|
Loading…
Add table
Add a link
Reference in a new issue