signaleries
TypeScript icon, indicating that this package has built-in type declarations

1.0.11 • Public • Published

Build Status Codacy Badge Codacy Badge

Signal salt

adding salt before node process exit

Dependencies

Node.js version >= 7.0.*

Installation

npm i --save signaleries

Usage

const Signaler = require('signaleries');

const exit = new Signaler();
exit.before([function(){
  // logic code
  process.exit(0); // exit with the success code
}]);
// also: exit.before(fn1, context); context default: null
//       exit.before(fn2, context);

exit.SIGTERM(); // start to listen the signal of sigterm
// also work if the lowerEventName specified `true` value
// exit.sigterm(); 

exit.emit('SIGTERM'/* sigterm */); // Trigger event 

Also see: Examples

Methods of signaleries

  • .before([fn1, fn2], context) - only accept function or function of Array
  • .remove(name | index) - remove one with the hook you added
  • .names() - show you all names of hook you added

The signals that can be listened

Defaults
  • SIGABRT
  • SIGALRM
  • SIGHUP
  • SIGINT
  • SIGTERM
Non-win32
  • SIGVTALRM
  • SIGXCPU
  • SIGXFSZ
  • SIGUSR2
  • SIGTRAP
  • SIGSYS
  • SIGQUIT
  • SIGIOT
Linux
  • SIGIO
  • SIGPOLL
  • SIGPWR
  • SIGSTKFLT
  • SIGUNUSED

LICENCE

MIT License

Copyright (c) 2019 Danielsss

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Package Sidebar

Install

npm i signaleries

Weekly Downloads

1

Version

1.0.11

License

MIT

Unpacked Size

20.9 kB

Total Files

15

Last publish

Collaborators

  • danielsssss