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

miniflare

Package Overview
Dependencies
Maintainers
1
Versions
452
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

miniflare - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

dist/src/kv/cache.d.ts

10

dist/src/example.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const vm_1 = tslib_1.__importDefault(require("vm"));
const _1 = require(".");
(async () => {
const mf = new _1.Miniflare(new vm_1.default.Script(`
const mf = new _1.Miniflare({
script: `
addEventListener("fetch", (event) => {

@@ -14,2 +13,3 @@ event.respondWith(handleRequest(event.request));

async function handleRequest(request) {
// throw new Error("error");
const value = await TEST_NAMESPACE.get("key");

@@ -24,5 +24,5 @@ return new Response(\`Hello from Miniflare! key="\${value}"\`, {

});
`), {
`,
kvNamespaces: ["TEST_NAMESPACE"],
log: new _1.ConsoleLog(),
log: new _1.ConsoleLog(true),
});

@@ -29,0 +29,0 @@ const ns = await mf.getNamespace("TEST_NAMESPACE");

@@ -24,3 +24,3 @@ /// <reference types="node" />

}
declare type EventListener = (event: any) => void;
declare type EventListener<Event> = (event: Event) => void;
export declare type ResponseWaitUntil<WaitUntil extends any[] = any[]> = Response & {

@@ -30,4 +30,5 @@ waitUntil: () => Promise<WaitUntil>;

export declare class EventsModule extends Module {
private listeners;
addEventListener(type: string, listener: EventListener): void;
_listeners: Record<string, EventListener<any>[]>;
addEventListener(type: "fetch", listener: EventListener<FetchEvent>): void;
addEventListener(type: "scheduled", listener: EventListener<ScheduledEvent>): void;
removeEventListeners(): void;

@@ -34,0 +35,0 @@ buildSandbox(_options: ProcessedOptions): Sandbox;

@@ -38,3 +38,3 @@ "use strict";

super(...arguments);
this.listeners = {};
this._listeners = {};
}

@@ -45,8 +45,8 @@ addEventListener(type, listener) {

}
if (!(type in this.listeners))
this.listeners[type] = [];
this.listeners[type].push(listener);
if (!(type in this._listeners))
this._listeners[type] = [];
this._listeners[type].push(listener);
}
removeEventListeners() {
this.listeners = {};
this._listeners = {};
}

@@ -64,3 +64,3 @@ buildSandbox(_options) {

const waitUntil = async () => (await Promise.all(event._waitUntilPromises));
for (const listener of (_a = this.listeners.fetch) !== null && _a !== void 0 ? _a : []) {
for (const listener of (_a = this._listeners.fetch) !== null && _a !== void 0 ? _a : []) {
try {

@@ -93,3 +93,3 @@ listener(event);

const event = new ScheduledEvent(scheduledTime !== null && scheduledTime !== void 0 ? scheduledTime : Date.now());
for (const listener of (_a = this.listeners.scheduled) !== null && _a !== void 0 ? _a : []) {
for (const listener of (_a = this._listeners.scheduled) !== null && _a !== void 0 ? _a : []) {
listener(event);

@@ -96,0 +96,0 @@ }

{
"name": "miniflare",
"version": "0.1.0",
"version": "0.1.1",
"description": "Fully-local Cloudflare Workers Simulator",

@@ -30,3 +30,3 @@ "keywords": [

"dependencies": {
"@mrbbot/node-fetch": "github:mrbbot/node-fetch",
"@mrbbot/node-fetch": "^4.0.1",
"@peculiar/webcrypto": "^1.1.4",

@@ -33,0 +33,0 @@ "chalk": "^4.1.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