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.10.10 to 1.10.11

33

dist/index.d.ts

@@ -72,7 +72,12 @@ import { Database } from "bun:sqlite";

get values(): any[] | undefined;
getItemsObject<T = any>(startsWithOrKeys?: string | string[]): {
getItemsAsObject<T = any>(startsWithOrKeys?: string | string[]): {
[key: string]: T | undefined;
} | undefined;
getItemsMap<T = any>(startsWithOrKeys?: string | string[]): Map<string, T | undefined> | undefined;
getValuesSet<T = any>(startsWithOrKeys?: string | string[]): Set<T> | undefined;
getItemsObject: <T = any>(startsWithOrKeys?: string | string[]) => {
[key: string]: T | undefined;
} | undefined;
getItemsAsMap<T = any>(startsWithOrKeys?: string | string[]): Map<string, T | undefined> | undefined;
getItemsMap: <T = any>(startsWithOrKeys?: string | string[]) => Map<string, T | undefined> | undefined;
getValuesAsSet<T = any>(startsWithOrKeys?: string | string[]): Set<T> | undefined;
getValuesSet: <T = any>(startsWithOrKeys?: string | string[]) => Set<T> | undefined;
has(key: string): boolean;

@@ -158,2 +163,24 @@ exists: (key: string) => boolean;

hDecr(key: string, field: string, decrBy?: number, ttlMs?: number): number;
/**
* Array - Left Push
*
* @param {string} key
* @param {T} values
* @returns {number | undefined}
* New length of the list or `undefined` if the old value in the database is not an array.
*
* Inspired by: https://docs.keydb.dev/docs/commands/#lpush
*/
lPush<T = any>(key: string, ...values: T[]): number | undefined;
/**
* Array - Right Push
*
* @param {string} key
* @param {T} values
* @returns {number | undefined}
* New length of the list or `undefined` if the old value in the database is not an array.
*
* Inspired by: https://docs.keydb.dev/docs/commands/#rpush
*/
rPush<T = any>(key: string, ...values: T[]): number | undefined;
}

