Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

datastore-level

Package Overview
Dependencies
Maintainers
4
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

datastore-level - npm Package Compare versions

Comparing version 9.0.0 to 9.0.1

10

dist/src/index.d.ts

@@ -16,7 +16,9 @@ /**

* @param {string | LevelDb} path
* @param {import('level').DatabaseOptions<string, Uint8Array>} [opts]
* @param {import('level').DatabaseOptions<string, Uint8Array> & import('level').OpenOptions} [opts]
*/
constructor(path: string | import("abstract-level/types/abstract-level").AbstractLevel<any, string, Uint8Array>, opts?: import("level").DatabaseOptions<string, Uint8Array> | undefined);
constructor(path: string | import("abstract-level/types/abstract-level").AbstractLevel<any, string, Uint8Array>, opts?: (import("classic-level").DatabaseOptions<string, Uint8Array> & import("browser-level").DatabaseOptions<string, Uint8Array> & import("classic-level").OpenOptions & import("abstract-level").AbstractOpenOptions) | undefined);
/** @type {LevelDb} */
db: import("abstract-level/types/abstract-level").AbstractLevel<any, string, Uint8Array>;
/** @type {import('level').OpenOptions} */
opts: import('level').OpenOptions;
/**

@@ -61,2 +63,6 @@ * @param {Key} key

}
export type LevelIterator = {
next: (cb: (err: Error, key: string | Uint8Array | null, value: any) => void) => void;
end: (cb: (err: Error) => void) => void;
};
export type Datastore = import('interface-datastore').Datastore;

@@ -63,0 +69,0 @@ export type Pair = import('interface-datastore').Pair;

2

package.json
{
"name": "datastore-level",
"version": "9.0.0",
"version": "9.0.1",
"description": "Datastore implementation with level(up|down) backend",

@@ -5,0 +5,0 @@ "author": "Friedel Ziegelmayer<dignifiedquire@gmail.com>",

@@ -25,3 +25,3 @@ import { Key } from 'interface-datastore'

* @param {string | LevelDb} path
* @param {import('level').DatabaseOptions<string, Uint8Array>} [opts]
* @param {import('level').DatabaseOptions<string, Uint8Array> & import('level').OpenOptions} [opts]
*/

@@ -39,2 +39,9 @@ constructor (path, opts = {}) {

: path
/** @type {import('level').OpenOptions} */
this.opts = {
createIfMissing: true,
compression: false, // same default as go
...opts
}
}

@@ -44,3 +51,3 @@

try {
await this.db.open()
await this.db.open(this.opts)
} catch (/** @type {any} */ err) {

@@ -217,3 +224,15 @@ throw Errors.dbOpenFailedError(err)

return levelIteratorToIterator(this.db.iterator(iteratorOpts))
const iterator = this.db.iterator(iteratorOpts)
if (iterator[Symbol.asyncIterator]) {
return levelIteratorToIterator(iterator)
}
// @ts-expect-error support older level
if (iterator.next != null && iterator.end != null) {
// @ts-expect-error support older level
return oldLevelIteratorToIterator(iterator)
}
throw new Error('Level returned incompatible iterator')
}

@@ -233,1 +252,38 @@ }

}
/**
* @typedef {object} LevelIterator
* @property {(cb: (err: Error, key: string | Uint8Array | null, value: any)=> void)=>void} next
* @property {(cb: (err: Error) => void) => void } end
*/
/**
* @param {LevelIterator} li - Level iterator
* @returns {AsyncIterable<Pair>}
*/
function oldLevelIteratorToIterator (li) {
return {
[Symbol.asyncIterator] () {
return {
next: () => new Promise((resolve, reject) => {
li.next((err, key, value) => {
if (err) return reject(err)
if (key == null) {
return li.end(err => {
if (err) return reject(err)
resolve({ done: true, value: undefined })
})
}
resolve({ done: false, value: { key: new Key(key, false), value } })
})
}),
return: () => new Promise((resolve, reject) => {
li.end(err => {
if (err) return reject(err)
resolve({ done: true, value: undefined })
})
})
}
}
}
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc