Socket
Socket
Sign inDemoInstall

interface-store

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

interface-store - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

src/index.ts

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

## [1.0.2](https://github.com/ipfs/js-ipfs-interfaces/compare/interface-store@1.0.1...interface-store@1.0.2) (2021-09-02)
### Bug Fixes
* make tests more stable ([#38](https://github.com/ipfs/js-ipfs-interfaces/issues/38)) ([595de43](https://github.com/ipfs/js-ipfs-interfaces/commit/595de438cbb5bda7444bdd8c4ce561215855d190))
## [1.0.1](https://github.com/ipfs/js-ipfs-interfaces/compare/interface-store@1.0.0...interface-store@1.0.1) (2021-08-20)

@@ -8,0 +19,0 @@

337

dist/src/index.d.ts

@@ -1,10 +0,7 @@

export type AwaitIterable<T> = Iterable<T> | AsyncIterable<T>
export type Await<T> = Promise<T> | T
export declare type AwaitIterable<T> = Iterable<T> | AsyncIterable<T>;
export declare type Await<T> = Promise<T> | T;
export interface Pair<Key, Value> {
key: Key
value: Value
key: Key;
value: Value;
}
/**

@@ -14,185 +11,161 @@ * Options for async operations.

export interface Options {
signal?: AbortSignal
signal?: AbortSignal;
}
export interface Batch<Key, Value> {
put: (key: Key, value: Value) => void
delete: (key: Key) => void
commit: (options?: Options) => Promise<void>
put: (key: Key, value: Value) => void;
delete: (key: Key) => void;
commit: (options?: Options) => Promise<void>;
}
export interface Store<Key, Value> {
open: () => Promise<void>
close: () => Promise<void>
/**
* Store the passed value under the passed key
*
* @example
*
* ```js
* await store.put([{ key: new Key('awesome'), value: new Uint8Array([0, 1, 2, 3]) }])
* ```
*/
put: (key: Key, val: Value, options?: Options) => Promise<void>
/**
* Retrieve the value stored under the given key
*
* @example
* ```js
* const value = await store.get(new Key('awesome'))
* console.log('got content: %s', value.toString('utf8'))
* // => got content: datastore
* ```
*/
get: (key: Key, options?: Options) => Promise<Value>
/**
* Check for the existence of a value for the passed key
*
* @example
* ```js
*const exists = await store.has(new Key('awesome'))
*
*if (exists) {
* console.log('it is there')
*} else {
* console.log('it is not there')
*}
*```
*/
has: (key: Key, options?: Options) => Promise<boolean>
/**
* Remove the record for the passed key
*
* @example
*
* ```js
* await store.delete(new Key('awesome'))
* console.log('deleted awesome content :(')
* ```
*/
delete: (key: Key, options?: Options) => Promise<void>
/**
* Store the given key/value pairs
*
* @example
* ```js
* const source = [{ key: new Key('awesome'), value: new Uint8Array([0, 1, 2, 3]) }]
*
* for await (const { key, value } of store.putMany(source)) {
* console.info(`put content for key ${key}`)
* }
* ```
*/
putMany: (
source: AwaitIterable<Pair<Key, Value>>,
options?: Options
) => AsyncIterable<Pair<Key, Value>>
/**
* Retrieve values for the passed keys
*
* @example
* ```js
* for await (const value of store.getMany([new Key('awesome')])) {
* console.log('got content:', new TextDecoder('utf8').decode(value))
* // => got content: datastore
* }
* ```
*/
getMany: (
source: AwaitIterable<Key>,
options?: Options
) => AsyncIterable<Value>
/**
* Remove values for the passed keys
*
* @example
*
* ```js
* const source = [new Key('awesome')]
*
* for await (const key of store.deleteMany(source)) {
* console.log(`deleted content with key ${key}`)
* }
* ```
*/
deleteMany: (
source: AwaitIterable<Key>,
options?: Options
) => AsyncIterable<Key>
/**
* This will return an object with which you can chain multiple operations together, with them only being executed on calling `commit`.
*
* @example
* ```js
* const b = store.batch()
*
* for (let i = 0; i < 100; i++) {
* b.put(new Key(`hello${i}`), new TextEncoder('utf8').encode(`hello world ${i}`))
* }
*
* await b.commit()
* console.log('put 100 values')
* ```
*/
batch: () => Batch<Key, Value>
/**
* Query the store.
*
* @example
* ```js
* // retrieve __all__ key/value pairs from the store
* let list = []
* for await (const { key, value } of store.query({})) {
* list.push(value)
* }
* console.log('ALL THE VALUES', list)
* ```
*/
query: (query: Query<Key, Value>, options?: Options) => AsyncIterable<Pair<Key, Value>>
/**
* Query the store.
*
* @example
* ```js
* // retrieve __all__ keys from the store
* let list = []
* for await (const key of store.queryKeys({})) {
* list.push(key)
* }
* console.log('ALL THE KEYS', key)
* ```
*/
queryKeys: (query: KeyQuery<Key>, options?: Options) => AsyncIterable<Key>
open: () => Promise<void>;
close: () => Promise<void>;
/**
* Store the passed value under the passed key
*
* @example
*
* ```js
* await store.put([{ key: new Key('awesome'), value: new Uint8Array([0, 1, 2, 3]) }])
* ```
*/
put: (key: Key, val: Value, options?: Options) => Promise<void>;
/**
* Retrieve the value stored under the given key
*
* @example
* ```js
* const value = await store.get(new Key('awesome'))
* console.log('got content: %s', value.toString('utf8'))
* // => got content: datastore
* ```
*/
get: (key: Key, options?: Options) => Promise<Value>;
/**
* Check for the existence of a value for the passed key
*
* @example
* ```js
*const exists = await store.has(new Key('awesome'))
*
*if (exists) {
* console.log('it is there')
*} else {
* console.log('it is not there')
*}
*```
*/
has: (key: Key, options?: Options) => Promise<boolean>;
/**
* Remove the record for the passed key
*
* @example
*
* ```js
* await store.delete(new Key('awesome'))
* console.log('deleted awesome content :(')
* ```
*/
delete: (key: Key, options?: Options) => Promise<void>;
/**
* Store the given key/value pairs
*
* @example
* ```js
* const source = [{ key: new Key('awesome'), value: new Uint8Array([0, 1, 2, 3]) }]
*
* for await (const { key, value } of store.putMany(source)) {
* console.info(`put content for key ${key}`)
* }
* ```
*/
putMany: (source: AwaitIterable<Pair<Key, Value>>, options?: Options) => AsyncIterable<Pair<Key, Value>>;
/**
* Retrieve values for the passed keys
*
* @example
* ```js
* for await (const value of store.getMany([new Key('awesome')])) {
* console.log('got content:', new TextDecoder('utf8').decode(value))
* // => got content: datastore
* }
* ```
*/
getMany: (source: AwaitIterable<Key>, options?: Options) => AsyncIterable<Value>;
/**
* Remove values for the passed keys
*
* @example
*
* ```js
* const source = [new Key('awesome')]
*
* for await (const key of store.deleteMany(source)) {
* console.log(`deleted content with key ${key}`)
* }
* ```
*/
deleteMany: (source: AwaitIterable<Key>, options?: Options) => AsyncIterable<Key>;
/**
* This will return an object with which you can chain multiple operations together, with them only being executed on calling `commit`.
*
* @example
* ```js
* const b = store.batch()
*
* for (let i = 0; i < 100; i++) {
* b.put(new Key(`hello${i}`), new TextEncoder('utf8').encode(`hello world ${i}`))
* }
*
* await b.commit()
* console.log('put 100 values')
* ```
*/
batch: () => Batch<Key, Value>;
/**
* Query the store.
*
* @example
* ```js
* // retrieve __all__ key/value pairs from the store
* let list = []
* for await (const { key, value } of store.query({})) {
* list.push(value)
* }
* console.log('ALL THE VALUES', list)
* ```
*/
query: (query: Query<Key, Value>, options?: Options) => AsyncIterable<Pair<Key, Value>>;
/**
* Query the store.
*
* @example
* ```js
* // retrieve __all__ keys from the store
* let list = []
* for await (const key of store.queryKeys({})) {
* list.push(key)
* }
* console.log('ALL THE KEYS', key)
* ```
*/
queryKeys: (query: KeyQuery<Key>, options?: Options) => AsyncIterable<Key>;
}
export type QueryFilter<Key, Value> = (item: Pair<Key, Value>) => boolean
export type QueryOrder<Key, Value> = (a: Pair<Key, Value>, b: Pair<Key, Value>) => -1 | 0 | 1
export declare type QueryFilter<Key, Value> = (item: Pair<Key, Value>) => boolean;
export declare type QueryOrder<Key, Value> = (a: Pair<Key, Value>, b: Pair<Key, Value>) => -1 | 0 | 1;
export interface Query<Key, Value> {
prefix?: string
filters?: QueryFilter<Key, Value>[]
orders?: QueryOrder<Key, Value>[]
limit?: number
offset?: number
prefix?: string;
filters?: QueryFilter<Key, Value>[];
orders?: QueryOrder<Key, Value>[];
limit?: number;
offset?: number;
}
export type KeyQueryFilter<Key> = (item: Key) => boolean
export type KeyQueryOrder<Key> = (a: Key, b: Key) => -1 | 0 | 1
export declare type KeyQueryFilter<Key> = (item: Key) => boolean;
export declare type KeyQueryOrder<Key> = (a: Key, b: Key) => -1 | 0 | 1;
export interface KeyQuery<Key> {
prefix?: string
filters?: KeyQueryFilter<Key>[]
orders?: KeyQueryOrder<Key>[]
limit?: number
offset?: number
prefix?: string;
filters?: KeyQueryFilter<Key>[];
orders?: KeyQueryOrder<Key>[];
limit?: number;
offset?: number;
}
//# sourceMappingURL=index.d.ts.map
{
"name": "interface-store",
"version": "1.0.1",
"version": "1.0.2",
"description": "A generic interface for storing and retrieving data",

@@ -10,3 +10,4 @@ "main": "src/index.js",

"test": "echo \"No tests configured\"",
"lint": "aegir ts -p check && aegir lint"
"lint": "aegir ts -p check && aegir lint",
"dep-check": "aegir dep-check"
},

@@ -23,3 +24,3 @@ "homepage": "https://github.com/ipfs/js-ipfs-interfaces/tree/master/packages/interface-store#readme",

},
"gitHead": "b4a251475df060773c9e3fd5218c95a92b6008b8"
"gitHead": "f5d59e8f70f72a5900504ef4c4cd7af2b69cb7fb"
}

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