@@ -226,3 +226,3 @@ // src/index.ts

}
getItemsObject(startsWithOrKeys) {
getItemsAsObject(startsWithOrKeys) {
const items = this.getItems(startsWithOrKeys);

@@ -233,3 +233,4 @@ if (!items)

}
getItemsMap(startsWithOrKeys) {
getItemsObject = this.getItemsAsObject;
getItemsAsMap(startsWithOrKeys) {
const items = this.getItems(startsWithOrKeys);

@@ -240,3 +241,4 @@ if (!items)

}
getValuesSet(startsWithOrKeys) {
getItemsMap = this.getItemsAsMap;
getValuesAsSet(startsWithOrKeys) {
const values = this.getValues(startsWithOrKeys);

@@ -247,2 +249,3 @@ if (!values)

}
getValuesSet = this.getValuesAsSet;
has(key) {

@@ -513,2 +516,38 @@ const record = this.getKeyStatement.get({ key });

}
lPush(key, ...values) {
return this.db.transaction(() => {
const array = this.get(key) ?? new Array;
let newLength;
try {
values.forEach((value) => {
newLength = array.unshift(value);
});
} catch (error) {
if (error.toString().includes("TypeError")) {
return;
} else {
throw error;
}
}
this.set(key, array);
return newLength;
}).immediate();
}
rPush(key, ...values) {
return this.db.transaction(() => {
const array = this.get(key) ?? new Array;
let newLength;
try {
newLength = array.push(...values);
} catch (error) {
if (error.toString().includes("TypeError")) {
return;
} else {
throw error;
}
}
this.set(key, array);
return newLength;
}).immediate();
}
}

@@ -515,0 +554,0 @@ export {

2

package.json
{
"name": "bun-sqlite-key-value",
"version": "1.10.10",
"version": "1.10.11",
"author": {

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

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

- [`getValues()`](#read-multiple-values)
- `getValuesSet()` --> Set with values
- `getValuesAsSet()` --> Set with values
- Write and Read Items

@@ -40,4 +40,4 @@ - [`setItems()`](#write-multiple-items)

- [`getItems()`](#read-multiple-items)
- `getItemsObject()` --> Object with items
- `getItemsMap()` --> Map with items
- `getItemsAsObject()` --> Object with items
- `getItemsAsMap()` --> Map with items
- [Read and Write Binary Files (Images)](#read-and-write-binary-files-images)

@@ -78,4 +78,7 @@ - Keys

- [`hDelete()`](#hash-map-object---delete-field)
- [`hIncr()`]()
- [`hDecr()`]()
- `hIncr()` --> Increments the value of a field.
- `hDecr()` --> Decrements the value of a field.
- List (Array Object)
- `lPush()` --> Insert values at the begin of the list.
- `rPush()` --> Insert values at the end of the list.
- Extended database topics

@@ -332,3 +335,3 @@ - [Multiple Databases](#multiple-databases)

```typescript
setItems(items: {key: string, value: T, ttlMs?: number}[]) {
setItems(items: {key: string, value: T, ttlMs?: number}[])
```

@@ -335,0 +338,0 @@

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

// Get multiple items as object
getItemsObject<T = any>(startsWithOrKeys?: string | string[]): {[key: string]: T | undefined} | undefined {
getItemsAsObject<T = any>(startsWithOrKeys?: string | string[]): {[key: string]: T | undefined} | undefined {
const items = this.getItems(startsWithOrKeys)

@@ -378,4 +378,8 @@ if (!items) return

// alias for getItemsAsObject()
getItemsObject = this.getItemsAsObject
// Get multiple items as Map()
getItemsMap<T = any>(startsWithOrKeys?: string | string[]): Map<string, T | undefined> | undefined {
getItemsAsMap<T = any>(startsWithOrKeys?: string | string[]): Map<string, T | undefined> | undefined {
const items = this.getItems(startsWithOrKeys)

@@ -387,4 +391,8 @@ if (!items) return

// Alias for getItemsAsMap()
getItemsMap = this.getItemsAsMap
// Get multiple values as Set()
getValuesSet<T = any>(startsWithOrKeys?: string | string[]): Set<T> | undefined {
getValuesAsSet<T = any>(startsWithOrKeys?: string | string[]): Set<T> | undefined {
const values = this.getValues(startsWithOrKeys)

@@ -396,2 +404,6 @@ if (!values) return

// Alias for getValuesAsSet()
getValuesSet = this.getValuesAsSet
// Checks if key exists

@@ -834,2 +846,64 @@ has(key: string): boolean {

/**
* Array - Left Push
*
* @param {string} key
* @param {T} values
* @returns {number | undefined}
* New length of the list or `undefined` if the old value in the database is not an array.
*
* Inspired by: https://docs.keydb.dev/docs/commands/#lpush
*/
lPush<T = any>(key: string, ...values: T[]): number | undefined {
// @ts-ignore (Transaction returns number, not void.)
return this.db.transaction(() => {
const array = this.get<Array<T>>(key) ?? new Array<T>()
let newLength: number | undefined
try {
values.forEach((value) => {
newLength = array.unshift(value)
})
} catch (error: any) {
if (error.toString().includes("TypeError")) {
return
} else {
throw error
}
}
this.set<Array<T>>(key, array)
return newLength
}).immediate()
}
/**
* Array - Right Push
*
* @param {string} key
* @param {T} values
* @returns {number | undefined}
* New length of the list or `undefined` if the old value in the database is not an array.
*
* Inspired by: https://docs.keydb.dev/docs/commands/#rpush
*/
rPush<T = any>(key: string, ...values: T[]): number | undefined {
// @ts-ignore (Transaction returns number, not void.)
return this.db.transaction(() => {
const array = this.get<Array<T>>(key) ?? new Array<T>()
let newLength: number | undefined
try {
newLength = array.push(...values)
} catch (error: any) {
if (error.toString().includes("TypeError")) {
return
} else {
throw error
}
}
this.set<Array<T>>(key, array)
return newLength
}).immediate()
}
// ToDo: lIndex()

@@ -847,6 +921,2 @@ // Inspired by: https://docs.keydb.dev/docs/commands/#lindex

// ToDo: lPush()
// Inspired by: https://docs.keydb.dev/docs/commands/#lpush
// ToDo: lRange()

@@ -872,6 +942,2 @@ // Inspired by: https://docs.keydb.dev/docs/commands/#lrange

// ToDo: rPush()
// Inspired by: https://docs.keydb.dev/docs/commands/#rpush
// ToDo: sAdd()

@@ -878,0 +944,0 @@ // Inspired by: https://docs.keydb.dev/docs/commands/#sadd

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