sublevel-pouchdb
Advanced tools
Comparing version 7.3.1 to 8.0.0
@@ -5,3 +5,2 @@ import ltgt from 'ltgt'; | ||
import ReadableStreamCore from 'readable-stream'; | ||
import inherits from 'inherits'; | ||
@@ -139,10 +138,9 @@ function isFunction(f) { | ||
function NotFoundError() { | ||
Error.call(this); | ||
class NotFoundError extends Error { | ||
constructor() { | ||
super(); | ||
this.name = 'NotFoundError'; | ||
} | ||
} | ||
inherits(NotFoundError, Error); | ||
NotFoundError.prototype.name = 'NotFoundError'; | ||
var EventEmitter = events.EventEmitter; | ||
@@ -282,86 +280,103 @@ var version = "6.5.4"; | ||
function ReadStream(options, makeData) { | ||
if (!(this instanceof ReadStream)) { | ||
return new ReadStream(options, makeData); | ||
function createClass(parent, init) { | ||
let klass = function (...args) { | ||
if (!(this instanceof klass)) { | ||
return new klass(...args); | ||
} | ||
init.apply(this, args); | ||
}; | ||
klass.prototype = Object.create(parent.prototype, { | ||
constructor: { value: klass } | ||
}); | ||
return klass; | ||
} | ||
class ReadStreamInternal extends Readable { | ||
constructor(options, makeData) { | ||
super({ objectMode: true, highWaterMark: options.highWaterMark }); | ||
this._setup(options, makeData); | ||
} | ||
Readable.call(this, { objectMode: true, highWaterMark: options.highWaterMark }); | ||
_setup(options, makeData) { | ||
super.constructor({ objectMode: true, highWaterMark: options.highWaterMark }); | ||
// purely to keep `db` around until we're done so it's not GCed if the user doesn't keep a ref | ||
this._waiting = false; | ||
this._options = options; | ||
this._makeData = makeData; | ||
} | ||
inherits(ReadStream, Readable); | ||
ReadStream.prototype.setIterator = function (it) { | ||
this._iterator = it; | ||
/* istanbul ignore if */ | ||
if (this._destroyed) { | ||
return it.end(function () {}); | ||
} | ||
/* istanbul ignore if */ | ||
if (this._waiting) { | ||
// purely to keep `db` around until we're done so it's not GCed if the user doesn't keep a ref | ||
this._waiting = false; | ||
return this._read(); | ||
this._options = options; | ||
this._makeData = makeData; | ||
} | ||
return this; | ||
}; | ||
ReadStream.prototype._read = function read() { | ||
var self = this; | ||
/* istanbul ignore if */ | ||
if (self._destroyed) { | ||
return; | ||
setIterator(it) { | ||
this._iterator = it; | ||
/* istanbul ignore if */ | ||
if (this._destroyed) { | ||
return it.end(function () {}); | ||
} | ||
/* istanbul ignore if */ | ||
if (this._waiting) { | ||
this._waiting = false; | ||
return this._read(); | ||
} | ||
return this; | ||
} | ||
/* istanbul ignore if */ | ||
if (!self._iterator) { | ||
return this._waiting = true; | ||
} | ||
self._iterator.next(function (err, key, value) { | ||
if (err || (key === undefined && value === undefined)) { | ||
if (!err && !self._destroyed) { | ||
self.push(null); | ||
} | ||
return self._cleanup(err); | ||
_cleanup(err) { | ||
if (this._destroyed) { | ||
return; | ||
} | ||
value = self._makeData(key, value); | ||
if (!self._destroyed) { | ||
self.push(value); | ||
this._destroyed = true; | ||
var self = this; | ||
/* istanbul ignore if */ | ||
if (err && err.message !== 'iterator has ended') { | ||
self.emit('error', err); | ||
} | ||
}); | ||
}; | ||
ReadStream.prototype._cleanup = function (err) { | ||
if (this._destroyed) { | ||
return; | ||
/* istanbul ignore else */ | ||
if (self._iterator) { | ||
self._iterator.end(function () { | ||
self._iterator = null; | ||
self.emit('close'); | ||
}); | ||
} else { | ||
self.emit('close'); | ||
} | ||
} | ||
this._destroyed = true; | ||
var self = this; | ||
/* istanbul ignore if */ | ||
if (err && err.message !== 'iterator has ended') { | ||
self.emit('error', err); | ||
destroy() { | ||
this._cleanup(); | ||
} | ||
/* istanbul ignore else */ | ||
if (self._iterator) { | ||
self._iterator.end(function () { | ||
self._iterator = null; | ||
self.emit('close'); | ||
_read() { | ||
var self = this; | ||
/* istanbul ignore if */ | ||
if (self._destroyed) { | ||
return; | ||
} | ||
/* istanbul ignore if */ | ||
if (!self._iterator) { | ||
return this._waiting = true; | ||
} | ||
self._iterator.next(function (err, key, value) { | ||
if (err || (key === undefined && value === undefined)) { | ||
if (!err && !self._destroyed) { | ||
self.push(null); | ||
} | ||
return self._cleanup(err); | ||
} | ||
value = self._makeData(key, value); | ||
if (!self._destroyed) { | ||
self.push(value); | ||
} | ||
}); | ||
} else { | ||
self.emit('close'); | ||
} | ||
}; | ||
} | ||
ReadStream.prototype.destroy = function () { | ||
this._cleanup(); | ||
}; | ||
const ReadStream = createClass(ReadStreamInternal, function (options, makeData) { | ||
ReadStreamInternal.prototype._setup.call(this, options, makeData); | ||
}); | ||
@@ -368,0 +383,0 @@ var precodec = { |
165
lib/index.js
@@ -9,3 +9,2 @@ 'use strict'; | ||
var ReadableStreamCore = _interopDefault(require('readable-stream')); | ||
var inherits = _interopDefault(require('inherits')); | ||
@@ -143,10 +142,9 @@ function isFunction(f) { | ||
function NotFoundError() { | ||
Error.call(this); | ||
class NotFoundError extends Error { | ||
constructor() { | ||
super(); | ||
this.name = 'NotFoundError'; | ||
} | ||
} | ||
inherits(NotFoundError, Error); | ||
NotFoundError.prototype.name = 'NotFoundError'; | ||
var EventEmitter = events.EventEmitter; | ||
@@ -286,86 +284,103 @@ var version = "6.5.4"; | ||
function ReadStream(options, makeData) { | ||
if (!(this instanceof ReadStream)) { | ||
return new ReadStream(options, makeData); | ||
function createClass(parent, init) { | ||
let klass = function (...args) { | ||
if (!(this instanceof klass)) { | ||
return new klass(...args); | ||
} | ||
init.apply(this, args); | ||
}; | ||
klass.prototype = Object.create(parent.prototype, { | ||
constructor: { value: klass } | ||
}); | ||
return klass; | ||
} | ||
class ReadStreamInternal extends Readable { | ||
constructor(options, makeData) { | ||
super({ objectMode: true, highWaterMark: options.highWaterMark }); | ||
this._setup(options, makeData); | ||
} | ||
Readable.call(this, { objectMode: true, highWaterMark: options.highWaterMark }); | ||
_setup(options, makeData) { | ||
super.constructor({ objectMode: true, highWaterMark: options.highWaterMark }); | ||
// purely to keep `db` around until we're done so it's not GCed if the user doesn't keep a ref | ||
this._waiting = false; | ||
this._options = options; | ||
this._makeData = makeData; | ||
} | ||
inherits(ReadStream, Readable); | ||
ReadStream.prototype.setIterator = function (it) { | ||
this._iterator = it; | ||
/* istanbul ignore if */ | ||
if (this._destroyed) { | ||
return it.end(function () {}); | ||
} | ||
/* istanbul ignore if */ | ||
if (this._waiting) { | ||
// purely to keep `db` around until we're done so it's not GCed if the user doesn't keep a ref | ||
this._waiting = false; | ||
return this._read(); | ||
this._options = options; | ||
this._makeData = makeData; | ||
} | ||
return this; | ||
}; | ||
ReadStream.prototype._read = function read() { | ||
var self = this; | ||
/* istanbul ignore if */ | ||
if (self._destroyed) { | ||
return; | ||
setIterator(it) { | ||
this._iterator = it; | ||
/* istanbul ignore if */ | ||
if (this._destroyed) { | ||
return it.end(function () {}); | ||
} | ||
/* istanbul ignore if */ | ||
if (this._waiting) { | ||
this._waiting = false; | ||
return this._read(); | ||
} | ||
return this; | ||
} | ||
/* istanbul ignore if */ | ||
if (!self._iterator) { | ||
return this._waiting = true; | ||
} | ||
self._iterator.next(function (err, key, value) { | ||
if (err || (key === undefined && value === undefined)) { | ||
if (!err && !self._destroyed) { | ||
self.push(null); | ||
} | ||
return self._cleanup(err); | ||
_cleanup(err) { | ||
if (this._destroyed) { | ||
return; | ||
} | ||
value = self._makeData(key, value); | ||
if (!self._destroyed) { | ||
self.push(value); | ||
this._destroyed = true; | ||
var self = this; | ||
/* istanbul ignore if */ | ||
if (err && err.message !== 'iterator has ended') { | ||
self.emit('error', err); | ||
} | ||
}); | ||
}; | ||
ReadStream.prototype._cleanup = function (err) { | ||
if (this._destroyed) { | ||
return; | ||
/* istanbul ignore else */ | ||
if (self._iterator) { | ||
self._iterator.end(function () { | ||
self._iterator = null; | ||
self.emit('close'); | ||
}); | ||
} else { | ||
self.emit('close'); | ||
} | ||
} | ||
this._destroyed = true; | ||
var self = this; | ||
/* istanbul ignore if */ | ||
if (err && err.message !== 'iterator has ended') { | ||
self.emit('error', err); | ||
destroy() { | ||
this._cleanup(); | ||
} | ||
/* istanbul ignore else */ | ||
if (self._iterator) { | ||
self._iterator.end(function () { | ||
self._iterator = null; | ||
self.emit('close'); | ||
_read() { | ||
var self = this; | ||
/* istanbul ignore if */ | ||
if (self._destroyed) { | ||
return; | ||
} | ||
/* istanbul ignore if */ | ||
if (!self._iterator) { | ||
return this._waiting = true; | ||
} | ||
self._iterator.next(function (err, key, value) { | ||
if (err || (key === undefined && value === undefined)) { | ||
if (!err && !self._destroyed) { | ||
self.push(null); | ||
} | ||
return self._cleanup(err); | ||
} | ||
value = self._makeData(key, value); | ||
if (!self._destroyed) { | ||
self.push(value); | ||
} | ||
}); | ||
} else { | ||
self.emit('close'); | ||
} | ||
}; | ||
} | ||
ReadStream.prototype.destroy = function () { | ||
this._cleanup(); | ||
}; | ||
const ReadStream = createClass(ReadStreamInternal, function (options, makeData) { | ||
ReadStreamInternal.prototype._setup.call(this, options, makeData); | ||
}); | ||
@@ -372,0 +387,0 @@ var precodec = { |
{ | ||
"name": "sublevel-pouchdb", | ||
"version": "7.3.1", | ||
"version": "8.0.0", | ||
"description": "Fork of level-sublevel with ony the subset of the API that PouchDB uses", | ||
@@ -22,3 +22,2 @@ "main": "./lib/index.js", | ||
"dependencies": { | ||
"inherits": "2.0.4", | ||
"level-codec": "9.0.2", | ||
@@ -25,0 +24,0 @@ "ltgt": "2.2.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31854
3
678
- Removedinherits@2.0.4