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

servie

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

servie - npm Package Compare versions

Comparing version 4.0.10 to 4.0.11

28

dist/signal.d.ts

@@ -0,26 +1,3 @@

import { Emitter } from "@servie/events";
/**
* Event listener type.
*/
declare type EventListener<T, K extends keyof T> = (...args: (T & Record<PropertyKey, any[]>)[K]) => void;
/**
* Wildcard event listener type.
*/
declare type EachEventListener<T> = {
[K in keyof T]: (type: K, ...args: (T & Record<PropertyKey, any[]>)[K]) => void;
}[keyof T];
/**
* Type-safe event emitter.
*/
declare class Events<T> {
all: Array<EachEventListener<T>>;
any: {
[K in keyof T]: Array<EventListener<T, K>>;
};
on<K extends keyof T>(type: K, callback: EventListener<T, K>): void;
off<K extends keyof T>(type: K, callback: EventListener<T, K>): void;
each(callback: EachEventListener<T>): void;
none(callback: EachEventListener<T>): void;
emit<K extends keyof T>(type: K, ...args: (T & Record<PropertyKey, any[]>)[K]): void;
}
/**
* Dictionary of supported signal events.

@@ -40,3 +17,3 @@ */

*/
export declare class Signal extends Events<SignalEvents> {
export declare class Signal extends Emitter<SignalEvents> {
aborted: boolean;

@@ -52,2 +29,1 @@ constructor();

}
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const events_1 = require("@servie/events");
/**
* Type-safe event emitter.
*/
class Events {
constructor() {
this.all = [];
this.any = Object.create(null);
}
on(type, callback) {
(this.any[type] = this.any[type] || []).push(callback);
}
off(type, callback) {
const stack = this.any[type] || [];
stack.splice(stack.indexOf(callback) >>> 0, 1);
}
each(callback) {
this.all.push(callback);
}
none(callback) {
this.all.splice(this.all.indexOf(callback) >>> 0, 1);
}
emit(type, ...args) {
(this.any[type] || []).slice().forEach(fn => fn(...args));
this.all.slice().forEach(fn => fn(type, ...args));
}
}
/**
* Helper to listen to an event once only.
*/
function once(e, type, callback) {
return e.on(type, function once(...args) {
e.off(type, once);
callback(...args);
});
}
/**
* Standard signal used to communicate during `request` processing.
*/
class Signal extends Events {
class Signal extends events_1.Emitter {
constructor() {

@@ -46,3 +12,3 @@ super();

// Listen for the abort signal.
once(this, "abort", () => (this.aborted = true));
this.on("abort", () => (this.aborted = true));
}

@@ -49,0 +15,0 @@ }

3

package.json
{
"name": "servie",
"version": "4.0.10",
"version": "4.0.11",
"description": "Standard HTTP interfaces for HTTP clients and servers in node.js and browsers",

@@ -103,4 +103,5 @@ "main": "dist/index.js",

"dependencies": {
"@servie/events": "^1.0.0",
"byte-length": "^1.0.2"
}
}

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