Fast and simple key-value pair storage for React Native using LevelDB native binding.
+ new Storage(name
: string, buffer?
: boolean): Storage
The level storage instance. Key must be string | number
and value can either be string
or buffer
.
Default: string
.
Name | Type | Default value | Description |
---|---|---|---|
name |
string | - | The name of the storage |
buffer |
boolean | false | Make values as buffer, instead of string |
Returns: Storage
• get length(): Promise<number>
Returns the number of items in the storage.
Returns: Promise<number>
▸ clear(): Promise<void>
Removes all items in storage.
Returns: Promise<void>
▸ create(name
: string): Storage<string>
Create new instance of storage with string type values.
Name | Type | Description |
---|---|---|
name |
string | The name of storage |
Returns: Storage<string>
▸ create(name
: string, buffer
: true): Storage<Buffer>
Create new instance of storage with Buffer type values.
Name | Type | Description |
---|---|---|
name |
string | The name of storage |
buffer |
true | Set true to make values as buffer |
Returns: Storage<Buffer>
▸ filter(condition
: (value: T, key: string) => boolean, options?
: AbstractIteratorOptions<any>): Promise<T[]>
Iterates over items, returning new array of all items predicate returns truthy for.
Options:
gt
(greater than), gte
(greater than or equal) define the lower bound of the range to be iterated.lt
(less than), lte
(less than or equal) define the higher bound of the range to be iterated.reverse
(boolean, default: false): iterate entries in reverse order.limit
(number, default: -1): limit the number of entries collected by this iterator.Type T
is either string
or buffer
.
Name | Type | Description |
---|---|---|
condition |
(value: T, key: string) => boolean | The function to invoke per iteration |
options? |
AbstractIteratorOptions<any> | The options object |
Returns: Promise<T[]>
▸ forEach(iteratee
: (value: T, key: string) => false | void, options?
: AbstractIteratorOptions<any>): Promise<void>
Iterates over items.
Name | Type | Description |
---|---|---|
iteratee |
(value: T, key: string) => false | void | The function to invoke per iteration |
options? |
AbstractIteratorOptions<any> | The same options with filter |
Returns: Promise<void>
▸ getItem(key
: string | number): Promise<T | null>
Get the value. Either string
or buffer
depending on what you specified.
Will convert key
to string if not string.
Name | Type | Description |
---|---|---|
key |
string | number | Name of the item |
Returns: Promise<T | null>
▸ keys(): Promise<string[]>
Returns an array of all keys.
Returns: Promise<string[]>
▸ removeItem(key
: string | number): Promise<void>
Remove the item in storage.
Will convert key
to string if not string.
Name | Type | Description |
---|---|---|
key |
string | number | Name of the item |
Returns: Promise<void>
▸ setItem(key
: string | number, value
: T): Promise<void>
Store a value. Must be string
or buffer
depending on what you specified.
Will convert key
to string if not string.
Name | Type | Description |
---|---|---|
key |
string | number | Name of the item |
value |
T | Value to store |
Returns: Promise<void>
▸ values(): Promise<T[]>
Returns an array of all values.
Returns: Promise<T[]>