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

apache-js-workers

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apache-js-workers - npm Package Compare versions

Comparing version 0.0.14 to 0.0.16

24

index.js

@@ -45,17 +45,19 @@ "use strict";

this.statusCode = 200;
this.headers = {};
}
Res.prototype.addHeaders = function (headers) {
for (var name in headers) {
var value = headers[name];
worker_threads_1.parentPort.postMessage({ type: 'set-header', name: name, value: value });
}
};
Res.prototype.writeHead = function (statusCode, headers) {
this.addHeaders(headers);
this.statusCode = statusCode;
worker_threads_1.parentPort.postMessage({ type: 'set-status-code', statusCode: statusCode });
};
Res.prototype.write = function (body) {
worker_threads_1.parentPort.postMessage({
type: 'write',
body: body
});
worker_threads_1.parentPort.postMessage({ type: 'write', body: body });
};
Res.prototype.send = function (body) {
worker_threads_1.parentPort.postMessage({
type: 'response',
statusCode: this.statusCode,
headers: this.headers,
body: body
});
worker_threads_1.parentPort.postMessage({ type: 'response', body: body });
};

@@ -62,0 +64,0 @@ return Res;

@@ -29,49 +29,59 @@ import { workerData, parentPort } from 'worker_threads'

export type PostMessage = ResponsePostMessage | WritePostMessage | LogPostMessage
export type PostMessage = ResponseMessage | WriteMessage | LogMessage | SetHeaderMessage | SetStatusCodeMessage
export interface ResponsePostMessage {
export interface ResponseMessage {
type: 'response'
statusCode: number
headers: {
[ keys: string ]: string
}
body: any
}
export interface WritePostMessage {
type: 'write',
export interface WriteMessage {
type: 'write'
body: any
}
export interface LogPostMessage {
type: 'log',
level: LogLevel,
export interface LogMessage {
type: 'log'
level: LogLevel
message: string
}
export interface SetHeaderMessage {
type: 'set-header'
name: string
value: string
}
export interface SetStatusCodeMessage {
type: 'set-status-code'
statusCode: number
}
export class Res {
statusCode: number
headers: {
[ keys: string ]: string
}
constructor() {
this.statusCode = 200
this.headers = {}
}
addHeaders(headers: { [ keys: string ]: string }) {
for (let name in headers) {
const value = headers[name]
parentPort.postMessage({ type: 'set-header', name, value } as SetHeaderMessage)
}
}
writeHead(statusCode: number, headers: { [ keys: string ]: string }) {
this.addHeaders(headers)
this.statusCode = statusCode
parentPort.postMessage({ type: 'set-status-code', statusCode } as SetStatusCodeMessage)
}
write(body: any) {
parentPort.postMessage({
type: 'write',
body
} as WritePostMessage)
parentPort.postMessage({ type: 'write', body } as WriteMessage)
}
send(body?: any) {
parentPort.postMessage({
type: 'response',
statusCode: this.statusCode,
headers: this.headers,
body
} as ResponsePostMessage)
parentPort.postMessage({ type: 'response', body } as ResponseMessage)
}

@@ -87,3 +97,3 @@ }

parentPort.postMessage({ type: 'log', level, message } as LogPostMessage)
parentPort.postMessage({ type: 'log', level, message } as LogMessage)
}
{
"name": "apache-js-workers",
"version": "0.0.14",
"version": "0.0.16",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

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