safesocket

1.0.0 • Public • Published

safesocket

Wraps socket.io event handlers to prevent crashes from certain malicious inputs.

Usage

The first parameter passed to safesocket is the expected number of (non-function) arguments. The second parameter is the handler function to wrap. This function will always be called with exactly expected + 1 arguments, and the last argument will always be a Function.

var safesocket = require('safesocket');

socket.on('ping', safesocket(2, function (name, location, callback) {
    console.log('Pinged from ' + name + '/' + location);
    callback('pong');
}));

License

The MIT License (MIT)

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    2
  • 0.1.1
    0
  • 0.1.0
    0

Package Sidebar

Install

npm i safesocket

Weekly Downloads

2

Version

1.0.0

License

MIT

Last publish

Collaborators

  • majiir