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.8.1 to 1.8.2

1

dist/index.d.ts

@@ -82,2 +82,3 @@ // Generated by dts-bundle-generator v9.5.1

decr(key: string, decrBy?: number, ttlMs?: number): number;
append(key: string, value: string, ttlMs?: number): number;
}

@@ -84,0 +85,0 @@

@@ -320,2 +320,10 @@ // src/index.ts

}
append(key, value, ttlMs) {
const self = this;
return this.db.transaction(() => {
const newValue = String(self.get(key) ?? "") + value;
self.set(key, newValue, ttlMs);
return newValue.length;
})();
}
}

@@ -326,2 +334,2 @@ export {

//# debugId=1F142DC76E9E63B264756E2164756E21
//# debugId=980128A3C0A1689C64756E2164756E21

2

package.json
{
"name": "bun-sqlite-key-value",
"version": "1.8.1",
"version": "1.8.2",
"author": {

@@ -5,0 +5,0 @@ "name": "Gerold Penz",

@@ -730,3 +730,44 @@ # Bun SQLite Key Value

## Append
```typescript
append(key: string, value: string, ttlMs?: number): number
```
If key already exists and is a string, this command appends the
value at the end of the string.
If key does not exist it is created and set as an empty string,
so `append()` will be similar to `set()` in this special case.
Inspired by: https://docs.keydb.dev/docs/commands/#append
Returns the length of the string after the append operation.
### key
The key must be a string.
### value
The string that is appended to the existing string.
### ttlMs (optional)
"Time to live" in milliseconds. After this time,
the item becomes invalid and is deleted from the database
the next time it is accessed or when the application is started.
Set the value to 0 if you want to explicitly deactivate the process.
### Example
```typescript
import { BunSqliteKeyValue } from "bun-sqlite-key-value"
const store = new BunSqliteKeyValue()
store.append("my-key", "Hello!") // --> 6
store.append("my-key", "World!") // --> 12
store.get("my-key") // --> "Hello!World!"
```
## All Functions

@@ -812,7 +853,10 @@

### Calculations
### Math operations
- `incr()` --> Number
- `decr()` --> Number
### String operations
- `append()` --> Number
## SQLite as base for a key value storage

@@ -819,0 +863,0 @@

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

// Inspired by: https://docs.keydb.dev/docs/commands/#incrby
incr(key: string, incrBy: number = 1, ttlMs?: number): number {

@@ -481,2 +482,3 @@ const self = this

// Inspired by: https://docs.keydb.dev/docs/commands/#decrby
decr(key: string, decrBy: number = 1, ttlMs?: number): number {

@@ -486,2 +488,18 @@ return this.incr(key, decrBy * -1, ttlMs)

// If key already exists and is a string, this command appends the value at the end of the string.
// If key does not exist it is created and set as an empty string,
// so APPEND will be similar to `set()` in this special case.
// Returns the length of the string after the append operation.
// Inspired by: https://docs.keydb.dev/docs/commands/#append
append(key: string, value: string, ttlMs?: number): number {
const self = this
return this.db.transaction(() => {
const newValue = String(self.get<string>(key) ?? "") + value
self.set<string>(key, newValue, ttlMs)
return newValue.length
})()
}
}

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