FRE-600: Fix code review blockers

- Consolidated duplicate UndoManagers to single instance
- Fixed connection promise to only resolve on 'connected' status
- Fixed WebSocketProvider import (WebsocketProvider)
- Added proper doc.destroy() cleanup
- Renamed isPresenceInitialized property to avoid conflict

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
2026-04-25 00:08:01 -04:00
parent 65b552bb08
commit 7c684a42cc
48450 changed files with 5679671 additions and 383 deletions

494
node_modules/level-js/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,494 @@
# Changelog
_**If you are upgrading:** please see [`UPGRADING.md`](UPGRADING.md)._
## [5.0.2] - 2020-04-03
### Changed
- Use `nextTick` of `abstract-leveldown` ([#195](https://github.com/Level/level-js/issues/195)) ([**@vweevers**](https://github.com/vweevers)) (same underlying code)
- Upgrade `nyc` devDependency from `^14.0.0` to `^15.0.0` ([#187](https://github.com/Level/level-js/issues/187)) ([**@vweevers**](https://github.com/vweevers))
- Upgrade `airtap` devDependency from `^2.0.0` to `^3.0.0` ([#189](https://github.com/Level/level-js/issues/189)) ([**@vweevers**](https://github.com/vweevers))
### Fixed
- Add `buffer` for browsers ([#191](https://github.com/Level/level-js/issues/191)) ([**@hugomrdias**](https://github.com/hugomrdias))
## [5.0.1] - 2019-11-29
### Fixed
- Restore support of empty prefix option ([#184](https://github.com/Level/level-js/issues/184)) ([**@achingbrain**](https://github.com/achingbrain)). This restores a previous behavior (of `level-js` &lt; 3) that unknown to us, was provided by the since-removed `IDBWrapper`.
## [5.0.0] - 2019-10-04
### Changed
- **Breaking**: Drop support of key & value types other than string and Buffer ([#179](https://github.com/Level/level-js/issues/179)) ([**@vweevers**](https://github.com/vweevers))
- Replace mentions of `level-browserify` with `level` ([`58b3e07`](https://github.com/Level/level-js/commit/58b3e07)) ([**@vweevers**](https://github.com/vweevers))
- Upgrade `hallmark` devDependency from `^0.1.0` to `^2.0.0` ([#172](https://github.com/Level/level-js/issues/172), [#177](https://github.com/Level/level-js/issues/177)) ([**@vweevers**](https://github.com/vweevers))
- Upgrade `nyc` devDependency from `^13.1.0` to `^14.0.0` ([#169](https://github.com/Level/level-js/issues/169)) ([**@vweevers**](https://github.com/vweevers))
- Upgrade `standard` devDependency from `^12.0.1` to `^14.0.2` ([#171](https://github.com/Level/level-js/issues/171), [`aacb0ea`](https://github.com/Level/level-js/commit/aacb0ea)) ([**@vweevers**](https://github.com/vweevers), [**@ralphtheninja**](https://github.com/ralphtheninja))
### Added
- Add manifest ([Level/community#83](https://github.com/Level/community/issues/83)) ([#183](https://github.com/Level/level-js/issues/183)) ([**@vweevers**](https://github.com/vweevers))
- Support `clear()` ([Level/community#79](https://github.com/Level/community/issues/79)) ([#182](https://github.com/Level/level-js/issues/182)) ([**@vweevers**](https://github.com/vweevers))
## [4.0.1] - 2019-03-31
### Changed
- Apply common project tweaks ([#164](https://github.com/Level/level-js/issues/164), [#165](https://github.com/Level/level-js/issues/165)) ([**@vweevers**](https://github.com/vweevers))
### Removed
- Remove outdated sentence about nullish values from README ([#166](https://github.com/Level/level-js/issues/166)) ([**@vweevers**](https://github.com/vweevers))
## [4.0.0] - 2018-12-30
### Changed
- Upgrade `abstract-leveldown` from `~5.0.0` to `~6.0.1` ([#155](https://github.com/Level/level-js/issues/155), [#157](https://github.com/Level/level-js/issues/157)) ([**@vweevers**](https://github.com/vweevers))
- Don't serialize boolean or `NaN` keys, have IDB reject them ([#155](https://github.com/Level/level-js/issues/155)) ([**@vweevers**](https://github.com/vweevers))
- Update test of `key cannot be an empty Array` error ([#155](https://github.com/Level/level-js/issues/155)) ([**@vweevers**](https://github.com/vweevers))
- Change `iterator.db` to reference `level-js` instance, not IDB ([#155](https://github.com/Level/level-js/issues/155)) ([**@vweevers**](https://github.com/vweevers))
- Handle `location` in constructor, as it was removed from `abstract-leveldown` ([#155](https://github.com/Level/level-js/issues/155)) ([**@vweevers**](https://github.com/vweevers))
- Use `level-concat-iterator` and `testCommon.factory()` in custom tests ([#155](https://github.com/Level/level-js/issues/155)) ([**@vweevers**](https://github.com/vweevers))
- Invoke abstract tests from single function ([#155](https://github.com/Level/level-js/issues/155)) ([**@vweevers**](https://github.com/vweevers))
- Upgrade `airtap` devDependency from `0.0.7` to `^2.0.0` ([`2b71337`](https://github.com/Level/level-js/commit/2b71337), [#161](https://github.com/Level/level-js/issues/161)) ([**@ralphtheninja**](https://github.com/ralphtheninja), [**@vweevers**](https://github.com/vweevers))
- Upgrade `standard` devDependency from `^11.0.1` to `^12.0.1` ([#153](https://github.com/Level/level-js/issues/153)) ([**@vweevers**](https://github.com/vweevers), [**@ralphtheninja**](https://github.com/ralphtheninja))
- Replace `remark-cli` devDependency with `hallmark` ([#151](https://github.com/Level/level-js/issues/151), [#153](https://github.com/Level/level-js/issues/153)) ([**@vweevers**](https://github.com/vweevers))
### Added
- Test and document native sort order ([#157](https://github.com/Level/level-js/issues/157)) ([**@vweevers**](https://github.com/vweevers))
- Add iPhone and Android `latest` to test matrix ([#162](https://github.com/Level/level-js/issues/162)) ([**@vweevers**](https://github.com/vweevers))
- Add `nyc` and `coveralls` devDependencies ([#150](https://github.com/Level/level-js/issues/150), [#153](https://github.com/Level/level-js/issues/153)) ([`eb1aead`](https://github.com/Level/level-js/commit/eb1aead)) ([**@ralphtheninja**](https://github.com/ralphtheninja), [**@vweevers**](https://github.com/vweevers))
- Add Contributing section to README ([`c94a9a4`](https://github.com/Level/level-js/commit/c94a9a4)) ([**@ralphtheninja**](https://github.com/ralphtheninja))
### Removed
- Remove now irrelevant serialization of nullish values ([#155](https://github.com/Level/level-js/issues/155)) ([**@vweevers**](https://github.com/vweevers))
- Remove unused `IndexedDBShim` from tests ([#162](https://github.com/Level/level-js/issues/162)) ([**@vweevers**](https://github.com/vweevers))
## [3.0.0] - 2018-06-17
### Changed
- Destroy with `location` and `prefix` only ([#116](https://github.com/Level/level-js/issues/116)) ([**@ralphtheninja**](https://github.com/ralphtheninja))
- Replace `util.inherits` with `inherits` module ([`8db16c1`](https://github.com/Level/level-js/commit/8db16c1)) ([**@ralphtheninja**](https://github.com/ralphtheninja))
- Change copyright years to "2012-present" ([`7017edd`](https://github.com/Level/level-js/commit/7017edd)) ([**@ralphtheninja**](https://github.com/ralphtheninja))
- Simplify license description ([#141](https://github.com/Level/level-js/issues/141)) ([**@vweevers**](https://github.com/vweevers))
- Update `package.json` description and keywords ([#141](https://github.com/Level/level-js/issues/141)) ([**@vweevers**](https://github.com/vweevers))
### Added
- Add `CHANGELOG.md` ([#107](https://github.com/Level/level-js/issues/107), [#115](https://github.com/Level/level-js/issues/115)) ([**@ralphtheninja**](https://github.com/ralphtheninja), [**@vweevers**](https://github.com/vweevers))
- Add `UPGRADING.md` ([#143](https://github.com/Level/level-js/issues/143)) ([**@vweevers**](https://github.com/vweevers))
- Add `CONTRIBUTORS.md` (replaces `COLLABORATORS.md`) ([#141](https://github.com/Level/level-js/issues/141)) ([**@vweevers**](https://github.com/vweevers))
- Add `standard` ([#112](https://github.com/Level/level-js/issues/112)) ([**@ralphtheninja**](https://github.com/ralphtheninja))
- Document constructor ([#119](https://github.com/Level/level-js/issues/119)) ([**@ralphtheninja**](https://github.com/ralphtheninja))
- Document type support ([#125](https://github.com/Level/level-js/issues/125), [#143](https://github.com/Level/level-js/issues/143)) ([**@vweevers**](https://github.com/vweevers))
- Add `remark` tooling ([#141](https://github.com/Level/level-js/issues/141), [#143](https://github.com/Level/level-js/issues/143), [#147](https://github.com/Level/level-js/issues/147)) ([**@vweevers**](https://github.com/vweevers))
- Test default and custom prefix ([#124](https://github.com/Level/level-js/issues/124)) ([**@vweevers**](https://github.com/vweevers))
- Test all key types of IndexedDB Second Edition ([#130](https://github.com/Level/level-js/issues/130)) ([**@vweevers**](https://github.com/vweevers))
- Test illegal value types ([#118](https://github.com/Level/level-js/issues/118)) ([**@vweevers**](https://github.com/vweevers))
- Test illegal and stringified key types ([#139](https://github.com/Level/level-js/issues/139)) ([**@vweevers**](https://github.com/vweevers))
- Test `Buffer`, `ArrayBuffer` and `Uint8Array` values with `asBuffer` option ([#146](https://github.com/Level/level-js/issues/146)) ([**@vweevers**](https://github.com/vweevers))
### Fixed
- Add original copyright owner (Max Ogden) ([#141](https://github.com/Level/level-js/issues/141)) ([**@vweevers**](https://github.com/vweevers))
- Replace `level.js` in documentation to match npm name `level-js` ([#121](https://github.com/Level/level-js/issues/121)) ([**@ralphtheninja**](https://github.com/ralphtheninja))
- Force airtap's browserify to use latest `buffer@5` ([#122](https://github.com/Level/level-js/issues/122)) ([**@vweevers**](https://github.com/vweevers))
- Don't stringify keys (except fallbacks, booleans and `NaN`) ([#130](https://github.com/Level/level-js/issues/130)) ([**@vweevers**](https://github.com/vweevers))
- Fix conversion of `ArrayBuffer` cursor key to `Buffer` ([#130](https://github.com/Level/level-js/issues/130)) ([**@vweevers**](https://github.com/vweevers))
- Catch IndexedDB key and value errors ([#139](https://github.com/Level/level-js/issues/139)) ([**@vweevers**](https://github.com/vweevers))
- Use `setImmediate` with callback in `_close()` ([#111](https://github.com/Level/level-js/issues/111)) ([**@ralphtheninja**](https://github.com/ralphtheninja))
- Whitelist npm package files ([#126](https://github.com/Level/level-js/issues/126)) ([**@vweevers**](https://github.com/vweevers))
- Avoid `instanceof Date` for cross-realm support ([#129](https://github.com/Level/level-js/issues/129)) ([**@vweevers**](https://github.com/vweevers))
- Fix wrong release date for `3.0.0-rc1` ([`43a702b`](https://github.com/Level/level-js/commit/43a702b)) ([**@ralphtheninja**](https://github.com/ralphtheninja))
### Removed
- Remove `test/levelup-test.js` ([#134](https://github.com/Level/level-js/issues/134)) ([**@ralphtheninja**](https://github.com/ralphtheninja))
- Remove `levelup` from destroy tests ([#136](https://github.com/Level/level-js/issues/136)) ([**@ralphtheninja**](https://github.com/ralphtheninja))
## [3.0.0-rc1] - 2018-05-26
### Changed
- Upgrade `abstract-leveldown` from `0.12.0` to `5.0.0` ([**@vweevers**](https://github.com/vweevers))
- Upgrade `typedarray-to-buffer` from `1.0.0` to `3.1.5` ([**@vweevers**](https://github.com/vweevers))
- Upgrade `levelup` devDependency from `0.18.2` to `3.0.0` ([**@vweevers**](https://github.com/vweevers))
- Upgrade `browserify` devDependency from `4.1.2` to `16.2.2` ([**@vweevers**](https://github.com/vweevers))
- Switch license from BSD to MIT ([**@ralphtheninja**](https://github.com/ralphtheninja))
- Replace `IDBWrapper` with straight IndexedDB code ([**@vweevers**](https://github.com/vweevers))
- Change default database prefix from `IDBWrapper-` to `level-js-` ([**@vweevers**](https://github.com/vweevers))
- Implement abstract `#_serializeKey` with support of all IndexedDB Second Edition types including binary keys (as Buffers) ([**@vweevers**](https://github.com/vweevers))
- Implement abstract `#_serializeValue` with support of all types of the structured clone algorithm except for `null` and `undefined` ([**@vweevers**](https://github.com/vweevers))
- Use `immediate` module for consistent microtask behavior ([**@vweevers**](https://github.com/vweevers))
- Replace `Buffer()` with `Buffer.from()` ([**@vweevers**](https://github.com/vweevers))
- Rename `Iterator#iterator` to `#transaction` ([**@vweevers**](https://github.com/vweevers))
- Replace `beefy` with `airtap --local` for local testing ([**@vweevers**](https://github.com/vweevers))
- Homogenize README title, description and headers ([**@vweevers**](https://github.com/vweevers))
- Make real `tape` tests out of `test-levelup.js` ([**@vweevers**](https://github.com/vweevers))
- Restructure custom tests to follow abstract test suite format ([**@vweevers**](https://github.com/vweevers))
### Added
- Add continuous browser tests with `airtap` and Sauce Labs ([**@vweevers**](https://github.com/vweevers))
- Add `prefix` and `version` options to constructor ([**@vweevers**](https://github.com/vweevers))
- Detect binary key support and fallback to `String(buffer)` ([**@vweevers**](https://github.com/vweevers))
- Detect array key support and fallback to `String(array)` ([**@vweevers**](https://github.com/vweevers))
- Test all value types of the structured clone algorithm ([**@vweevers**](https://github.com/vweevers))
- Catch `DataCloneError` if the environment does not support serializing the type of a key or value ([**@vweevers**](https://github.com/vweevers))
- Include Promise polyfill for `levelup` integration tests ([**@vweevers**](https://github.com/vweevers))
- Test that `Iterator` stringifies `Buffer.from()` argument ([**@vweevers**](https://github.com/vweevers))
- Add README badges, new goals and a code example with `levelup` ([**@vweevers**](https://github.com/vweevers))
- Add npm files to `.gitignore` ([**@vweevers**](https://github.com/vweevers))
### Fixed
- Start `Iterator` cursor immediately and fill an in-memory cache to fulfill `abstract-leveldown` snapshot guarantees ([**@vweevers**](https://github.com/vweevers))
- Stop advancing `Iterator` cursor when `options.limit` is reached ([**@vweevers**](https://github.com/vweevers))
- Rename public `#iterator` to private `#_iterator` ([**@vweevers**](https://github.com/vweevers))
- Fix `#_iterator({ limit: 0 })` to yield 0 entries ([**@vweevers**](https://github.com/vweevers))
- Handle transaction errors in `Iterator` ([**@vweevers**](https://github.com/vweevers))
- Fix constructor to call super ([**@vweevers**](https://github.com/vweevers))
- Make one request at a time in a batch transaction, saving CPU time ([**@vweevers**](https://github.com/vweevers))
- Properly close and destroy db's in custom tests ([**@vweevers**](https://github.com/vweevers))
- Update README links ([**@vweevers**](https://github.com/vweevers))
### Removed
- Remove support of `ArrayBuffer` values in favor of `Buffer` ([**@vweevers**](https://github.com/vweevers))
- Remove now unneeded `raw` option from `#_get()` and `#_iterator()` ([**@vweevers**](https://github.com/vweevers))
- Run tests without `IndexedDBShim` ([**@vweevers**](https://github.com/vweevers))
- Remove `Buffer` to `Uint8Array` conversion in `#_put()` and `#_batch()` ([**@vweevers**](https://github.com/vweevers))
- Remove obsolete `#_approximateSize` ([**@vweevers**](https://github.com/vweevers))
- Remove obsolete `#_isBuffer` ([**@vweevers**](https://github.com/vweevers))
- Remove obsolete `testBuffer` from abstract tests ([**@vweevers**](https://github.com/vweevers))
- Remove obsolete writestream test from `test-levelup.js` ([**@vweevers**](https://github.com/vweevers))
- Rely on `abstract-leveldown` defaults in `Iterator` constructor ([**@vweevers**](https://github.com/vweevers))
- Rely on `abstract-leveldown` callback defaults ([**@vweevers**](https://github.com/vweevers))
- Remove testling from `package.json` ([**@vweevers**](https://github.com/vweevers))
- Remove `level.js` logo ([**@vweevers**](https://github.com/vweevers))
**Historical Note** Support of `ArrayBuffer` values was restored in `3.0.0`.
**Historical Note** This release introduced the boolean `binaryKeys` and `arrayKeys` properties on the constructor, indicating whether the environment supports binary and array keys respectively. These properties may become private.
**Historical Note** The vendored `IndexedDBShim` is still included, but likely to be removed.
**Historical Note** Though we upgraded `browserify` to `16.2.2`, the effective version used in tests is `13.3.0` because we switched from `beefy` to `airtap`, which ships with its own `browserify` dependency.
## [2.2.4] - 2016-05-09
### Changed
- Use `toArrayBuffer()` only when present ([**@substack**](https://github.com/substack))
## [2.2.3] - 2015-12-10
### Changed
- Update `ltgt` to `^2.1.2` ([**@ryanramage**](https://github.com/ryanramage))
## [2.2.2] - 2015-09-12
### Added
- Add [**@nolanlawson**](https://github.com/nolanlawson) to collaborators ([**@maxogden**](https://github.com/maxogden))
### Fixed
- Fix iterator when start > end ([**@nolanlawson**](https://github.com/nolanlawson))
**Historical Note** This release introduced `this._keyRangeError`.
## [2.2.1] - 2015-07-05
### Changed
- Update collaborators ([**@maxogden**](https://github.com/maxogden))
- Roll back `abstract-leveldown` to `~0.12.0` ([**@maxogden**](https://github.com/maxogden))
## [2.2.0] - 2015-07-03
### Added
- Add `Collaborators` section to README ([**@maxogden**](https://github.com/maxogden))
### Changed
- Update syntax highlighting in README ([**@yoshuawuyts**](https://github.com/yoshuawuyts))
- Update `idb-wrapper` to `^1.5.0` ([**@JamesKyburz**](https://github.com/JamesKyburz))
- Update `abstract-leveldown` to `^2.4.0` ([**@maxogden**](https://github.com/maxogden))
- Update `tape` to `^4.0.0` ([**@maxogden**](https://github.com/maxogden))
- Move `tape` to devDependencies ([**@maxogden**](https://github.com/maxogden))
- Change license from BSD to BSD-2-Clause ([**@maxogden**](https://github.com/maxogden))
### Removed
- Remove Testling badge ([**@maxogden**](https://github.com/maxogden))
## [2.1.6] - 2014-06-15
### Fixed
- Avoid using keyword in `cursor.continue()` ([**@nolanlawson**](https://github.com/nolanlawson))
## [2.1.5] - 2014-05-29
### Changed
- Use `ltgt` module to handle ranges ([**@dominictarr**](https://github.com/dominictarr))
## [2.1.4] - 2014-05-13
### Changed
- Update `browserify` to `^4.1.2` ([**@maxogden**](https://github.com/maxogden))
- Move `browserify` to devDependencies ([**@maxogden**](https://github.com/maxogden))
## [2.1.3] - 2014-04-09
### Added
- Use `typedarray-to-buffer` to avoid copying to Buffer ([**@mafintosh**](https://github.com/mafintosh))
## [2.1.2] - 2014-04-05
### Added
- Add link to [**@brycebaril**](https://github.com/brycebaril)'s presentation to README ([**@maxogden**](https://github.com/maxogden))
### Changed
- Update browser configuration for Testling ([**@maxogden**](https://github.com/maxogden))
## [2.1.1] - 2014-03-12
### Changed
- Update browser configuration for Testling ([**@maxogden**](https://github.com/maxogden))
- Update `abstract-leveldown` to `~0.12.0` ([**@maxogden**](https://github.com/maxogden))
- Update `levelup` to `~0.18.2` ([**@maxogden**](https://github.com/maxogden))
- Make sure to store `Uint8Array` ([**@maxogden**](https://github.com/maxogden))
- Test storing native JS types with raw = true ([**@maxogden**](https://github.com/maxogden))
**Historical Note** This was not published to npm. There's also a gap between `2.1.1` and `2.0.0` that is inconsistent. The `options.raw` property was introduced in this release.
## [2.0.0] - 2014-03-09
### Changed
- Update `browserify` to `~3.32.0` ([**@maxogden**](https://github.com/maxogden))
- Update `tape` to `~2.10.2` ([**@maxogden**](https://github.com/maxogden))
- Change default encoding of values to strings to more closely match `leveldown` ([**@maxogden**](https://github.com/maxogden))
### Fixed
- Add missing `xtend` dependency ([**@maxogden**](https://github.com/maxogden))
**Historical Note** For some reason both `tape` and `browserify` were moved from devDependencies to dependencies. This release only had one commit.
## [1.2.0] - 2014-03-09
### Added
- Add `IndexedDBShim` to tests ([**@maxogden**](https://github.com/maxogden))
- Add `Level.destroy()` ([**@qs44**](https://github.com/qs44))
- Add prefix to pass `PouchDB` tests ([**@qs44**](https://github.com/qs44))
- Test `Level.destroy()` ([**@calvinmetcalf**](https://github.com/calvinmetcalf))
### Changed
- Update browser configuration for Testling ([**@maxogden**](https://github.com/maxogden))
- Pass through open options to idbwrapper ([**@maxogden**](https://github.com/maxogden))
### Fixed
- Don't use `indexedDB.webkitGetDatabasesNames()` in tests ([**@maxogden**](https://github.com/maxogden))
## [1.1.2] - 2014-02-02
### Removed
- Remove global leaks ([**@mcollina**](https://github.com/mcollina))
## [1.1.1] - 2014-02-02
### Changed
- Modify a copy of the batch array, not the original ([**@nrw**](https://github.com/nrw))
### Fixed
- Fix broken `package.json` ([**@maxogden**](https://github.com/maxogden))
- Fix testling path ([**@maxogden**](https://github.com/maxogden))
## [1.1.0] - 2014-01-30
### Added
- Add Testling ([**@maxogden**](https://github.com/maxogden))
- Add npm badge ([**@maxogden**](https://github.com/maxogden))
- Test ranges ([**@rvagg**](https://github.com/rvagg), [**@maxogden**](https://github.com/maxogden))
### Changed
- Update README ([**@maxogden**](https://github.com/maxogden))
- Update `abstract-leveldown` to `~0.11.0` ([**@rvagg**](https://github.com/rvagg), [**@maxogden**](https://github.com/maxogden))
- Update to work with `abstract-leveldown@0.11.2` ([**@shama**](https://github.com/shama), [**@maxogden**](https://github.com/maxogden))
- Update iterator to pass all range tests ([**@shama**](https://github.com/shama), [**@maxogden**](https://github.com/maxogden))
### Fixed
- Fix incorrect version of `abstract-leveldown` ([**@maxogden**](https://github.com/maxogden))
- Pass error to callback in `approximateSize()` ([**@mcollina**](https://github.com/mcollina))
### Removed
- Remove unnecessary factor in tests ([**@rvagg**](https://github.com/rvagg), [**@maxogden**](https://github.com/maxogden))
**Historical Note** In this time period `bops` shows up and gets removed. Also, `._isBuffer()` uses `Buffer.isBuffer()` in favor of `is-buffer` module.
## [1.0.8] - 2013-08-12
### Changed
- Move `levelup` to devDependencies ([**@juliangruber**](https://github.com/juliangruber))
### Removed
- Remove fn#bind from iterator ([**@juliangruber**](https://github.com/juliangruber))
## [1.0.7] - 2013-07-02
### Changed
- Implement full batch support ([**@mcollina**](https://github.com/mcollina))
### Fixed
- Fix git url to `abstract-leveldown` ([**@maxogden**](https://github.com/maxogden))
## [1.0.6] - 2013-05-31
### Changed
- Update `idb-wrapper` to `1.2.0` ([**@maxogden**](https://github.com/maxogden))
- Switch `abstract-leveldown#master` ([**@maxogden**](https://github.com/maxogden))
- Disable batch and chainable batch tests ([**@maxogden**](https://github.com/maxogden))
## [1.0.5] - 2013-05-30
### Changed
- Use upstream `idb-wrapper` ([**@maxogden**](https://github.com/maxogden))
## [1.0.4] - 2013-05-30
### Added
- Test batch and chainable batch ([**@rvagg**](https://github.com/rvagg))
### Changed
- Update `abstract-leveldown` to `~0.7.1` ([**@rvagg**](https://github.com/rvagg))
- Update `levelup` to `~0.9.0` ([**@brycebaril**](https://github.com/brycebaril))
## [1.0.3] - 2013-05-14
### Changed
- Use `is-buffer` ([**@juliangruber**](https://github.com/juliangruber))
## [1.0.2] - 2013-05-04
### Fixed
- Don't convert `ArrayBuffer` and typed arrays to strings ([**@maxogden**](https://github.com/maxogden))
## [1.0.1] - 2013-05-03
### Added
- Add optional options argument to `.open()` ([**@rvagg**](https://github.com/rvagg))
- Add `test-levelup.js` ([**@maxogden**](https://github.com/maxogden))
### Changed
- Update README ([**@maxogden**](https://github.com/maxogden))
- Use `npm test` instead of `npm start` ([**@shama**](https://github.com/shama))
- Properly delete test dbs ([**@maxogden**](https://github.com/maxogden))
- Inherit from `abstract-leveldown` ([**@rvagg**](https://github.com/rvagg))
## 1.0.0 - 2013-05-03
:seedling: Initial release.
[5.0.2]: https://github.com/Level/level-js/compare/v5.0.1...v5.0.2
[5.0.1]: https://github.com/Level/level-js/compare/v5.0.0...v5.0.1
[5.0.0]: https://github.com/Level/level-js/compare/v4.0.1...v5.0.0
[4.0.1]: https://github.com/Level/level-js/compare/v4.0.0...v4.0.1
[4.0.0]: https://github.com/Level/level-js/compare/v3.0.0...v4.0.0
[3.0.0]: https://github.com/Level/level-js/compare/v3.0.0-rc1...v3.0.0
[3.0.0-rc1]: https://github.com/Level/level-js/compare/v2.2.4...v3.0.0-rc1
[2.2.4]: https://github.com/Level/level-js/compare/v2.2.3...v2.2.4
[2.2.3]: https://github.com/Level/level-js/compare/v2.2.2...v2.2.3
[2.2.2]: https://github.com/Level/level-js/compare/v2.2.1...v2.2.2
[2.2.1]: https://github.com/Level/level-js/compare/v2.2.0...v2.2.1
[2.2.0]: https://github.com/Level/level-js/compare/v2.1.6...v2.2.0
[2.1.6]: https://github.com/Level/level-js/compare/v2.1.5...v2.1.6
[2.1.5]: https://github.com/Level/level-js/compare/v2.1.4...v2.1.5
[2.1.4]: https://github.com/Level/level-js/compare/v2.1.3...v2.1.4
[2.1.3]: https://github.com/Level/level-js/compare/v2.1.2...v2.1.3
[2.1.2]: https://github.com/Level/level-js/compare/v2.1.1...v2.1.2
[2.1.1]: https://github.com/Level/level-js/compare/v2.0.0...v2.1.1
[2.0.0]: https://github.com/Level/level-js/compare/v1.2.0...v2.0.0
[1.2.0]: https://github.com/Level/level-js/compare/v1.1.2...v1.2.0
[1.1.2]: https://github.com/Level/level-js/compare/v1.1.1...v1.1.2
[1.1.1]: https://github.com/Level/level-js/compare/v1.1.0...v1.1.1
[1.1.0]: https://github.com/Level/level-js/compare/v1.0.8...v1.1.0
[1.0.8]: https://github.com/Level/level-js/compare/v1.0.7...v1.0.8
[1.0.7]: https://github.com/Level/level-js/compare/v1.0.6...v1.0.7
[1.0.6]: https://github.com/Level/level-js/compare/v1.0.5...v1.0.6
[1.0.5]: https://github.com/Level/level-js/compare/v1.0.4...v1.0.5
[1.0.4]: https://github.com/Level/level-js/compare/v1.0.3...v1.0.4
[1.0.3]: https://github.com/Level/level-js/compare/v1.0.2...v1.0.3
[1.0.2]: https://github.com/Level/level-js/compare/v1.0.1...v1.0.2
[1.0.1]: https://github.com/Level/level-js/compare/v1.0.0...v1.0.1

24
node_modules/level-js/CONTRIBUTORS.md generated vendored Normal file
View File

@@ -0,0 +1,24 @@
# Contributors
| Name | GitHub | Social |
| :---------------------- | :------------------------------------------------------- | :-------------------------------------------------------------- |
| **Vincent Weevers** | [**@vweevers**](https://github.com/vweevers) | [**@vweevers@twitter**](https://twitter.com/vweevers) |
| **Max Ogden** | [**@maxogden**](https://github.com/maxogden) | [**@maxogden@twitter**](https://twitter.com/maxogden) |
| **Lars-Magnus Skog** | [**@ralphtheninja**](https://github.com/ralphtheninja) | [**@ralph@social.weho.st**](https://social.weho.st/@ralph) |
| **Rod Vagg** | [**@rvagg**](https://github.com/rvagg) | [**@rvagg@twitter**](https://twitter.com/rvagg) |
| **Josh** | [**@qs44**](https://github.com/qs44) | |
| **Dominic Tarr** | [**@dominictarr**](https://github.com/dominictarr) | [**@dominictarr@twitter**](https://twitter.com/dominictarr) |
| **Kyle Robinson Young** | [**@shama**](https://github.com/shama) | [**@shamakry@twitter**](https://twitter.com/shamakry) |
| **Matteo Collina** | [**@mcollina**](https://github.com/mcollina) | [**@matteocollina@twitter**](https://twitter.com/matteocollina) |
| **Nolan Lawson** | [**@nolanlawson**](https://github.com/nolanlawson) | [**@nolan@toot.cafe**](https://toot.cafe/@nolan) |
| **Julian Gruber** | [**@juliangruber**](https://github.com/juliangruber) | [**@juliangruber@twitter**](https://twitter.com/juliangruber) |
| **Mathias Buus** | [**@mafintosh**](https://github.com/mafintosh) | [**@mafintosh@twitter**](https://twitter.com/mafintosh) |
| **Alex Potsides** | | |
| **Bryce Baril** | [**@brycebaril**](https://github.com/brycebaril) | [**@brycebaril@twitter**](https://twitter.com/brycebaril) |
| **Calvin Metcalf** | [**@calvinmetcalf**](https://github.com/calvinmetcalf) | |
| **Hugo Dias** | | |
| **James Halliday** | [**@substack**](https://github.com/substack) | [**@substack@twitter**](https://twitter.com/substack) |
| **James Kyburz** | [**@jameskyburz**](https://github.com/jameskyburz) | [**@jameskyburz@twitter**](https://twitter.com/jameskyburz) |
| **Nicholas Westlake** | [**@nrw**](https://github.com/nrw) | |
| **Ryan Ramage** | [**@ryanramage**](https://github.com/ryanramage) | |
| **Yoshua Wuyts** | [**@yoshuawuyts**](https://github.com/yoshuawuyts) | [**@yoshuawuyts@twitter**](https://twitter.com/yoshuawuyts) |

21
node_modules/level-js/LICENSE.md generated vendored Normal file
View File

@@ -0,0 +1,21 @@
# The MIT License (MIT)
**Copyright © 2012-present [Max Ogden](https://github.com/maxogden) and [Contributors](CONTRIBUTORS.md).**
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

178
node_modules/level-js/README.md generated vendored Normal file
View File

@@ -0,0 +1,178 @@
# level-js
> An [`abstract-leveldown`][abstract-leveldown] compliant store on top of [IndexedDB][indexeddb].
[![level badge][level-badge]][awesome]
[![npm](https://img.shields.io/npm/v/level-js.svg?label=&logo=npm)](https://www.npmjs.com/package/level-js)
[![Travis](https://img.shields.io/travis/com/Level/level-js.svg?logo=travis&label=)](https://travis-ci.com/Level/level-js)
[![npm](https://img.shields.io/npm/dm/level-js.svg?label=dl)](https://www.npmjs.com/package/level-js)
[![Coverage Status](https://coveralls.io/repos/github/Level/level-js/badge.svg)](https://coveralls.io/github/Level/level-js)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)
[![Backers on Open Collective](https://opencollective.com/level/backers/badge.svg?color=orange)](#backers)
[![Sponsors on Open Collective](https://opencollective.com/level/sponsors/badge.svg?color=orange)](#sponsors)
## Table of Contents
<details><summary>Click to expand</summary>
- [Background](#background)
- [Example](#example)
- [Browser Support](#browser-support)
- [Type Support](#type-support)
- [Install](#install)
- [API](#api)
- [Running Tests](#running-tests)
- [Big Thanks](#big-thanks)
- [Contributing](#contributing)
- [Donate](#donate)
- [License](#license)
</details>
## Background
Here are the goals of `level-js`:
- Store large amounts of data in modern browsers
- Pass the full [`abstract-leveldown`][abstract-leveldown] test suite
- Support string and [`Buffer`][buffer] keys and values
- Be as fast as possible
- ~~Sync with [multilevel](https://github.com/juliangruber/multilevel) over ASCII or binary transports.~~
Being `abstract-leveldown` compliant means you can use many of the [Level modules][awesome] on top of this library.
## Example
**If you are upgrading:** please see [UPGRADING.md](UPGRADING.md).
```js
var levelup = require('levelup')
var leveljs = require('level-js')
var db = levelup(leveljs('bigdata'))
db.put('hello', Buffer.from('world'), function (err) {
if (err) throw err
db.get('hello', function (err, value) {
if (err) throw err
console.log(value.toString()) // 'world'
})
})
```
In ES6 browsers:
```js
const levelup = require('levelup')
const leveljs = require('level-js')
const db = levelup(leveljs('bigdata'))
await db.put('hello', Buffer.from('world'))
const value = await db.get('hello')
```
## Browser Support
[![Sauce Test Status](https://saucelabs.com/browser-matrix/level-js.svg)](https://saucelabs.com/u/level-js)
## Type Support
Keys and values can be a string or [`Buffer`][buffer]. Any other type will be irreversibly stringified. The only exceptions are `null` and `undefined`. Keys and values of that type are rejected.
In order to sort string and Buffer keys the same way, for compatibility with `leveldown` and the larger ecosystem, `level-js` internally converts keys and values to binary before passing them to IndexedDB. If binary keys are not supported by the environment (like IE11) `level-js` falls back to `String(key)`.
If you desire non-destructive encoding (e.g. to store and retrieve numbers as-is), wrap `level-js` with [`encoding-down`][encoding-down]. Alternatively install [`level`][level] which conveniently bundles [`levelup`][levelup], `level-js` and `encoding-down`. Such an approach is also recommended if you want to achieve universal (isomorphic) behavior. For example, you could have [`leveldown`][leveldown] in a backend and `level-js` in the frontend. The `level` package does exactly that.
When getting or iterating keys and values, regardless of the type with which they were stored, keys and values will return as a Buffer unless the `asBuffer`, `keyAsBuffer` or `valueAsBuffer` options are set, in which case strings are returned. Setting these options is not needed when `level-js` is wrapped with `encoding-down`, which determines the optimal return type by the chosen encoding.
```js
db.get('key', { asBuffer: false })
db.iterator({ keyAsBuffer: false, valueAsBuffer: false })
```
## Install
With [npm](https://npmjs.org) do:
```bash
npm install level-js
```
Not to be confused with [leveljs](https://www.npmjs.com/package/leveljs).
This library is best used with [browserify](http://browserify.org).
## API
### `db = leveljs(location[, options])`
Returns a new `leveljs` instance. `location` is the string name of the [`IDBDatabase`](https://developer.mozilla.org/en-US/docs/Web/API/IDBDatabase) to be opened, as well as the object store within that database. The database name will be prefixed with `options.prefix`.
#### `options`
The optional `options` argument may contain:
- `prefix` _(string, default: `'level-js-'`)_: Prefix for `IDBDatabase` name.
- `version` _(string | number, default: `1`)_: The version to open the database with.
See [`IDBFactory#open`](https://developer.mozilla.org/en-US/docs/Web/API/IDBFactory/open) for more details.
## Running Tests
```sh
git clone git@github.com:Level/level-js.git
cd level-js
npm install
npm test
```
It will print out a URL to open in a browser of choice.
## Big Thanks
Cross-browser Testing Platform and Open Source ♥ Provided by [Sauce Labs](https://saucelabs.com).
[![Sauce Labs logo](./sauce-labs.svg)](https://saucelabs.com)
## Contributing
[`Level/level-js`](https://github.com/Level/level-js) is an **OPEN Open Source Project**. This means that:
> Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project.
See the [Contribution Guide](https://github.com/Level/community/blob/master/CONTRIBUTING.md) for more details.
## Donate
To sustain [`Level`](https://github.com/Level) and its activities, become a backer or sponsor on [Open Collective](https://opencollective.com/level). Your logo or avatar will be displayed on our 28+ [GitHub repositories](https://github.com/Level) and [npm](https://www.npmjs.com/) packages. 💖
### Backers
[![Open Collective backers](https://opencollective.com/level/backers.svg?width=890)](https://opencollective.com/level)
### Sponsors
[![Open Collective sponsors](https://opencollective.com/level/sponsors.svg?width=890)](https://opencollective.com/level)
## License
[MIT](LICENSE.md) © 2012-present [Max Ogden](https://github.com/maxogden) and [Contributors](CONTRIBUTORS.md).
[level-badge]: https://leveljs.org/img/badge.svg
[indexeddb]: https://developer.mozilla.org/en-US/docs/Web/API/IndexedDB_API
[buffer]: https://nodejs.org/api/buffer.html
[awesome]: https://github.com/Level/awesome
[abstract-leveldown]: https://github.com/Level/abstract-leveldown
[levelup]: https://github.com/Level/levelup
[leveldown]: https://github.com/Level/leveldown
[level]: https://github.com/Level/level
[encoding-down]: https://github.com/Level/encoding-down

162
node_modules/level-js/UPGRADING.md generated vendored Normal file
View File

@@ -0,0 +1,162 @@
# Upgrade Guide
This document describes breaking changes and how to upgrade. For a complete list of changes including minor and patch releases, please refer to the [changelog][changelog].
## 5.0.0
Support of keys & values other than strings and Buffers has been dropped. Internally `level-js` now stores keys & values as binary which solves a number of compatibility issues ([Level/memdown#186](https://github.com/Level/memdown/issues/186)). If you pass in a key or value that isn't a string or Buffer, it will be irreversibly stringified.
Existing IndexedDB databases created with `level-js@4` can be read only if they used binary keys and string or binary values. Other types will come out stringified, and string keys will sort incorrectly. Use the included `upgrade()` utility to convert stored data to binary (in so far the environment supports it):
```js
var leveljs = require('level-js')
var db = leveljs('my-db')
db.open(function (err) {
if (err) throw err
db.upgrade(function (err) {
if (err) throw err
})
})
```
Or with (the upcoming release of) `level`:
```js
var level = require('level')
var reachdown = require('reachdown')
var db = level('my-db')
db.open(function (err) {
if (err) throw err
reachdown(db, 'level-js').upgrade(function (err) {
if (err) throw err
})
})
```
## 4.0.0
This is an upgrade to `abstract-leveldown@6` which solves long-standing issues around serialization and type support.
### Range options are now serialized
Previously, range options like `lt` were passed through as-is by `abstract-leveldown`, unlike keys. For `level-js` it means that Buffers and arrays, if not supported by the environment (e.g. Microsoft Edge), will be stringified.
### The rules for range options have been relaxed
Because `null`, `undefined`, zero-length strings and zero-length buffers are significant types in encodings like `bytewise` and `charwise`, they became valid as range options in `abstract-leveldown`. This means `db.iterator({ gt: undefined })` is not the same as `db.iterator({})`.
In the case of `level-js`, when used by itself, the aforementioned change means that `db.iterator({ gt: undefined })` will throw an error as `undefined` is not a valid IndexedDB key type. On the other hand `db.iterator({ gt: '' })` is valid and thus now supported. For details on sort order (which is richer than in `leveldown`) please see [the readme](README.md).
### Nullish values are rejected
In addition to rejecting `null` and `undefined` as _keys_, `abstract-leveldown` now also rejects these types as _values_, due to preexisting significance in streams and iterators.
### Zero-length array keys are rejected
Though this was already the case (both in IndexedDB and `abstract-leveldown`), `abstract-leveldown` has replaced the behavior with an explicit `Array.isArray()` check and a new error message.
### Boolean and `NaN` keys (as well as range options) are rejected
Previously, for compliance with `abstract-leveldown` tests that have since been removed, they were stringified. As of `level-js@4` they are rejected (by IndexedDB).
### Added mobile browser support
iPhone and Android `latest` are now officially supported. At the time of writing that's iPhone 12.0 and Android 7.1 (note that's Chrome for Android, not the old stock browser). Older versions (iPhone 10+ and Android 6+) did pass our tests but are not included in the test matrix going forward. Feel free to open an issue if you need/want these versions to be supported.
### The value of `iterator#db` has changed
Though this was undocumented and only for internal use, the `db` property on an iterator pointed to an `IDBDatabase`. To comply with `abstract-leveldown` the `db` property now points to the `level-js` instance that created that iterator.
## 3.0.0
This release brings `level-js` up to par with latest [`levelup`][levelup] (v2), [`abstract-leveldown`][abstract-leveldown] (v5) and IndexedDB Second Edition. It targets modern `browserify` preferring [`Buffer`][buffer] over `ArrayBuffer`. Lastly, [`IDBWrapper`][idbwrapper] has been replaced with straight IndexedDB code.
### Usage with [`levelup`][levelup]
Usage has changed to:
```js
const levelup = require('levelup')
const leveljs = require('leveljs')
const db = levelup(leveljs('mydb'))
```
From the old:
```js
const db = levelup('mydb', { db: leveljs })
```
Friendly reminder: encodings have moved from [`levelup`][levelup] to [`encoding-down`][encoding-down]. To get identical functionality to `levelup < 2` please use the [`level-browserify`][level-browserify] convenience package or wrap `level-js` with `encoding-down`:
```js
const encode = require('encoding-down')
const db = levelup(encode(leveljs('mydb')))
```
### New database prefix
The default prefix of the [`IDBDatabase`][idbdatabase] name has changed from `IDBWrapper-` to `level-js-`. To access databases created using `level-js < 3`, pass a custom prefix to the `level-js` constructor:
```js
const db = levelup(leveljs('mydb', { prefix: 'IDBWrapper-' }))
```
### Browser support
As a result of removing [`IDBWrapper`][idbwrapper], only modern browsers with a non-prefixed `window.indexedDB` are supported in this release. The current test matrix of `level-js` includes the latest versions of Chrome, Firefox, Safari, Edge and IE.
:fire: Internet Explorer 10 is no longer supported.
### Type support
All value types of the [structured clone algorithm][structured-clone-algorithm] and all key types of IndexedDB Second Edition are now supported. This means you can store almost any JavaScript type without the need for [`encoding-down`][encoding-down]. In addition, you can use [`Buffer`][buffer] for both keys and values. For details and caveats please see the [readme][readme].
### No backpressure
In `level-js`, iterators are powered by IndexedDB cursors. To fulfill [`abstract-leveldown`][abstract-leveldown] snapshot guarantees (reads not being affected by simultaneous writes) cursors are started immediately and continuously read from, filling an in-memory cache.
Though `level-js` now passes the full [`abstract-leveldown`][abstract-leveldown] test suite, fulfilling the snapshot guarantee means a loss of backpressure. Memory consumption might increase if an iterator is not consumed fast enough. A future release will have an option to favor backpressure over snapshot guarantees.
### Removed `raw` option
Because `level-js` no longer stringifies values, the `raw` option (which bypassed conversion) became unnecessary and has been removed. If you use [`level-browserify`][level-browserify] or [`levelup`][levelup] with [`encoding-down`][encoding-down], you can store and retrieve raw values (as returned by IndexedDB) using the `id` encoding. Please refer to the [readme][readme] for an example.
### New `destroy()` function signature
Previously, a `level-js` instance could be passed to `destroy()`:
```js
leveljs.destroy(db, callback)
```
This was useful to destroy a database that used a custom prefix. The new signature is `destroy(location[, prefix], callback)`.
### Strict `.batch(array)`
The upgrade to [`abstract-leveldown`][abstract-leveldown] comes with a [breaking change](https://github.com/Level/abstract-leveldown/commit/a2621ad70571f6ade9d2be42632ece042e068805) for the array version of `.batch()`. This change ensures all elements in the batch array are objects. If you previously passed arrays to `.batch()` that contained `undefined` or `null`, they would be silently ignored. Now this will produce an error.
[readme]: README.md
[changelog]: CHANGELOG.md
[buffer]: https://nodejs.org/api/buffer.html
[idbwrapper]: https://www.npmjs.com/package/idb-wrapper
[abstract-leveldown]: https://github.com/Level/abstract-leveldown
[levelup]: https://github.com/Level/levelup
[encoding-down]: https://github.com/Level/encoding-down
[level-browserify]: https://github.com/Level/level-browserify
[idbdatabase]: https://developer.mozilla.org/en-US/docs/Web/API/IDBDatabase
[structured-clone-algorithm]: https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm

269
node_modules/level-js/index.js generated vendored Normal file
View File

@@ -0,0 +1,269 @@
/* global indexedDB */
'use strict'
module.exports = Level
var AbstractLevelDOWN = require('abstract-leveldown').AbstractLevelDOWN
var inherits = require('inherits')
var Iterator = require('./iterator')
var serialize = require('./util/serialize')
var deserialize = require('./util/deserialize')
var support = require('./util/support')
var clear = require('./util/clear')
var createKeyRange = require('./util/key-range')
var DEFAULT_PREFIX = 'level-js-'
function Level (location, opts) {
if (!(this instanceof Level)) return new Level(location, opts)
AbstractLevelDOWN.call(this, {
bufferKeys: support.bufferKeys(indexedDB),
snapshots: true,
permanence: true,
clear: true
})
opts = opts || {}
if (typeof location !== 'string') {
throw new Error('constructor requires a location string argument')
}
this.location = location
this.prefix = opts.prefix == null ? DEFAULT_PREFIX : opts.prefix
this.version = parseInt(opts.version || 1, 10)
}
inherits(Level, AbstractLevelDOWN)
Level.prototype.type = 'level-js'
Level.prototype._open = function (options, callback) {
var req = indexedDB.open(this.prefix + this.location, this.version)
var self = this
req.onerror = function () {
callback(req.error || new Error('unknown error'))
}
req.onsuccess = function () {
self.db = req.result
callback()
}
req.onupgradeneeded = function (ev) {
var db = ev.target.result
if (!db.objectStoreNames.contains(self.location)) {
db.createObjectStore(self.location)
}
}
}
Level.prototype.store = function (mode) {
var transaction = this.db.transaction([this.location], mode)
return transaction.objectStore(this.location)
}
Level.prototype.await = function (request, callback) {
var transaction = request.transaction
// Take advantage of the fact that a non-canceled request error aborts
// the transaction. I.e. no need to listen for "request.onerror".
transaction.onabort = function () {
callback(transaction.error || new Error('aborted by user'))
}
transaction.oncomplete = function () {
callback(null, request.result)
}
}
Level.prototype._get = function (key, options, callback) {
var store = this.store('readonly')
try {
var req = store.get(key)
} catch (err) {
return this._nextTick(callback, err)
}
this.await(req, function (err, value) {
if (err) return callback(err)
if (value === undefined) {
// 'NotFound' error, consistent with LevelDOWN API
return callback(new Error('NotFound'))
}
callback(null, deserialize(value, options.asBuffer))
})
}
Level.prototype._del = function (key, options, callback) {
var store = this.store('readwrite')
try {
var req = store.delete(key)
} catch (err) {
return this._nextTick(callback, err)
}
this.await(req, callback)
}
Level.prototype._put = function (key, value, options, callback) {
var store = this.store('readwrite')
try {
// Will throw a DataError or DataCloneError if the environment
// does not support serializing the key or value respectively.
var req = store.put(value, key)
} catch (err) {
return this._nextTick(callback, err)
}
this.await(req, callback)
}
Level.prototype._serializeKey = function (key) {
return serialize(key, this.supports.bufferKeys)
}
Level.prototype._serializeValue = function (value) {
return serialize(value, true)
}
Level.prototype._iterator = function (options) {
return new Iterator(this, this.location, options)
}
Level.prototype._batch = function (operations, options, callback) {
if (operations.length === 0) return this._nextTick(callback)
var store = this.store('readwrite')
var transaction = store.transaction
var index = 0
var error
transaction.onabort = function () {
callback(error || transaction.error || new Error('aborted by user'))
}
transaction.oncomplete = function () {
callback()
}
// Wait for a request to complete before making the next, saving CPU.
function loop () {
var op = operations[index++]
var key = op.key
try {
var req = op.type === 'del' ? store.delete(key) : store.put(op.value, key)
} catch (err) {
error = err
transaction.abort()
return
}
if (index < operations.length) {
req.onsuccess = loop
}
}
loop()
}
Level.prototype._clear = function (options, callback) {
try {
var keyRange = createKeyRange(options)
} catch (e) {
// The lower key is greater than the upper key.
// IndexedDB throws an error, but we'll just do nothing.
return this._nextTick(callback)
}
if (options.limit >= 0) {
// IDBObjectStore#delete(range) doesn't have such an option.
// Fall back to cursor-based implementation.
return clear(this, this.location, keyRange, options, callback)
}
try {
var store = this.store('readwrite')
var req = keyRange ? store.delete(keyRange) : store.clear()
} catch (err) {
return this._nextTick(callback, err)
}
this.await(req, callback)
}
Level.prototype._close = function (callback) {
this.db.close()
this._nextTick(callback)
}
// NOTE: remove in a next major release
Level.prototype.upgrade = function (callback) {
if (this.status !== 'open') {
return this._nextTick(callback, new Error('cannot upgrade() before open()'))
}
var it = this.iterator()
var batchOptions = {}
var self = this
it._deserializeKey = it._deserializeValue = identity
next()
function next (err) {
if (err) return finish(err)
it.next(each)
}
function each (err, key, value) {
if (err || key === undefined) {
return finish(err)
}
var newKey = self._serializeKey(deserialize(key, true))
var newValue = self._serializeValue(deserialize(value, true))
// To bypass serialization on the old key, use _batch() instead of batch().
// NOTE: if we disable snapshotting (#86) this could lead to a loop of
// inserting and then iterating those same entries, because the new keys
// possibly sort after the old keys.
self._batch([
{ type: 'del', key: key },
{ type: 'put', key: newKey, value: newValue }
], batchOptions, next)
}
function finish (err) {
it.end(function (err2) {
callback(err || err2)
})
}
function identity (data) {
return data
}
}
Level.destroy = function (location, prefix, callback) {
if (typeof prefix === 'function') {
callback = prefix
prefix = DEFAULT_PREFIX
}
var request = indexedDB.deleteDatabase(prefix + location)
request.onsuccess = function () {
callback()
}
request.onerror = function (err) {
callback(err)
}
}

143
node_modules/level-js/iterator.js generated vendored Normal file
View File

@@ -0,0 +1,143 @@
'use strict'
var inherits = require('inherits')
var AbstractIterator = require('abstract-leveldown').AbstractIterator
var createKeyRange = require('./util/key-range')
var deserialize = require('./util/deserialize')
var noop = function () {}
module.exports = Iterator
function Iterator (db, location, options) {
AbstractIterator.call(this, db)
this._limit = options.limit
this._count = 0
this._callback = null
this._cache = []
this._completed = false
this._aborted = false
this._error = null
this._transaction = null
this._keys = options.keys
this._values = options.values
this._keyAsBuffer = options.keyAsBuffer
this._valueAsBuffer = options.valueAsBuffer
if (this._limit === 0) {
this._completed = true
return
}
try {
var keyRange = createKeyRange(options)
} catch (e) {
// The lower key is greater than the upper key.
// IndexedDB throws an error, but we'll just return 0 results.
this._completed = true
return
}
this.createIterator(location, keyRange, options.reverse)
}
inherits(Iterator, AbstractIterator)
Iterator.prototype.createIterator = function (location, keyRange, reverse) {
var self = this
var transaction = this.db.db.transaction([location], 'readonly')
var store = transaction.objectStore(location)
var req = store.openCursor(keyRange, reverse ? 'prev' : 'next')
req.onsuccess = function (ev) {
var cursor = ev.target.result
if (cursor) self.onItem(cursor)
}
this._transaction = transaction
// If an error occurs (on the request), the transaction will abort.
transaction.onabort = function () {
self.onAbort(self._transaction.error || new Error('aborted by user'))
}
transaction.oncomplete = function () {
self.onComplete()
}
}
Iterator.prototype.onItem = function (cursor) {
this._cache.push(cursor.key, cursor.value)
if (this._limit <= 0 || ++this._count < this._limit) {
cursor.continue()
}
this.maybeNext()
}
Iterator.prototype.onAbort = function (err) {
this._aborted = true
this._error = err
this.maybeNext()
}
Iterator.prototype.onComplete = function () {
this._completed = true
this.maybeNext()
}
Iterator.prototype.maybeNext = function () {
if (this._callback) {
this._next(this._callback)
this._callback = null
}
}
Iterator.prototype._next = function (callback) {
if (this._aborted) {
// The error should be picked up by either next() or end().
var err = this._error
this._error = null
this._nextTick(callback, err)
} else if (this._cache.length > 0) {
var key = this._cache.shift()
var value = this._cache.shift()
if (this._keys && key !== undefined) {
key = this._deserializeKey(key, this._keyAsBuffer)
} else {
key = undefined
}
if (this._values && value !== undefined) {
value = this._deserializeValue(value, this._valueAsBuffer)
} else {
value = undefined
}
this._nextTick(callback, null, key, value)
} else if (this._completed) {
this._nextTick(callback)
} else {
this._callback = callback
}
}
// Exposed for the v4 to v5 upgrade utility
Iterator.prototype._deserializeKey = deserialize
Iterator.prototype._deserializeValue = deserialize
Iterator.prototype._end = function (callback) {
if (this._aborted || this._completed) {
return this._nextTick(callback, this._error)
}
// Don't advance the cursor anymore, and the transaction will complete
// on its own in the next tick. This approach is much cleaner than calling
// transaction.abort() with its unpredictable event order.
this.onItem = noop
this.onAbort = callback
this.onComplete = callback
}

57
node_modules/level-js/package.json generated vendored Normal file
View File

@@ -0,0 +1,57 @@
{
"name": "level-js",
"version": "5.0.2",
"description": "An abstract-leveldown compliant store on top of IndexedDB",
"author": "max ogden",
"license": "MIT",
"main": "index.js",
"scripts": {
"test": "standard && hallmark && airtap --local --coverage test/index.js",
"test-browsers": "standard && airtap --sauce-connect --loopback airtap.local --coverage test/index.js",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"hallmark": "hallmark --fix",
"dependency-check": "dependency-check . test/*.js",
"prepublishOnly": "npm run dependency-check"
},
"files": [
"index.js",
"iterator.js",
"util",
"CONTRIBUTORS.md",
"CHANGELOG.md",
"UPGRADING.md",
"sauce-labs.svg"
],
"dependencies": {
"abstract-leveldown": "~6.2.3",
"buffer": "^5.5.0",
"inherits": "^2.0.3",
"ltgt": "^2.1.2"
},
"devDependencies": {
"airtap": "^3.0.0",
"coveralls": "^3.0.2",
"dependency-check": "^3.3.0",
"hallmark": "^2.0.0",
"level-community": "^3.0.0",
"level-concat-iterator": "^2.0.0",
"nyc": "^15.0.0",
"standard": "^14.0.2",
"tape": "^4.0.0",
"uuid": "^3.3.2"
},
"hallmark": {
"community": "level-community"
},
"repository": {
"type": "git",
"url": "https://github.com/Level/level-js.git"
},
"homepage": "https://github.com/Level/level-js",
"keywords": [
"level",
"leveldb",
"indexeddb",
"abstract-leveldown"
]
}

81
node_modules/level-js/sauce-labs.svg generated vendored Normal file
View File

@@ -0,0 +1,81 @@
<svg
xmlns="http://www.w3.org/2000/svg"
width="460"
height="64"
version="1.1"
viewBox="0 0 144.37044 20.09272">
<defs>
<style>
.cls-1{isolation:isolate;}
.cls-2{opacity:0.15;mix-blend-mode:multiply;}
.cls-3{fill:#fff;}
.cls-4{fill:#e1251b;}
.cls-5{fill:#474c55;}
</style>
</defs>
<title>Sauce Labs</title>
<g
transform="translate(-0.87516672,-1.0999856)"
style="isolation:isolate"
id="g3807"
class="cls-1">
<g
id="white">
<path
style="fill:#e1251b"
id="path3774"
d="M 3.33,14.05 A 8,8 0 0 1 2.79,11.13 8.17,8.17 0 0 1 11,3 8.77,8.77 0 0 1 12.15,3.08 l -0.92,0.93 h -0.25 a 7.15,7.15 0 0 0 -6.88,9.1 h 6.26 L 7.7,18 14,11.62 H 5.4 L 15.09,2 A 9.94,9.94 0 0 0 10.94,1.1 10.07,10.07 0 0 0 5.69,19.76 l 3,-5.67 z"
class="cls-4" />
<path
style="fill:#e1251b"
id="path3776"
d="m 16.19,2.54 -3,5.67 h 5.37 A 8.15,8.15 0 0 1 10.95,19.28 9.39,9.39 0 0 1 9.76,19.2 l 0.91,-0.92 h 0.28 A 7.15,7.15 0 0 0 18.1,11.13 7.83,7.83 0 0 0 17.83,9.19 h -6.26 l 2.61,-4.93 -6.42,6.39 h 8.62 L 6.8,20.31 A 10.07,10.07 0 0 0 16.19,2.54 Z"
class="cls-4" />
<path
style="fill:#474c55"
id="path3778"
d="m 26,17.35 0.86,-1.27 a 0.44,0.44 0 0 1 0.69,-0.09 4.09,4.09 0 0 0 2.76,1.16 1.94,1.94 0 0 0 2,-1.89 c 0,-1 -0.66,-1.62 -1.91,-2.44 -1.46,-1 -3.2,-2.22 -3.2,-4.44 0,-2.22 1.54,-4.62 5,-4.62 a 6.11,6.11 0 0 1 4,1.44 0.63,0.63 0 0 1 0.06,0.89 L 35.4,7.31 C 35.22,7.58 34.93,7.6 34.62,7.36 a 3.67,3.67 0 0 0 -2.51,-1 1.82,1.82 0 0 0 -1.89,1.73 c 0,0.89 0.6,1.33 1.93,2.22 1.33,0.89 3.42,2.2 3.42,4.64 0,2.6 -2,4.78 -5.3,4.78 A 6.21,6.21 0 0 1 26,18 c -0.14,-0.12 -0.25,-0.32 0,-0.65 z"
class="cls-5" />
<path
style="fill:#474c55"
id="path3780"
d="M 36.92,19 45.27,4 a 0.42,0.42 0 0 1 0.38,-0.24 h 0.2 A 0.32,0.32 0 0 1 46.16,4 l 4.09,15 a 0.44,0.44 0 0 1 -0.42,0.58 H 47.9 c -0.34,0 -0.52,-0.12 -0.58,-0.45 l -0.56,-2.46 h -5.53 l -1.29,2.46 a 0.79,0.79 0 0 1 -0.71,0.45 h -2 C 36.88,19.53 36.77,19.24 36.92,19 Z m 9.13,-4.73 -1,-4.84 v 0 l -2.42,4.84 z"
class="cls-5" />
<path
style="fill:#474c55"
id="path3782"
d="M 54.51,4.4 A 0.51,0.51 0 0 1 55,4 h 2.2 a 0.35,0.35 0 0 1 0.33,0.42 l -1.33,9.35 a 3.54,3.54 0 0 0 0,0.71 2.09,2.09 0 0 0 2.27,2.36 c 1.82,0 2.84,-1.18 3.11,-3 l 1.33,-9.37 a 0.47,0.47 0 0 1 0.44,-0.42 h 2.2 a 0.37,0.37 0 0 1 0.34,0.42 l -1.36,9.51 c -0.47,3.37 -2.82,5.84 -6.28,5.84 a 4.81,4.81 0 0 1 -5.07,-5 6.94,6.94 0 0 1 0.07,-0.89 z"
class="cls-5" />
<path
style="fill:#474c55"
id="path3784"
d="m 76.5,3.76 a 6,6 0 0 1 4.62,2.11 0.46,0.46 0 0 1 -0.09,0.62 l -1.2,1.15 a 0.49,0.49 0 0 1 -0.73,0 4,4 0 0 0 -2.75,-1.11 c -2.67,0 -5,2.76 -5,5.93 0,2.36 1.27,4.38 3.4,4.38 a 4.6,4.6 0 0 0 3,-1.31 c 0.29,-0.25 0.53,-0.2 0.71,0 L 79.68,17 a 0.53,0.53 0 0 1 -0.11,0.6 7.11,7.11 0 0 1 -5,2.16 c -3.84,0 -6.33,-3.09 -6.33,-6.91 C 68.22,7.62 71.9,3.76 76.5,3.76 Z"
class="cls-5" />
<path
style="fill:#474c55"
id="path3786"
d="m 85.3,4.4 a 0.47,0.47 0 0 1 0.42,-0.42 h 8.22 A 0.35,0.35 0 0 1 94.27,4.4 L 94,6.22 a 0.47,0.47 0 0 1 -0.44,0.43 h -5.69 l -0.51,3.64 h 4.71 a 0.36,0.36 0 0 1 0.33,0.42 l -0.26,1.84 a 0.49,0.49 0 0 1 -0.45,0.42 H 87 l -0.55,3.89 h 5.71 c 0.22,0 0.33,0.2 0.31,0.42 l -0.25,1.82 a 0.47,0.47 0 0 1 -0.44,0.43 H 83.54 A 0.34,0.34 0 0 1 83.23,19.1 Z"
class="cls-5" />
<path
style="fill:#e1251b"
id="path3788"
d="M 99.56,4.4 A 0.49,0.49 0 0 1 100,4 h 1 a 0.37,0.37 0 0 1 0.34,0.42 L 99.36,18 H 105 a 0.35,0.35 0 0 1 0.31,0.42 l -0.09,0.64 a 0.49,0.49 0 0 1 -0.44,0.43 h -7 a 0.36,0.36 0 0 1 -0.33,-0.43 z"
class="cls-4" />
<path
style="fill:#e1251b"
id="path3790"
d="m 107.15,19 8.2,-15 a 0.42,0.42 0 0 1 0.37,-0.24 h 0.2 A 0.32,0.32 0 0 1 116.23,4 l 4,15 a 0.47,0.47 0 0 1 -0.42,0.58 h -0.94 a 0.32,0.32 0 0 1 -0.33,-0.25 l -0.89,-3.66 h -6.93 l -1.89,3.66 a 0.47,0.47 0 0 1 -0.42,0.25 h -1 C 107.11,19.53 107,19.24 107.15,19 Z m 10,-4.71 L 115.44,7 h -0.14 l -3.8,7.28 z"
class="cls-4" />
<path
style="fill:#e1251b"
id="path3792"
d="m 130.94,11.71 a 3.37,3.37 0 0 1 1.88,3 4.67,4.67 0 0 1 -5,4.8 h -4.6 a 0.36,0.36 0 0 1 -0.33,-0.43 L 125,4.4 a 0.51,0.51 0 0 1 0.45,-0.42 h 4.42 a 3.42,3.42 0 0 1 3.57,3.53 4.44,4.44 0 0 1 -2.46,4.13 z m -2.8,6.29 a 3,3 0 0 0 2.86,-3.12 2.33,2.33 0 0 0 -2.38,-2.39 h -3.11 L 124.7,18 Z m 0.67,-7.09 c 1.64,0 2.7,-1.31 2.7,-3.26 0,-1.29 -0.66,-2.18 -1.95,-2.18 H 126.5 L 125.72,11 Z"
class="cls-4" />
<path
style="fill:#e1251b"
id="path3794"
d="m 135.56,17.19 0.35,-0.37 c 0.27,-0.27 0.45,-0.36 0.71,-0.11 a 4.32,4.32 0 0 0 3.29,1.55 2.65,2.65 0 0 0 2.8,-2.69 c 0,-1.4 -1.05,-2.22 -2.89,-3.28 -1.84,-1.06 -3,-2 -3,-4.05 0,-1.86 1.17,-4.48 4.81,-4.48 a 5.7,5.7 0 0 1 3.45,1.13 c 0.11,0.09 0.31,0.33 0,0.76 L 144.83,6 c -0.22,0.31 -0.44,0.4 -0.73,0.2 a 4.52,4.52 0 0 0 -2.64,-0.95 2.88,2.88 0 0 0 -3,2.79 c 0,1.25 0.85,2.07 2.25,2.82 2.13,1.16 3.75,2.25 3.75,4.54 0,2.46 -1.78,4.35 -4.86,4.35 a 5.69,5.69 0 0 1 -4.16,-1.91 c -0.08,-0.16 -0.17,-0.36 0.12,-0.65 z"
class="cls-4" />
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 5.3 KiB

34
node_modules/level-js/util/clear.js generated vendored Normal file
View File

@@ -0,0 +1,34 @@
'use strict'
module.exports = function clear (db, location, keyRange, options, callback) {
if (options.limit === 0) return db._nextTick(callback)
var transaction = db.db.transaction([location], 'readwrite')
var store = transaction.objectStore(location)
var count = 0
transaction.oncomplete = function () {
callback()
}
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()
}
}
}
}
}

44
node_modules/level-js/util/deserialize.js generated vendored Normal file
View File

@@ -0,0 +1,44 @@
'use strict'
var Buffer = require('buffer').Buffer
var ta2str = (function () {
if (global.TextDecoder) {
var decoder = new TextDecoder('utf-8')
return decoder.decode.bind(decoder)
} else {
return function ta2str (ta) {
return ta2buf(ta).toString()
}
}
})()
var ab2str = (function () {
if (global.TextDecoder) {
var decoder = new TextDecoder('utf-8')
return decoder.decode.bind(decoder)
} else {
return function ab2str (ab) {
return Buffer.from(ab).toString()
}
}
})()
function ta2buf (ta) {
var buf = Buffer.from(ta.buffer)
if (ta.byteLength === ta.buffer.byteLength) {
return buf
} else {
return buf.slice(ta.byteOffset, ta.byteOffset + ta.byteLength)
}
}
module.exports = function (data, asBuffer) {
if (data instanceof Uint8Array) {
return asBuffer ? ta2buf(data) : ta2str(data)
} else if (data instanceof ArrayBuffer) {
return asBuffer ? Buffer.from(data) : ab2str(data)
} else {
return asBuffer ? Buffer.from(String(data)) : String(data)
}
}

23
node_modules/level-js/util/key-range.js generated vendored Normal file
View File

@@ -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
}
}

21
node_modules/level-js/util/serialize.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
'use strict'
var Buffer = require('buffer').Buffer
// Returns either a Uint8Array or Buffer (doesn't matter to
// IndexedDB, because Buffer is a subclass of Uint8Array)
var str2bin = (function () {
if (global.TextEncoder) {
var encoder = new TextEncoder('utf-8')
return encoder.encode.bind(encoder)
} else {
return Buffer.from
}
})()
module.exports = function (data, asBuffer) {
if (asBuffer) {
return Buffer.isBuffer(data) ? data : str2bin(String(data))
} else {
return String(data)
}
}

17
node_modules/level-js/util/support.js generated vendored Normal file
View File

@@ -0,0 +1,17 @@
'use strict'
var Buffer = require('buffer').Buffer
exports.test = function (key) {
return function test (impl) {
try {
impl.cmp(key, 0)
return true
} catch (err) {
return false
}
}
}
// Detect binary key support (IndexedDB Second Edition)
exports.bufferKeys = exports.test(Buffer.alloc(0))