Socket
Socket
Sign inDemoInstall

@contrast/patcher

Package Overview
Dependencies
Maintainers
14
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@contrast/patcher - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

62

lib/index.d.ts

@@ -16,18 +16,58 @@ /*

// import { Core } from '@contrast/core';
import { Logger } from '@contrast/logger';
// TODO
interface Core {
logger: Logger;
}
interface HookData<T, P extends readonly any[] = any[], R = any> {
hooked(...args: P): R;
orig(...args: P): R;
funcKey: string;
obj: T;
name: string;
args: P;
}
interface ResultHookData<T, P extends readonly any[] = any[], R = any>
extends HookData<T, P, R> {
result: R;
}
interface PatchOptions<T, P extends readonly any[] = any[], R = any> {
name: string;
patchType: string;
pre?(data: HookData<T, P, R>): void;
around?(next: () => void, data: HookData<T, P, R>): void;
post?(data: ResultHookData<T, P, R>): void;
}
export interface Patcher {
patch: (obj: function | class | { [key: string]: any }, prop: string, options: { name: string,
patchType: string, pre?: function, around?: function, post?: function }) => function | class | { [key: string]: any },
resetInstrumentation: () => void,
unpatch: (fn: function, funcName: string, patchType: string) => void,
unwrap: (fn: function) => function
isContrastHooked: (fn: function) => boolean
hookedFunctionToString: (fn: function) => string
hookedFunctions: WeakMap<K<function>, V<{ fn: function }>>
patch<T extends (...args: any[]) => any>(
fn: T,
options: PatchOptions<T, Parameters<T>, ReturnType<T>>,
): T | null;
patch<T, K extends keyof T>(
obj: T,
method: K,
options: T[K] extends (...args: infer P) => infer R
? PatchOptions<T, P, R>
: PatchOptions<T>,
): T | null;
resetInstrumentation(): void;
unpatch<T extends (...args: any[]) => any>(
fn: T,
funcName: string,
patchType: string,
): void;
unwrap<T extends (...args: any[]) => any>(fn: T): T;
isContrastHooked<T extends (...args: any[]) => any>(fn: T): boolean;
hookedFunctionToString<T extends (...args: any[]) => any>(fn: T): string;
hookedFunctions: WeakMap<(...args: any[]) => any, (...args: any[]) => any>;
}
declare function init(core: any): Patcher;
declare function init(core: Core): Patcher;
export default init;

2

package.json
{
"name": "@contrast/patcher",
"version": "1.2.0",
"version": "1.3.0",
"description": "Advanced monkey patching--registers hooks to run in and around functions",

@@ -5,0 +5,0 @@ "license": "SEE LICENSE IN LICENSE",

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