New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

bun-sqlite-key-value

Package Overview
Dependencies
Maintainers
0
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bun-sqlite-key-value - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

2

package.json
{
"name": "bun-sqlite-key-value",
"description": "A key-value store with SQLite that uses bun:sqlite and v8 as a fast Json replacement.",
"version": "1.1.2",
"version": "1.1.3",
"author": "Gerold Penz<gerold@gp-softwaretechnik.at>",

@@ -6,0 +6,0 @@ "module": "src/index.ts",

@@ -36,9 +36,11 @@ # Bun SQLite Key Value

`const store = new BunSQLiteKeyValue([filename], [options])`
```typescript
const store = new BunSQLiteKeyValue([filename], [options])
```
- `filename`
- `filename`:
The full path of the SQLite database to open.
Pass an empty string (`""`) or `":memory:"` or undefined for an in-memory database.
- `options`
- `options`:
Defaults to `{readwrite: true, create: true}`.

@@ -52,3 +54,2 @@ If a number, then it's treated as `SQLITE_OPEN_*` constant flags.

import { BunSQLiteKeyValue } from "bun-sqlite-key-value";
import {join} from "path"

@@ -58,3 +59,56 @@ const store = new BunSQLiteKeyValue();

### Write Value
```typescript
store.set<T=any>(key, value)
```
- `T`
can be any data type serializable by v8.
[Supported data types](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#supported_types).
- `key`:
The key must be a string.
- `value`:
The value can be any object that can be serialized with
[v8](https://github.com/nodejs/node/blob/main/doc/api/v8.md#serialization-api).
This means that not only simple data types such as JSON are possible,
but also more complex types such as sets or maps.
Here you will find a list of
[supported data types](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#supported_types).
#### Example
```typescript
import { BunSQLiteKeyValue } from "bun-sqlite-key-value";
const store = new BunSQLiteKeyValue();
store.set<string>("my-key", "my-value")
```
### Read Value
```typescript
store.get<T=any>(key)
```
- `T`
can be any data type serializable by v8.
[Supported data types](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#supported_types).
- `key`:
The key must be a string.
#### Example
```typescript
import { BunSQLiteKeyValue } from "bun-sqlite-key-value";
const store = new BunSQLiteKeyValue();
store.set<string>("my-key", "my-value")
console.log(store.get<string>("my-key")) // --> "my-value"
```
import { Database, Statement } from "bun:sqlite"
import { serialize, deserialize } from "v8"
import { serialize, deserialize } from "node:v8"

@@ -15,3 +15,3 @@

export class BunSqliteKeyValue {
export class BunSqliteKeyValue implements Object{

@@ -84,2 +84,8 @@ db: Database

// Getter for getCount()
get length() {
return this.getCount()
}
// @param ttlMs: Time to live in milliseconds

@@ -86,0 +92,0 @@ setValue<T = any>(key: string, value: T, ttlMs?: number) {

@@ -35,2 +35,4 @@ import { beforeAll, afterAll, expect, test } from "bun:test"

expect(store.length).toEqual(6)
store.db.close()

@@ -37,0 +39,0 @@ })

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