New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

xpozr

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xpozr

Super simple AOP-like tracing framework for Javascript

  • 0.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

xpozr

Super simple AOP-like tracing module for Javascript.

Supports:

  • Async functions
  • Functions returning Promises
  • Synchronous functions
  • Synchronous functions with callbacks
    • supports callbacks with multiple result arguments (eg: cb(err, result), cb(err, result1, result2) etc.)

Usage

  • A test class:
module.exports = class TestWidget {

    constructor(){}

    getWidget(id) {
        return {
            "id": id,
            "name": "My test widget"
        }
    }
}
  • Create an instance of the object you would like to wrap, eg:
let widget = new TestWidget();
  • Wrap the object, which will add extensive argument and result logging for every function in the object
const Xpozr = require('xpozr');
let xpozr = new Xpozr();

let wrappedWidget = xpozr.trace(widget);
  • You can use the wrapped object exactly as you normally would:
let result = wrappedWidget.getWidget(2);
  • The console output will be:
~~~~~~~~~~~~~~~~~~ START trace 'Object.getWidget' ~~~~~~~~~~~~~~~~~~
- function type: synchronous
- function name: getWidget
- start: 1588751615686
- end: 1588751615686
- duration:  0ms
- args:  [ 2 ]
- result:  { id: 2, name: 'My test widget' }
~~~~~~~~~~~~~~~~~~ END trace 'Object.getWidget' ~~~~~~~~~~~~~~~~~~
  • See the tests (in /test) for more examples

FAQs

Package last updated on 06 May 2020

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

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