@ohos-ports/level-js 0.0.0-stage → 6.1.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/iterator.js ADDED
@@ -0,0 +1,144 @@
1
+ 'use strict'
2
+
3
+ const inherits = require('inherits')
4
+ const AbstractIterator = require('abstract-leveldown').AbstractIterator
5
+ const createKeyRange = require('./util/key-range')
6
+ const deserialize = require('./util/deserialize')
7
+ const noop = function () {}
8
+
9
+ module.exports = Iterator
10
+
11
+ function Iterator (db, location, options) {
12
+ AbstractIterator.call(this, db)
13
+
14
+ this._limit = options.limit
15
+ this._count = 0
16
+ this._callback = null
17
+ this._cache = []
18
+ this._completed = false
19
+ this._aborted = false
20
+ this._error = null
21
+ this._transaction = null
22
+
23
+ this._keys = options.keys
24
+ this._values = options.values
25
+ this._keyAsBuffer = options.keyAsBuffer
26
+ this._valueAsBuffer = options.valueAsBuffer
27
+
28
+ if (this._limit === 0) {
29
+ this._completed = true
30
+ return
31
+ }
32
+
33
+ let keyRange
34
+
35
+ try {
36
+ keyRange = createKeyRange(options)
37
+ } catch (e) {
38
+ // The lower key is greater than the upper key.
39
+ // IndexedDB throws an error, but we'll just return 0 results.
40
+ this._completed = true
41
+ return
42
+ }
43
+
44
+ this.createIterator(location, keyRange, options.reverse)
45
+ }
46
+
47
+ inherits(Iterator, AbstractIterator)
48
+
49
+ Iterator.prototype.createIterator = function (location, keyRange, reverse) {
50
+ const transaction = this.db.db.transaction([location], 'readonly')
51
+ const store = transaction.objectStore(location)
52
+ const req = store.openCursor(keyRange, reverse ? 'prev' : 'next')
53
+
54
+ req.onsuccess = (ev) => {
55
+ const cursor = ev.target.result
56
+ if (cursor) this.onItem(cursor)
57
+ }
58
+
59
+ this._transaction = transaction
60
+
61
+ // If an error occurs (on the request), the transaction will abort.
62
+ transaction.onabort = () => {
63
+ this.onAbort(this._transaction.error || new Error('aborted by user'))
64
+ }
65
+
66
+ transaction.oncomplete = () => {
67
+ this.onComplete()
68
+ }
69
+ }
70
+
71
+ Iterator.prototype.onItem = function (cursor) {
72
+ this._cache.push(cursor.key, cursor.value)
73
+
74
+ if (this._limit <= 0 || ++this._count < this._limit) {
75
+ cursor.continue()
76
+ }
77
+
78
+ this.maybeNext()
79
+ }
80
+
81
+ Iterator.prototype.onAbort = function (err) {
82
+ this._aborted = true
83
+ this._error = err
84
+ this.maybeNext()
85
+ }
86
+
87
+ Iterator.prototype.onComplete = function () {
88
+ this._completed = true
89
+ this.maybeNext()
90
+ }
91
+
92
+ Iterator.prototype.maybeNext = function () {
93
+ if (this._callback) {
94
+ this._next(this._callback)
95
+ this._callback = null
96
+ }
97
+ }
98
+
99
+ Iterator.prototype._next = function (callback) {
100
+ if (this._aborted) {
101
+ // The error should be picked up by either next() or end().
102
+ const err = this._error
103
+ this._error = null
104
+ this._nextTick(callback, err)
105
+ } else if (this._cache.length > 0) {
106
+ let key = this._cache.shift()
107
+ let value = this._cache.shift()
108
+
109
+ if (this._keys && key !== undefined) {
110
+ key = this._deserializeKey(key, this._keyAsBuffer)
111
+ } else {
112
+ key = undefined
113
+ }
114
+
115
+ if (this._values && value !== undefined) {
116
+ value = this._deserializeValue(value, this._valueAsBuffer)
117
+ } else {
118
+ value = undefined
119
+ }
120
+
121
+ this._nextTick(callback, null, key, value)
122
+ } else if (this._completed) {
123
+ this._nextTick(callback)
124
+ } else {
125
+ this._callback = callback
126
+ }
127
+ }
128
+
129
+ // Exposed for the v4 to v5 upgrade utility
130
+ Iterator.prototype._deserializeKey = deserialize
131
+ Iterator.prototype._deserializeValue = deserialize
132
+
133
+ Iterator.prototype._end = function (callback) {
134
+ if (this._aborted || this._completed) {
135
+ return this._nextTick(callback, this._error)
136
+ }
137
+
138
+ // Don't advance the cursor anymore, and the transaction will complete
139
+ // on its own in the next tick. This approach is much cleaner than calling
140
+ // transaction.abort() with its unpredictable event order.
141
+ this.onItem = noop
142
+ this.onAbort = callback
143
+ this.onComplete = callback
144
+ }
package/package.json CHANGED
@@ -1,6 +1,56 @@
1
1
  {
2
2
  "name": "@ohos-ports/level-js",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "6.1.0-beta.0",
4
+ "description": "An abstract-leveldown compliant store on top of IndexedDB",
5
+ "author": "max ogden",
6
+ "license": "MIT",
7
+ "main": "index.js",
8
+ "scripts": {
9
+ "test": "standard && hallmark && airtap -p local --coverage test/index.js",
10
+ "test-browsers": "standard && airtap --coverage test/index.js",
11
+ "coverage": "nyc report -r lcovonly",
12
+ "hallmark": "hallmark --fix",
13
+ "dependency-check": "dependency-check --no-dev -i buffer .",
14
+ "prepublishOnly": "npm run dependency-check"
15
+ },
16
+ "files": [
17
+ "index.js",
18
+ "iterator.js",
19
+ "util",
20
+ "CHANGELOG.md",
21
+ "UPGRADING.md",
22
+ "sauce-labs.svg"
23
+ ],
24
+ "dependencies": {
25
+ "abstract-leveldown": "^7.2.0",
26
+ "buffer": "^6.0.3",
27
+ "fake-indexeddb": "^6.2.8",
28
+ "inherits": "^2.0.3",
29
+ "ltgt": "^2.1.2",
30
+ "run-parallel-limit": "^1.1.0"
31
+ },
32
+ "devDependencies": {
33
+ "airtap": "^4.0.1",
34
+ "airtap-playwright": "^1.0.1",
35
+ "airtap-sauce": "^1.1.0",
36
+ "dependency-check": "^4.1.0",
37
+ "hallmark": "^3.0.0",
38
+ "level-concat-iterator": "^3.0.0",
39
+ "nyc": "^15.0.0",
40
+ "standard": "^16.0.3",
41
+ "tape": "^5.0.0",
42
+ "uuid": "^3.3.2"
43
+ },
44
+ "repository": {
45
+ "type": "git",
46
+ "url": "https://github.com/ohos-ports/ohos-ports.git",
47
+ "directory": "ports/level-js/6.1.0"
48
+ },
49
+ "homepage": "https://github.com/Level/level-js",
50
+ "keywords": [
51
+ "level",
52
+ "leveldb",
53
+ "indexeddb",
54
+ "abstract-leveldown"
55
+ ]
56
+ }
package/sauce-labs.svg ADDED
@@ -0,0 +1,81 @@
1
+ <svg
2
+ xmlns="http://www.w3.org/2000/svg"
3
+ width="460"
4
+ height="64"
5
+ version="1.1"
6
+ viewBox="0 0 144.37044 20.09272">
7
+ <defs>
8
+ <style>
9
+ .cls-1{isolation:isolate;}
10
+ .cls-2{opacity:0.15;mix-blend-mode:multiply;}
11
+ .cls-3{fill:#fff;}
12
+ .cls-4{fill:#e1251b;}
13
+ .cls-5{fill:#474c55;}
14
+ </style>
15
+ </defs>
16
+ <title>Sauce Labs</title>
17
+ <g
18
+ transform="translate(-0.87516672,-1.0999856)"
19
+ style="isolation:isolate"
20
+ id="g3807"
21
+ class="cls-1">
22
+ <g
23
+ id="white">
24
+ <path
25
+ style="fill:#e1251b"
26
+ id="path3774"
27
+ 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"
28
+ class="cls-4" />
29
+ <path
30
+ style="fill:#e1251b"
31
+ id="path3776"
32
+ 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"
33
+ class="cls-4" />
34
+ <path
35
+ style="fill:#474c55"
36
+ id="path3778"
37
+ 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"
38
+ class="cls-5" />
39
+ <path
40
+ style="fill:#474c55"
41
+ id="path3780"
42
+ 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"
43
+ class="cls-5" />
44
+ <path
45
+ style="fill:#474c55"
46
+ id="path3782"
47
+ 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"
48
+ class="cls-5" />
49
+ <path
50
+ style="fill:#474c55"
51
+ id="path3784"
52
+ 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"
53
+ class="cls-5" />
54
+ <path
55
+ style="fill:#474c55"
56
+ id="path3786"
57
+ 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"
58
+ class="cls-5" />
59
+ <path
60
+ style="fill:#e1251b"
61
+ id="path3788"
62
+ 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"
63
+ class="cls-4" />
64
+ <path
65
+ style="fill:#e1251b"
66
+ id="path3790"
67
+ 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"
68
+ class="cls-4" />
69
+ <path
70
+ style="fill:#e1251b"
71
+ id="path3792"
72
+ 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"
73
+ class="cls-4" />
74
+ <path
75
+ style="fill:#e1251b"
76
+ id="path3794"
77
+ 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"
78
+ class="cls-4" />
79
+ </g>
80
+ </g>
81
+ </svg>
package/util/clear.js ADDED
@@ -0,0 +1,34 @@
1
+ 'use strict'
2
+
3
+ module.exports = function clear (db, location, keyRange, options, callback) {
4
+ if (options.limit === 0) return db._nextTick(callback)
5
+
6
+ const transaction = db.db.transaction([location], 'readwrite')
7
+ const store = transaction.objectStore(location)
8
+ let count = 0
9
+
10
+ transaction.oncomplete = function () {
11
+ callback()
12
+ }
13
+
14
+ transaction.onabort = function () {
15
+ callback(transaction.error || new Error('aborted by user'))
16
+ }
17
+
18
+ // A key cursor is faster (skips reading values) but not supported by IE
19
+ const method = store.openKeyCursor ? 'openKeyCursor' : 'openCursor'
20
+ const direction = options.reverse ? 'prev' : 'next'
21
+
22
+ store[method](keyRange, direction).onsuccess = function (ev) {
23
+ const cursor = ev.target.result
24
+
25
+ if (cursor) {
26
+ // Wait for a request to complete before continuing, saving CPU.
27
+ store.delete(cursor.key).onsuccess = function () {
28
+ if (options.limit <= 0 || ++count < options.limit) {
29
+ cursor.continue()
30
+ }
31
+ }
32
+ }
33
+ }
34
+ }
@@ -0,0 +1,44 @@
1
+ 'use strict'
2
+
3
+ const Buffer = require('buffer').Buffer
4
+ const ta2str = (function () {
5
+ if (global.TextDecoder) {
6
+ const decoder = new TextDecoder('utf-8')
7
+ return decoder.decode.bind(decoder)
8
+ } else {
9
+ return function ta2str (ta) {
10
+ return ta2buf(ta).toString()
11
+ }
12
+ }
13
+ })()
14
+
15
+ const ab2str = (function () {
16
+ if (global.TextDecoder) {
17
+ const decoder = new TextDecoder('utf-8')
18
+ return decoder.decode.bind(decoder)
19
+ } else {
20
+ return function ab2str (ab) {
21
+ return Buffer.from(ab).toString()
22
+ }
23
+ }
24
+ })()
25
+
26
+ function ta2buf (ta) {
27
+ const buf = Buffer.from(ta.buffer)
28
+
29
+ if (ta.byteLength === ta.buffer.byteLength) {
30
+ return buf
31
+ } else {
32
+ return buf.slice(ta.byteOffset, ta.byteOffset + ta.byteLength)
33
+ }
34
+ }
35
+
36
+ module.exports = function (data, asBuffer) {
37
+ if (data instanceof Uint8Array) {
38
+ return asBuffer ? ta2buf(data) : ta2str(data)
39
+ } else if (data instanceof ArrayBuffer) {
40
+ return asBuffer ? Buffer.from(data) : ab2str(data)
41
+ } else {
42
+ return asBuffer ? Buffer.from(String(data)) : String(data)
43
+ }
44
+ }
@@ -0,0 +1,60 @@
1
+ 'use strict'
2
+
3
+ // Provide an IndexedDB runtime on Node-like platforms (such as the
4
+ // HarmonyOS "openharmony" Node.js build) that ship without an `indexedDB`
5
+ // global and without a `node:indexeddb` builtin. Browsers (including
6
+ // ArkWeb/Chromium) always have a native IndexedDB implementation, which is
7
+ // detected here and left untouched, so browser behavior is unchanged.
8
+ //
9
+ // The polyfill is `fake-indexeddb`: a complete, spec-compliant IndexedDB
10
+ // implementation in pure JavaScript (not a mock/stub). Data is really stored
11
+ // and read back through it, so all observable behavior of a level-js store
12
+ // is preserved on such runtimes.
13
+
14
+ module.exports = function ensureIndexedDB () {
15
+ // Native implementation present (browser, ArkWeb, or a Node build with
16
+ // IndexedDB enabled): do nothing.
17
+ if (typeof globalThis.indexedDB === 'object' && globalThis.indexedDB !== null) return
18
+ if (typeof require !== 'function') return
19
+
20
+ let idb
21
+ try {
22
+ idb = require('fake-indexeddb')
23
+ } catch (err) {
24
+ // No native IndexedDB and the polyfill is not installed: keep the
25
+ // original behavior (level-js will fail like it did before).
26
+ return
27
+ }
28
+
29
+ const factory = idb.indexedDB || idb.fakeIndexedDB || idb
30
+
31
+ // Inject only what is missing; never overwrite existing globals.
32
+ if (typeof globalThis.indexedDB === 'undefined') {
33
+ globalThis.indexedDB = factory
34
+ }
35
+
36
+ if (typeof globalThis.IDBKeyRange === 'undefined' && typeof idb.IDBKeyRange === 'function') {
37
+ globalThis.IDBKeyRange = idb.IDBKeyRange
38
+ }
39
+
40
+ // Some Node builds (including openharmony Node.js v26) don't include the
41
+ // `node:indexeddb` builtin. Route that specifier to the same real
42
+ // implementation so `require('node:indexeddb')` works instead of throwing
43
+ // ERR_UNKNOWN_BUILTIN_MODULE. Everything else falls through to the
44
+ // original loader.
45
+ try {
46
+ require('node:indexeddb')
47
+ } catch (err) {
48
+ if (err && err.code === 'ERR_UNKNOWN_BUILTIN_MODULE') {
49
+ const Module = require('module')
50
+ const originalLoad = Module._load
51
+
52
+ Module._load = function (request, parent, isMain) {
53
+ if (request === 'node:indexeddb') {
54
+ return idb
55
+ }
56
+ return originalLoad.call(this, request, parent, isMain)
57
+ }
58
+ }
59
+ }
60
+ }
@@ -0,0 +1,23 @@
1
+ /* global IDBKeyRange */
2
+
3
+ 'use strict'
4
+
5
+ const ltgt = require('ltgt')
6
+ const NONE = Symbol('none')
7
+
8
+ module.exports = function createKeyRange (options) {
9
+ const lower = ltgt.lowerBound(options, NONE)
10
+ const upper = ltgt.upperBound(options, NONE)
11
+ const lowerOpen = ltgt.lowerBoundExclusive(options, NONE)
12
+ const upperOpen = ltgt.upperBoundExclusive(options, NONE)
13
+
14
+ if (lower !== NONE && upper !== NONE) {
15
+ return IDBKeyRange.bound(lower, upper, lowerOpen, upperOpen)
16
+ } else if (lower !== NONE) {
17
+ return IDBKeyRange.lowerBound(lower, lowerOpen)
18
+ } else if (upper !== NONE) {
19
+ return IDBKeyRange.upperBound(upper, upperOpen)
20
+ } else {
21
+ return null
22
+ }
23
+ }
@@ -0,0 +1,21 @@
1
+ 'use strict'
2
+
3
+ const Buffer = require('buffer').Buffer
4
+ // Returns either a Uint8Array or Buffer (doesn't matter to
5
+ // IndexedDB, because Buffer is a subclass of Uint8Array)
6
+ const str2bin = (function () {
7
+ if (global.TextEncoder) {
8
+ const encoder = new TextEncoder('utf-8')
9
+ return encoder.encode.bind(encoder)
10
+ } else {
11
+ return Buffer.from
12
+ }
13
+ })()
14
+
15
+ module.exports = function (data, asBuffer) {
16
+ if (asBuffer) {
17
+ return Buffer.isBuffer(data) ? data : str2bin(String(data))
18
+ } else {
19
+ return String(data)
20
+ }
21
+ }
@@ -0,0 +1,17 @@
1
+ 'use strict'
2
+
3
+ const Buffer = require('buffer').Buffer
4
+
5
+ exports.test = function (key) {
6
+ return function test (impl) {
7
+ try {
8
+ impl.cmp(key, 0)
9
+ return true
10
+ } catch (err) {
11
+ return false
12
+ }
13
+ }
14
+ }
15
+
16
+ // Detect binary key support (IndexedDB Second Edition)
17
+ exports.bufferKeys = exports.test(Buffer.alloc(0))