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

11
node_modules/level-codec/.travis.yml generated vendored Normal file
View File

@@ -0,0 +1,11 @@
language: node_js
node_js:
- 6
- 8
- 10
after_success: npm run coverage
notifications:
email: false

293
node_modules/level-codec/CHANGELOG.md generated vendored Normal file
View File

@@ -0,0 +1,293 @@
# Changelog
_**If you are upgrading:** please see [`UPGRADING.md`](UPGRADING.md)._
## [9.0.2] - 2020-06-26
### Changed
- Upgrade `hallmark` devDependency from `^0.1.0` to `^2.0.0` ([#53](https://github.com/Level/codec/issues/53), [#56](https://github.com/Level/codec/issues/56)) ([**@vweevers**](https://github.com/vweevers))
- Upgrade `standard` devDependency from `^12.0.0` to `^14.0.0` ([#52](https://github.com/Level/codec/issues/52), [#55](https://github.com/Level/codec/issues/55)) ([**@vweevers**](https://github.com/vweevers))
- Upgrade `nyc` devDependency from `^13.2.0` to `^14.0.0` ([#50](https://github.com/Level/codec/issues/50)) ([**@vweevers**](https://github.com/vweevers))
### Fixed
- Add `buffer` dependency for browsers ([#58](https://github.com/Level/codec/issues/58)) ([**@hugomrdias**](https://github.com/hugomrdias))
## [9.0.1] - 2019-04-01
### Changed
- Upgrade `standard` devDependency from `^11.0.1` to `^12.0.0` ([#38](https://github.com/Level/codec/issues/38)) ([**@ralphtheninja**](https://github.com/ralphtheninja))
- Update description in README and `package.json` ([#47](https://github.com/Level/codec/issues/47)) ([**@vweevers**](https://github.com/vweevers))
- Apply common project tweaks ([#39](https://github.com/Level/codec/issues/39), [#40](https://github.com/Level/codec/issues/40), [#41](https://github.com/Level/codec/issues/41)) ([**@vweevers**](https://github.com/vweevers))
- Tweak copyright year for less maintenance ([`79d2d02`](https://github.com/Level/codec/commit/79d2d02)) ([**@ralphtheninja**](https://github.com/ralphtheninja))
### Added
- Add `nyc` and `coveralls` ([#36](https://github.com/Level/codec/issues/36), [#44](https://github.com/Level/codec/issues/44)) ([**@ralphtheninja**](https://github.com/ralphtheninja), [**@vweevers**](https://github.com/vweevers))
- Add `CHANGELOG.md` and `UPGRADING.md` ([#47](https://github.com/Level/codec/issues/47)) ([**@vweevers**](https://github.com/vweevers))
### Removed
- Remove node 9 from travis ([`ffe3f92`](https://github.com/Level/codec/commit/ffe3f92)) ([**@ralphtheninja**](https://github.com/ralphtheninja))
- Remove experimental typings ([`1cfd23f`](https://github.com/Level/codec/commit/1cfd23f)) ([**@ralphtheninja**](https://github.com/ralphtheninja))
### Fixed
- Fix subtests by adding `t.plan()` ([#46](https://github.com/Level/codec/issues/46)) ([**@vweevers**](https://github.com/vweevers))
## [9.0.0] - 2018-05-12
### Changed
- Update README ([#31](https://github.com/Level/codec/issues/31)) ([**@ralphtheninja**](https://github.com/ralphtheninja))
### Added
- Add `standard` ([#29](https://github.com/Level/codec/issues/29)) ([**@ralphtheninja**](https://github.com/ralphtheninja))
- Add node 9 and 10 ([`9476e58`](https://github.com/Level/codec/commit/9476e58)) ([**@ralphtheninja**](https://github.com/ralphtheninja))
### Removed
- Drop node 0.12, 4, 5 and 7 ([`9476e58`](https://github.com/Level/codec/commit/9476e58), [#32](https://github.com/Level/codec/issues/32)) ([**@ralphtheninja**](https://github.com/ralphtheninja))
### Fixed
- Fix constructor to work without `new` ([#30](https://github.com/Level/codec/issues/30)) ([**@ralphtheninja**](https://github.com/ralphtheninja))
## [8.0.0] - 2017-10-21
### Changed
- Revert "fix utf-8 encoding returning buffers" ([#23](https://github.com/Level/codec/issues/23)) ([**@ralphtheninja**](https://github.com/ralphtheninja))
### Added
- Add badges to `README` and stylize "levelup" ([#22](https://github.com/Level/codec/issues/22)) ([**@vweevers**](https://github.com/vweevers))
- Document encodings and their format in greater detail ([#22](https://github.com/Level/codec/issues/22)) ([**@vweevers**](https://github.com/vweevers))
## [7.1.0] - 2017-09-12
### Changed
- Update copyright year from 2015 to 2017 ([`aceb6ff`](https://github.com/Level/codec/commit/aceb6ff)) ([**@ralphtheninja**](https://github.com/ralphtheninja))
### Added
- Add basic typings ([#18](https://github.com/Level/codec/issues/18)) ([**@MeirionHughes**](https://github.com/MeirionHughes))
- Add node 4, 5, 6, 7 and 8 ([`5c00a1c`](https://github.com/Level/codec/commit/5c00a1c)) ([**@ralphtheninja**](https://github.com/ralphtheninja))
### Removed
- Drop node 0.10 and iojs ([`5c00a1c`](https://github.com/Level/codec/commit/5c00a1c)) ([**@ralphtheninja**](https://github.com/ralphtheninja))
## [7.0.1] - 2017-08-14
### Added
- Add Greenkeeper ([#17](https://github.com/Level/codec/issues/17)) ([**@ralphtheninja**](https://github.com/ralphtheninja))
### Fixed
- Use `identity` function consistently ([#14](https://github.com/Level/codec/issues/14)) ([**@dcousens**](https://github.com/dcousens))
## [7.0.0] - 2017-01-26
### Fixed
- Fix utf-8 encoding returning buffers ([#12](https://github.com/Level/codec/issues/12)) ([**@juliangruber**](https://github.com/juliangruber))
## [6.2.0] - 2016-02-24
### Changed
- Rename "id" encoding to "none", add "id" alias ([#10](https://github.com/Level/codec/issues/10)) ([**@juliangruber**](https://github.com/juliangruber))
- Upgrade `tape` devDependency ([#9](https://github.com/Level/codec/issues/9)) ([**@ralphtheninja**](https://github.com/ralphtheninja))
### Added
- Document available encodings ([#10](https://github.com/Level/codec/issues/10)) ([**@juliangruber**](https://github.com/juliangruber))
## [6.1.0] - 2015-10-21
### Added
- Fallback to legacy `encoding` option if `valueEncoding` is not provided ([#8](https://github.com/Level/codec/issues/8)) ([**@dominictarr**](https://github.com/dominictarr))
## [6.0.0] - 2015-05-04
### Changed
- Replace `createDecodeStream()` with `createStreamDecoder()` ([#6](https://github.com/Level/codec/issues/6)) ([**@juliangruber**](https://github.com/juliangruber))
## [5.5.0] - 2015-04-17
### Added
- Add `createDecodeStream()` ([#5](https://github.com/Level/codec/issues/5)) ([**@juliangruber**](https://github.com/juliangruber))
## [5.4.0] - 2015-04-17
### Changed
- Simplify `encodeLtgt()` ([`24f3817`](https://github.com/Level/codec/commit/24f3817)) ([**@juliangruber**](https://github.com/juliangruber))
## [5.3.0] - 2015-04-17
### Added
- Add `encodeLtgt()` ([#4](https://github.com/Level/codec/issues/4)) ([**@juliangruber**](https://github.com/juliangruber))
## [5.2.0] - 2015-03-24
### Changed
- Make all options optional ([`4f942eb`](https://github.com/Level/codec/commit/4f942eb)) ([**@juliangruber**](https://github.com/juliangruber))
## [5.1.0] - 2015-03-24
### Changed
- Make member options optional ([`0c98ccb`](https://github.com/Level/codec/commit/0c98ccb)) ([**@juliangruber**](https://github.com/juliangruber))
## [5.0.0] - 2015-03-24
**Historical Note** 4.3.0 was meant to be a major release.
## [4.3.0] - 2015-03-24
### Changed
- Rewrite ([`37f103e`](https://github.com/Level/codec/commit/37f103e), [`054fb3f`](https://github.com/Level/codec/commit/054fb3f), [`f510a90`](https://github.com/Level/codec/commit/f510a90)) ([**@juliangruber**](https://github.com/juliangruber))
### Added
- Add [**@ralphtheninja**](https://github.com/ralphtheninja) to contributors ([`dd2b9a0`](https://github.com/Level/codec/commit/dd2b9a0)) ([**@juliangruber**](https://github.com/juliangruber))
- Add travis and licensing ([#1](https://github.com/Level/codec/issues/1)) ([**@ralphtheninja**](https://github.com/ralphtheninja))
## [4.2.0] - 2015-03-19
### Fixed
- Keep batch `.prefix` for `level-sublevel` ([`f706482`](https://github.com/Level/codec/commit/f706482)) ([**@juliangruber**](https://github.com/juliangruber))
## [4.1.0] - 2015-03-19
### Fixed
- Set `batch` encodings to binary if `{key,value}AsBuffer` is true ([`bcf6feb`](https://github.com/Level/codec/commit/bcf6feb)) ([**@juliangruber**](https://github.com/juliangruber))
## [4.0.1] - 2015-03-19
### Fixed
- Skip falsy objects in `walk` ([`270ea17`](https://github.com/Level/codec/commit/270ea17)) ([**@juliangruber**](https://github.com/juliangruber))
## [4.0.0] - 2015-03-19
### Removed
- Remove default encoding ([`28a63b2`](https://github.com/Level/codec/commit/28a63b2)) ([**@juliangruber**](https://github.com/juliangruber))
## [3.1.0] - 2015-03-19
### Added
- Add experimental `Codec` class ([`8a189f4`](https://github.com/Level/codec/commit/8a189f4)) ([**@juliangruber**](https://github.com/juliangruber))
## [3.0.0] - 2015-03-18
### Removed
- Remove `encoding` option in favor of `keyEncoding` and `valueEncoding` ([`9fed84d`](https://github.com/Level/codec/commit/9fed84d)) ([**@juliangruber**](https://github.com/juliangruber))
## [2.0.1] - 2015-03-18
### Fixed
- Fix `encoding` option to only be an alias for `valueEncoding` ([`b4de4d1`](https://github.com/Level/codec/commit/b4de4d1)) ([**@juliangruber**](https://github.com/juliangruber))
## [2.0.0] - 2015-03-18
### Changed
- Remove side effects from `batch()` ([`bedaa26`](https://github.com/Level/codec/commit/bedaa26), [`6f5b373`](https://github.com/Level/codec/commit/6f5b373), [`abef01b`](https://github.com/Level/codec/commit/abef01b)) ([**@juliangruber**](https://github.com/juliangruber))
## [1.2.1] - 2015-03-18
### Fixed
- Fix `require` statements for `{key,value}AsBuffer()` ([`71bf7a5`](https://github.com/Level/codec/commit/71bf7a5)) ([**@juliangruber**](https://github.com/juliangruber))
## [1.2.0] - 2015-03-18
### Added
- Add `{key,value}AsBuffer()` ([`796a540`](https://github.com/Level/codec/commit/796a540)) ([**@juliangruber**](https://github.com/juliangruber))
## [1.1.0] - 2015-03-18
### Added
- Add `decode{Key,Value}` ([`029fbd7`](https://github.com/Level/codec/commit/029fbd7)) ([**@juliangruber**](https://github.com/juliangruber))
## 1.0.1 - 2015-03-18
:seedling: Initial release.
[9.0.2]: https://github.com/Level/codec/compare/v9.0.1...v9.0.2
[9.0.1]: https://github.com/Level/codec/compare/v9.0.0...v9.0.1
[9.0.0]: https://github.com/Level/codec/compare/v8.0.0...v9.0.0
[8.0.0]: https://github.com/Level/codec/compare/v7.1.0...v8.0.0
[7.1.0]: https://github.com/Level/codec/compare/v7.0.1...v7.1.0
[7.0.1]: https://github.com/Level/codec/compare/v7.0.0...v7.0.1
[7.0.0]: https://github.com/Level/codec/compare/v6.2.0...v7.0.0
[6.2.0]: https://github.com/Level/codec/compare/v6.1.0...v6.2.0
[6.1.0]: https://github.com/Level/codec/compare/v6.0.0...v6.1.0
[6.0.0]: https://github.com/Level/codec/compare/v5.5.0...v6.0.0
[5.5.0]: https://github.com/Level/codec/compare/v5.4.0...v5.5.0
[5.4.0]: https://github.com/Level/codec/compare/v5.3.0...v5.4.0
[5.3.0]: https://github.com/Level/codec/compare/v5.2.0...v5.3.0
[5.2.0]: https://github.com/Level/codec/compare/v5.1.0...v5.2.0
[5.1.0]: https://github.com/Level/codec/compare/v5.0.0...v5.1.0
[5.0.0]: https://github.com/Level/codec/compare/v4.3.0...v5.0.0
[4.3.0]: https://github.com/Level/codec/compare/v4.2.0...v4.3.0
[4.2.0]: https://github.com/Level/codec/compare/v4.1.0...v4.2.0
[4.1.0]: https://github.com/Level/codec/compare/v4.0.1...v4.1.0
[4.0.1]: https://github.com/Level/codec/compare/v4.0.0...v4.0.1
[4.0.0]: https://github.com/Level/codec/compare/v3.1.0...v4.0.0
[3.1.0]: https://github.com/Level/codec/compare/v3.0.0...v3.1.0
[3.0.0]: https://github.com/Level/codec/compare/v2.0.1...v3.0.0
[2.0.1]: https://github.com/Level/codec/compare/v2.0.0...v2.0.1
[2.0.0]: https://github.com/Level/codec/compare/v1.2.1...v2.0.0
[1.2.1]: https://github.com/Level/codec/compare/v1.2.0...v1.2.1
[1.2.0]: https://github.com/Level/codec/compare/v1.1.0...v1.2.0
[1.1.0]: https://github.com/Level/codec/compare/v1.0.1...v1.1.0

11
node_modules/level-codec/CONTRIBUTORS.md generated vendored Normal file
View File

@@ -0,0 +1,11 @@
# Contributors
| Name | GitHub | Social |
| :------------------- | :----------------------------------------------------- | :------------------------------------------------------------ |
| **Julian Gruber** | [**@juliangruber**](https://github.com/juliangruber) | [**@juliangruber@twitter**](https://twitter.com/juliangruber) |
| **Lars-Magnus Skog** | [**@ralphtheninja**](https://github.com/ralphtheninja) | [**@ralph@social.weho.st**](https://social.weho.st/@ralph) |
| **Vincent Weevers** | [**@vweevers**](https://github.com/vweevers) | [**@vweevers@twitter**](https://twitter.com/vweevers) |
| **Dominic Tarr** | [**@dominictarr**](https://github.com/dominictarr) | [**@dominictarr@twitter**](https://twitter.com/dominictarr) |
| **Daniel Cousens** | [**@dcousens**](https://github.com/dcousens) | |
| **Hugo Dias** | | |
| **Meirion Hughes** | [**@MeirionHughes**](https://github.com/MeirionHughes) | |

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

@@ -0,0 +1,21 @@
# The MIT License (MIT)
**Copyright © 2012-present [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.

148
node_modules/level-codec/README.md generated vendored Normal file
View File

@@ -0,0 +1,148 @@
# level-codec
> Encode keys, values and range options, with built-in or custom encodings.
[![level badge][level-badge]](https://github.com/Level/awesome)
[![npm](https://img.shields.io/npm/v/level-codec.svg?label=&logo=npm)](https://www.npmjs.com/package/level-codec)
[![Node version](https://img.shields.io/node/v/level-codec.svg)](https://www.npmjs.com/package/level-codec)
[![Travis](https://img.shields.io/travis/com/Level/codec.svg?logo=travis&label=)](https://travis-ci.com/Level/codec)
[![npm](https://img.shields.io/npm/dm/level-codec.svg?label=dl)](https://www.npmjs.com/package/level-codec)
[![Coverage Status](https://coveralls.io/repos/github/Level/codec/badge.svg)](https://coveralls.io/github/Level/codec)
[![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)
## Usage
**If you are upgrading:** please see [`UPGRADING.md`](UPGRADING.md).
```js
const Codec = require('level-codec')
const codec = Codec({ keyEncoding: 'json' })
const key = codec.encodeKey({ foo: 'bar' })
console.log(key) // -> '{"foo":"bar"}'
console.log(codec.decodeKey(key)) // -> { foo: 'bar' }
```
## API
### `codec = Codec([opts])`
Create a new codec, with a global options object.
### `codec.encodeKey(key[, opts])`
Encode `key` with given `opts`.
### `codec.encodeValue(value[, opts])`
Encode `value` with given `opts`.
### `codec.encodeBatch(batch[, opts])`
Encode `batch` ops with given `opts`.
### `codec.encodeLtgt(ltgt)`
Encode the ltgt values of option object `ltgt`.
### `codec.decodeKey(key[, opts])`
Decode `key` with given `opts`.
### `codec.decodeValue(value[, opts])`
Decode `value` with given `opts`.
### `codec.createStreamDecoder([opts])`
Create a function with signature `(key, value)`, that for each key-value pair returned from a levelup read stream returns the decoded value to be emitted.
### `codec.keyAsBuffer([opts])`
Check whether `opts` and the global `opts` call for a binary key encoding.
### `codec.valueAsBuffer([opts])`
Check whether `opts` and the global `opts` call for a binary value encoding.
### `codec.encodings`
The builtin encodings as object of form
```js
{
[type]: encoding
}
```
See below for a list and the format of `encoding`.
## Builtin Encodings
| Type | Input | Stored as | Output |
| :---------------------------------------------------------------- | :--------------------------- | :--------------- | :-------- |
| `utf8` | String or Buffer | String or Buffer | String |
| `json` | Any JSON type | JSON string | Input |
| `binary` | Buffer, string or byte array | Buffer | As stored |
| `hex`<br>`ascii`<br>`base64`<br>`ucs2`<br>`utf16le`<br>`utf-16le` | String or Buffer | Buffer | String |
| `none` a.k.a. `id` | Any type (bypass encoding) | Input\* | As stored |
<sup>\*</sup> Stores may have their own type coercion. Whether type information is preserved depends on the [`abstract-leveldown`] implementation as well as the underlying storage (`LevelDB`, `IndexedDB`, etc).
## Encoding Format
An encoding is an object of the form:
```js
{
encode: function (data) {
return data
},
decode: function (data) {
return data
},
buffer: Boolean,
type: 'example'
}
```
All of these properties are required.
The `buffer` boolean tells consumers whether to fetch data as a Buffer, before calling your `decode()` function on that data. If `buffer` is true, it is assumed that `decode()` takes a Buffer. If false, it is assumed that `decode` takes any other type (usually a string).
To explain this in the grand scheme of things, consider a store like [`leveldown`] which has the ability to return either a Buffer or string, both sourced from the same byte array. Wrap this store with [`encoding-down`] and it'll select the most optimal data type based on the `buffer` property of the active encoding. If your `decode()` function needs a string (and the data can legitimately become a UTF8 string), you should set `buffer` to `false`. This avoids the cost of having to convert a Buffer to a string.
The `type` string should be a unique name.
## Contributing
[`Level/codec`](https://github.com/Level/codec) 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 [Contributors](CONTRIBUTORS.md).
[level-badge]: https://leveljs.org/img/badge.svg
[`encoding-down`]: https://github.com/Level/encoding-down
[`abstract-leveldown`]: https://github.com/Level/abstract-leveldown
[`leveldown`]: https://github.com/Level/leveldown

35
node_modules/level-codec/UPGRADING.md generated vendored Normal file
View File

@@ -0,0 +1,35 @@
# 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.md).
## v9
Dropped node 0.12, 4, 5 and 7.
## v8
Previously the "utf8" decoder always returned a string. This was a workaround for `encoding-down` that is no longer needed. The return type now depends on the `asBuffer` option, which is more optimal.
## v7
Dropped node 0.10 and iojs.
## v6
The `createDecodeStream()` method (introduced in the last 5.x version) has been replaced with `createStreamDecoder()`.
## v5
This is a rewrite of both internals and the public API. Please see the README for details.
## v4
Removed default encoding ("utf8"). If you relied on this behavior you must now define it yourself.
## v3
Removed the `encoding` option in favor of `keyEncoding` and `valueEncoding`. Note: it was partially restored in v6.1.0.
## v2
The function signature of `batch()` has changed from `batch(ops, batchOptions, dbOptions)` to `batch(ops, optionObjects)`.

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

@@ -0,0 +1,107 @@
var encodings = require('./lib/encodings')
module.exports = Codec
function Codec (opts) {
if (!(this instanceof Codec)) {
return new Codec(opts)
}
this.opts = opts || {}
this.encodings = encodings
}
Codec.prototype._encoding = function (encoding) {
if (typeof encoding === 'string') encoding = encodings[encoding]
if (!encoding) encoding = encodings.id
return encoding
}
Codec.prototype._keyEncoding = function (opts, batchOpts) {
return this._encoding((batchOpts && batchOpts.keyEncoding) ||
(opts && opts.keyEncoding) ||
this.opts.keyEncoding)
}
Codec.prototype._valueEncoding = function (opts, batchOpts) {
return this._encoding((batchOpts && (batchOpts.valueEncoding || batchOpts.encoding)) ||
(opts && (opts.valueEncoding || opts.encoding)) ||
(this.opts.valueEncoding || this.opts.encoding))
}
Codec.prototype.encodeKey = function (key, opts, batchOpts) {
return this._keyEncoding(opts, batchOpts).encode(key)
}
Codec.prototype.encodeValue = function (value, opts, batchOpts) {
return this._valueEncoding(opts, batchOpts).encode(value)
}
Codec.prototype.decodeKey = function (key, opts) {
return this._keyEncoding(opts).decode(key)
}
Codec.prototype.decodeValue = function (value, opts) {
return this._valueEncoding(opts).decode(value)
}
Codec.prototype.encodeBatch = function (ops, opts) {
var self = this
return ops.map(function (_op) {
var op = {
type: _op.type,
key: self.encodeKey(_op.key, opts, _op)
}
if (self.keyAsBuffer(opts, _op)) op.keyEncoding = 'binary'
if (_op.prefix) op.prefix = _op.prefix
if ('value' in _op) {
op.value = self.encodeValue(_op.value, opts, _op)
if (self.valueAsBuffer(opts, _op)) op.valueEncoding = 'binary'
}
return op
})
}
var ltgtKeys = ['lt', 'gt', 'lte', 'gte', 'start', 'end']
Codec.prototype.encodeLtgt = function (ltgt) {
var self = this
var ret = {}
Object.keys(ltgt).forEach(function (key) {
ret[key] = ltgtKeys.indexOf(key) > -1
? self.encodeKey(ltgt[key], ltgt)
: ltgt[key]
})
return ret
}
Codec.prototype.createStreamDecoder = function (opts) {
var self = this
if (opts.keys && opts.values) {
return function (key, value) {
return {
key: self.decodeKey(key, opts),
value: self.decodeValue(value, opts)
}
}
} else if (opts.keys) {
return function (key) {
return self.decodeKey(key, opts)
}
} else if (opts.values) {
return function (_, value) {
return self.decodeValue(value, opts)
}
} else {
return function () {}
}
}
Codec.prototype.keyAsBuffer = function (opts) {
return this._keyEncoding(opts).buffer
}
Codec.prototype.valueAsBuffer = function (opts) {
return this._valueEncoding(opts).buffer
}

66
node_modules/level-codec/lib/encodings.js generated vendored Normal file
View File

@@ -0,0 +1,66 @@
var Buffer = require('buffer').Buffer
exports.utf8 = exports['utf-8'] = {
encode: function (data) {
return isBinary(data) ? data : String(data)
},
decode: identity,
buffer: false,
type: 'utf8'
}
exports.json = {
encode: JSON.stringify,
decode: JSON.parse,
buffer: false,
type: 'json'
}
exports.binary = {
encode: function (data) {
return isBinary(data) ? data : Buffer.from(data)
},
decode: identity,
buffer: true,
type: 'binary'
}
exports.none = {
encode: identity,
decode: identity,
buffer: false,
type: 'id'
}
exports.id = exports.none
var bufferEncodings = [
'hex',
'ascii',
'base64',
'ucs2',
'ucs-2',
'utf16le',
'utf-16le'
]
bufferEncodings.forEach(function (type) {
exports[type] = {
encode: function (data) {
return isBinary(data) ? data : Buffer.from(data, type)
},
decode: function (buffer) {
return buffer.toString(type)
},
buffer: true,
type: type
}
})
function identity (value) {
return value
}
function isBinary (data) {
return data === undefined || data === null || Buffer.isBuffer(data)
}

37
node_modules/level-codec/package.json generated vendored Normal file
View File

@@ -0,0 +1,37 @@
{
"name": "level-codec",
"version": "9.0.2",
"description": "Encode keys, values and range options, with built-in or custom encodings",
"license": "MIT",
"main": "index.js",
"scripts": {
"test": "standard && hallmark && nyc tape test/*.js",
"coverage": "nyc report --reporter=text-lcov | coveralls",
"hallmark": "hallmark --fix",
"dependency-check": "dependency-check . test/*.js",
"prepublishOnly": "npm run dependency-check"
},
"dependencies": {
"buffer": "^5.6.0"
},
"devDependencies": {
"coveralls": "^3.0.2",
"dependency-check": "^3.3.0",
"hallmark": "^2.0.0",
"level-community": "^3.0.0",
"nyc": "^14.0.0",
"standard": "^14.0.0",
"tape": "^4.10.0"
},
"hallmark": {
"community": "level-community"
},
"repository": "Level/codec",
"homepage": "https://github.com/Level/codec",
"keywords": [
"level"
],
"engines": {
"node": ">=6"
}
}

18
node_modules/level-codec/test/as-buffer.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
var test = require('tape')
var Codec = require('..')
test('key as buffer', function (t) {
var codec = new Codec({ keyEncoding: 'hex' })
t.ok(codec.keyAsBuffer({}))
t.ok(codec.keyAsBuffer())
t.notOk(codec.keyAsBuffer({ keyEncoding: 'utf8' }))
t.end()
})
test('value as buffer', function (t) {
var codec = new Codec({ valueEncoding: 'hex' })
t.ok(codec.valueAsBuffer({}))
t.ok(codec.valueAsBuffer())
t.notOk(codec.valueAsBuffer({ valueEncoding: 'utf8' }))
t.end()
})

54
node_modules/level-codec/test/batch.js generated vendored Normal file
View File

@@ -0,0 +1,54 @@
var test = require('tape')
var Codec = require('..')
test('batch', function (t) {
var codec = new Codec({})
var ops = [
{ type: 'put', key: 'string', value: 'string', valueEncoding: 'utf8' },
{ type: 'put', key: 'json', value: {} }
]
var opsSerialized = JSON.stringify(ops)
var encoded = codec.encodeBatch(ops, { valueEncoding: 'json' })
t.equal(opsSerialized, JSON.stringify(ops), 'ops not changed')
t.deepEqual(encoded, [
{ type: 'put', key: 'string', value: 'string' },
{ type: 'put', key: 'json', value: '{}' }
])
encoded = codec.encodeBatch(ops)
t.deepEqual(encoded, [
{ type: 'put', key: 'string', value: 'string' },
{ type: 'put', key: 'json', value: {} }
])
t.end()
})
test('batch - legacy', function (t) {
var codec = new Codec({})
var ops = [
{ type: 'put', key: 'string', value: 'string', encoding: 'utf8' },
{ type: 'put', key: 'json', value: {} }
]
var opsSerialized = JSON.stringify(ops)
var encoded = codec.encodeBatch(ops, { encoding: 'json' })
t.equal(opsSerialized, JSON.stringify(ops), 'ops not changed')
t.deepEqual(encoded, [
{ type: 'put', key: 'string', value: 'string' },
{ type: 'put', key: 'json', value: '{}' }
])
encoded = codec.encodeBatch(ops)
t.deepEqual(encoded, [
{ type: 'put', key: 'string', value: 'string' },
{ type: 'put', key: 'json', value: {} }
])
t.end()
})

18
node_modules/level-codec/test/codec.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
var test = require('tape')
var Codec = require('..')
test('codec', function (t) {
var codec = new Codec({ keyEncoding: 'hex' })
t.ok(codec.keyAsBuffer())
codec = new Codec()
t.notOk(codec.keyAsBuffer())
t.end()
})
test('codec, new not needed', function (t) {
var codec = Codec({ keyEncoding: 'hex' })
t.ok(codec.keyAsBuffer())
codec = Codec()
t.notOk(codec.keyAsBuffer())
t.end()
})

74
node_modules/level-codec/test/decoder.js generated vendored Normal file
View File

@@ -0,0 +1,74 @@
var test = require('tape')
var Codec = require('..')
test('createStreamDecoder', function (t) {
var codec = new Codec({ keyEncoding: 'hex' })
t.plan(3)
t.test('keys and values', function (t) {
var decoder = codec.createStreamDecoder({
valueEncoding: 'json',
keys: true,
values: true
})
t.deepEqual(decoder(Buffer.from('hey'), '"you"'), {
key: '686579',
value: 'you'
})
t.end()
})
t.test('keys', function (t) {
var decoder = codec.createStreamDecoder({
keys: true
})
t.equal(decoder(Buffer.from('hey')), '686579')
t.end()
})
t.test('values', function (t) {
var decoder = codec.createStreamDecoder({
valueEncoding: 'hex',
values: true
})
t.equal(decoder(null, Buffer.from('hey')), '686579')
t.end()
})
})
test('createStreamDecoder - legacy', function (t) {
var codec = new Codec({ keyEncoding: 'hex' })
t.plan(3)
t.test('keys and values', function (t) {
var decoder = codec.createStreamDecoder({
encoding: 'json',
keys: true,
values: true
})
t.deepEqual(decoder(Buffer.from('hey'), '"you"'), {
key: '686579',
value: 'you'
})
t.end()
})
t.test('keys', function (t) {
var decoder = codec.createStreamDecoder({
keys: true
})
t.equal(decoder(Buffer.from('hey')), '686579')
t.end()
})
t.test('values', function (t) {
var decoder = codec.createStreamDecoder({
encoding: 'hex',
values: true
})
t.equal(decoder(null, Buffer.from('hey')), '686579')
t.end()
})
})

109
node_modules/level-codec/test/kv.js generated vendored Normal file
View File

@@ -0,0 +1,109 @@
var test = require('tape')
var Codec = require('..')
test('encode key', function (t) {
var codec = new Codec({ keyEncoding: 'hex' })
var buf = codec.encodeKey('686579', {})
t.equal(buf.toString(), 'hey')
buf = codec.encodeKey('686579')
t.equal(buf.toString(), 'hey')
buf = codec.encodeKey('686579', {
keyEncoding: 'binary'
})
t.equal(buf.toString(), '686579')
buf = codec.encodeKey({ foo: 'bar' }, {
keyEncoding: 'none'
})
t.deepEqual(buf, { foo: 'bar' })
t.end()
})
test('encode value', function (t) {
var codec = new Codec({ valueEncoding: 'hex' })
var buf = codec.encodeValue('686579', {})
t.equal(buf.toString(), 'hey')
buf = codec.encodeValue('686579')
t.equal(buf.toString(), 'hey')
buf = codec.encodeValue('686579', {
valueEncoding: 'binary'
})
t.equal(buf.toString(), '686579')
t.end()
})
test('decode key', function (t) {
var codec = new Codec({ keyEncoding: 'hex' })
var buf = codec.decodeKey(Buffer.from('hey'), {})
t.equal(buf, '686579')
buf = codec.decodeKey(Buffer.from('hey'))
t.equal(buf, '686579')
buf = codec.decodeKey(Buffer.from('hey'), {
keyEncoding: 'binary'
})
t.equal(buf.toString(), 'hey')
t.end()
})
test('decode value', function (t) {
var codec = new Codec({ valueEncoding: 'hex' })
var buf = codec.decodeValue(Buffer.from('hey'), {})
t.equal(buf, '686579')
buf = codec.decodeValue(Buffer.from('hey'))
t.equal(buf, '686579')
buf = codec.decodeValue(Buffer.from('hey'), {
valueEncoding: 'binary'
})
t.equal(buf.toString(), 'hey')
t.end()
})
test('encode value - legacy', function (t) {
var codec = new Codec({ encoding: 'hex' })
var buf = codec.encodeValue('686579', {})
t.equal(buf.toString(), 'hey')
buf = codec.encodeValue('686579')
t.equal(buf.toString(), 'hey')
buf = codec.encodeValue('686579', {
encoding: 'binary'
})
t.equal(buf.toString(), '686579')
t.end()
})
test('decode value - legacy', function (t) {
var codec = new Codec({ encoding: 'hex' })
var buf = codec.decodeValue(Buffer.from('hey'), {})
t.equal(buf, '686579')
buf = codec.decodeValue(Buffer.from('hey'))
t.equal(buf, '686579')
buf = codec.decodeValue(Buffer.from('hey'), {
encoding: 'binary'
})
t.equal(buf.toString(), 'hey')
t.end()
})

25
node_modules/level-codec/test/ltgt.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
var test = require('tape')
var Codec = require('..')
test('encode ltgt', function (t) {
var codec = new Codec({ keyEncoding: 'hex' })
var ltgt = {
start: '686579',
lte: '686579'
}
var encoded = codec.encodeLtgt(ltgt)
t.equal(encoded.start.toString(), 'hey')
t.equal(encoded.lte.toString(), 'hey')
ltgt = {
start: '686579',
lte: '686579',
keyEncoding: 'json'
}
encoded = codec.encodeLtgt(ltgt)
t.equal(encoded.start, '"686579"')
t.equal(encoded.lte, '"686579"')
t.end()
})