New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

jsrap

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsrap

A Node.js module to wrap existing library functions with custom code.

latest
Source
npmnpm
Version
2.2.0
Version published
Maintainers
1
Created
Source

JSRap

A Node.js module to wrap existing library functions with custom code.

experimental Downloads/week Build Status Test Coverage Maintainability

Installation

npm i jsrap

Usage

var { PrototypeWrapper } = require("jsrap");
var Target = require("some-class");

PrototypeWrapper(Target, "someMethod", {
  before() {
    console.info("Executed before someMethod");
  },
  after() {
    console.info("Executed after someMethod");
  }
});

Methods

All of the following methods may be passed in the options object.

before(...args: any[]): any[]

The before method is called with all of the arguments of the original function passed in. Your implementation must either return the arguments array, or void.

exceptionHandler(exception: any, ...args: any[]): any

This method is called whenever an exception is thrown by the original method. It's return value is saved as the method result if it's not void.

after(...args: any[]): any

This method is called after the original method has completed. All of the original arguments are passed to it, and it can return void or some other value that will be used as the method result. If void is returned, the previous result value is saved.

filterResults(result: any): any

Allows you to modify the results before returning. Whatever is returned from this function is used as the final result.

Keywords

nodejs

FAQs

Package last updated on 12 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts