Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@miniflare/kv

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@miniflare/kv - npm Package Compare versions

Comparing version 2.0.0-rc.3 to 2.0.0-rc.4

100

dist/src/index.js

@@ -0,3 +1,24 @@

var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
var __export = (target, all) => {
__markAsModule(target);
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __reExport = (target, module2, desc) => {
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
for (let key of __getOwnPropNames(module2))
if (!__hasOwnProp.call(target, key) && key !== "default")
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
}
return target;
};
var __toModule = (module2) => {
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
};
var __decorateClass = (decorators, target, key, kind) => {

@@ -13,14 +34,13 @@ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;

// packages/kv/src/index.ts
__export(exports, {
KVNamespace: () => KVNamespace,
KVPlugin: () => KVPlugin
});
// packages/kv/src/namespace.ts
import { arrayBuffer } from "stream/consumers";
import { ReadableStream } from "stream/web";
import { TextDecoder, TextEncoder } from "util";
import {
defaultClock,
millisToSeconds,
viewToArray,
viewToBuffer,
waitForOpenInputGate,
waitForOpenOutputGate
} from "@miniflare/shared";
var import_consumers = __toModule(require("stream/consumers"));
var import_web = __toModule(require("stream/web"));
var import_util = __toModule(require("util"));
var import_shared = __toModule(require("@miniflare/shared"));
var MIN_CACHE_TTL = 60;

@@ -32,4 +52,4 @@ var MAX_LIST_KEYS = 1e3;

var keyTypeError = " on 'KvNamespace': parameter 1 is not of type 'string'.";
var encoder = new TextEncoder();
var decoder = new TextDecoder();
var encoder = new import_util.TextEncoder();
var decoder = new import_util.TextDecoder();
var getValueTypes = new Set(["text", "json", "arrayBuffer", "stream"]);

@@ -76,10 +96,10 @@ function throwKVError(method, status, message) {

case "arrayBuffer":
return viewToBuffer(stored);
return (0, import_shared.viewToBuffer)(stored);
case "json":
return JSON.parse(decoder.decode(stored));
case "stream":
return new ReadableStream({
return new import_web.ReadableStream({
type: "bytes",
async pull(controller) {
await waitForOpenInputGate();
await (0, import_shared.waitForOpenInputGate)();
controller.enqueue(stored);

@@ -94,3 +114,3 @@ controller.close();

#clock;
constructor(storage, clock = defaultClock) {
constructor(storage, clock = import_shared.defaultClock) {
this.#storage = storage;

@@ -106,3 +126,3 @@ this.#clock = clock;

const stored = await this.#storage.get(key, true);
await waitForOpenInputGate();
await (0, import_shared.waitForOpenInputGate)();
if (stored === void 0)

@@ -119,3 +139,3 @@ return null;

const storedValue = await this.#storage.get(key);
await waitForOpenInputGate();
await (0, import_shared.waitForOpenInputGate)();
if (storedValue === void 0)

@@ -134,12 +154,12 @@ return { value: null, metadata: null };

stored = encoder.encode(value);
} else if (value instanceof ReadableStream) {
stored = new Uint8Array(await arrayBuffer(value));
} else if (value instanceof import_web.ReadableStream) {
stored = new Uint8Array(await (0, import_consumers.arrayBuffer)(value));
} else if (value instanceof ArrayBuffer) {
stored = new Uint8Array(value);
} else if (ArrayBuffer.isView(value)) {
stored = viewToArray(value);
stored = (0, import_shared.viewToArray)(value);
} else {
throw new TypeError("KV put() accepts only strings, ArrayBuffers, ArrayBufferViews, and ReadableStreams as values.");
}
const now = millisToSeconds(this.#clock());
const now = (0, import_shared.millisToSeconds)(this.#clock());
let expiration = normaliseInt(options.expiration);

@@ -170,3 +190,3 @@ const expirationTtl = normaliseInt(options.expirationTtl);

}
await waitForOpenOutputGate();
await (0, import_shared.waitForOpenOutputGate)();
await this.#storage.put(key, {

@@ -177,3 +197,3 @@ value: stored,

});
await waitForOpenInputGate();
await (0, import_shared.waitForOpenInputGate)();
}

@@ -185,5 +205,5 @@ async delete(key) {

validateKey("DELETE", key);
await waitForOpenOutputGate();
await (0, import_shared.waitForOpenOutputGate)();
await this.#storage.delete(key);
await waitForOpenInputGate();
await (0, import_shared.waitForOpenInputGate)();
}

@@ -202,3 +222,3 @@ async list({

const res = await this.#storage.list({ prefix, limit, cursor });
await waitForOpenInputGate();
await (0, import_shared.waitForOpenInputGate)();
return {

@@ -213,9 +233,4 @@ keys: res.keys,

// packages/kv/src/plugin.ts
import {
Option,
OptionType,
Plugin,
resolveStoragePersist
} from "@miniflare/shared";
var KVPlugin = class extends Plugin {
var import_shared2 = __toModule(require("@miniflare/shared"));
var KVPlugin = class extends import_shared2.Plugin {
kvNamespaces;

@@ -227,3 +242,3 @@ kvPersist;

this.assignOptions(options);
this.#persist = resolveStoragePersist(ctx.rootPath, this.kvPersist);
this.#persist = (0, import_shared2.resolveStoragePersist)(ctx.rootPath, this.kvPersist);
}

@@ -242,4 +257,4 @@ async getNamespace(storage, namespace) {

__decorateClass([
Option({
type: OptionType.ARRAY,
(0, import_shared2.Option)({
type: import_shared2.OptionType.ARRAY,
name: "kv",

@@ -253,4 +268,4 @@ alias: "k",

__decorateClass([
Option({
type: OptionType.BOOLEAN_STRING,
(0, import_shared2.Option)({
type: import_shared2.OptionType.BOOLEAN_STRING,
description: "Persist KV data (to optional path)",

@@ -261,6 +276,7 @@ logName: "KV Persistence",

], KVPlugin.prototype, "kvPersist", 2);
export {
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
KVNamespace,
KVPlugin
};
});
//# sourceMappingURL=index.js.map
{
"name": "@miniflare/kv",
"version": "2.0.0-rc.3",
"version": "2.0.0-rc.4",
"description": "Workers KV module for Miniflare: a fun, full-featured, fully-local simulator for Cloudflare Workers",

@@ -14,4 +14,3 @@ "keywords": [

"license": "MIT",
"type": "module",
"exports": "./dist/src/index.js",
"main": "./dist/src/index.js",
"types": "./dist/src/index.d.ts",

@@ -40,7 +39,7 @@ "files": [

"dependencies": {
"@miniflare/shared": "2.0.0-rc.3"
"@miniflare/shared": "2.0.0-rc.4"
},
"devDependencies": {
"@miniflare/shared-test": "2.0.0-rc.3"
"@miniflare/shared-test": "2.0.0-rc.4"
}
}

@@ -5,3 +5,3 @@ # `@miniflare/kv`

fun, full-featured, fully-local simulator for Cloudflare Workers. See
[📦 KV](https://miniflare.dev/kv.html) for more details.
[📦 KV](https://v2.miniflare.dev/storage/kv) for more details.

@@ -8,0 +8,0 @@ ## Example

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