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.3.12 to 1.3.13

jsr.json

5

package.json
{
"name": "bun-sqlite-key-value",
"version": "1.3.12",
"version": "1.3.13",
"author": "Gerold Penz<gerold@gp-softwaretechnik.at>",

@@ -46,5 +46,6 @@ "repository": {

"prepublishOnly": "bun run test && bun run increment_package_version",
"npm:publish": "npm publish --access public"
"npm:publish": "npm publish --access public",
"jsr:publish": "bunx jsr publish"
},
"type": "module"
}

24

README.md

@@ -56,3 +56,3 @@ # Bun SQLite Key Value

The full path of the SQLite database to open.
Pass an empty string (`""`) or `":memory:"` or undefined for an in-memory database.
Pass an empty string (`""`) or `":memory:"` or `undefined` for an in-memory database.

@@ -409,3 +409,23 @@ ### options (optional)

## Read Keys
```typescript
getKeys(): string[]
```
Returns the unexpired keys as array.
### Example
```typescript
import { BunSqliteKeyValue } from "bun-sqlite-key-value"
const store = new BunSqliteKeyValue()
store.getKeys() --> ["key1", "key2"]
```
## All Methods

@@ -474,5 +494,5 @@

- `has(key: string)` --> Boolean
- [ ] `getKeys()` --> Array with all Keys
- `getKeys()` --> Array with all Keys
- [ ] `getKeys(startsWith: string)` --> Array
- [ ] `getKeys(keys: string[])` --> Array

@@ -30,2 +30,3 @@ import { Database, type Statement } from "bun:sqlite"

const MIN_UTF8_CHAR: string = String.fromCodePoint(1)

@@ -49,3 +50,3 @@ const MAX_UTF8_CHAR: string = String.fromCodePoint(1_114_111)

private getKeyStatement: Statement<Omit<Record, "value">>
// private getAllKeysStatement: Statement<Omit<Record, "value">>
private getAllKeysStatement: Statement<{key: string}>
// private getKeysStartsWithStatement: Statement<Omit<Record, "value">>

@@ -90,3 +91,3 @@

this.getKeyStatement = this.db.query("SELECT key, expires FROM items WHERE key = $key")
// this.getAllKeysStatement = this.db.query("SELECT key, expires FROM items")
this.getAllKeysStatement = this.db.query("SELECT key FROM items WHERE expires IS NULL OR expires > $now")
// this.getKeysStartsWithStatement = this.db.query("SELECT key, expires FROM items WHERE key LIKE $startsWith")

@@ -299,2 +300,10 @@

// Returns all unexpired keys as an Array
getKeys(): string[] | undefined {
const records = this.getAllKeysStatement.all({now: Date.now()})
if (!records?.length) return
return records.map((record) => record.key)
}
}

@@ -345,1 +345,15 @@ import { expect, test } from "bun:test"

})
test("Get keys", async () => {
const store: BunSqliteKeyValue = new BunSqliteKeyValue()
store.set<string>(KEY_1, STRING_VALUE_1)
store.set<string>(KEY_2, STRING_VALUE_2, 50)
// All keys
expect(store.getKeys()).toHaveLength(2)
await Bun.sleep(100)
expect(store.getKeys()).toEqual([KEY_1])
})
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