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

control-c

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

control-c

Control-C (SIGINT) handler supports single, double, triple, quadruple control-c and so on

  • 0.0.9
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6
decreased by-53.85%
Maintainers
1
Weekly downloads
 
Created
Source

control-c - npm

ControlC is simple utility, handles SIGINT or Control-C.
Also suppot single control-c, double control-c, triple control-c and so on.

For example, print current status on single control-c,
reset or re-initialize on double control-c,
clean up and exit on triple control-c,
ignore quadruple or more control-c, and so on.

Japanese version/■日本語版はこちら■

control-c.png

INSTALL:

$ npm install control-c

USAGE:

var ControlC = require('control-c');

method: ControlC.new(handlers...)

Add new handlers to handle SIGINT (Control-C).

Format

var c1 = new ControlC(
  function singleControlC() { console.log('single ctrl-c'); },
  function doubleControlC() { console.log('double ctrl-c'); },
  function tripleControlC() { console.log('triple ctrl-c'); this.remove(); },
  function ignoreControlC() {});

// or
var c2 = ControlC(
  function singleControlC() { console.log('single ctrl-c'); },
  function doubleControlC() { console.log('double ctrl-c'); },
  function tripleControlC() { console.log('triple ctrl-c'); this.remove(); },
  function ignoreControlC() {});

// or
var c3 = ControlC.new(
  function singleControlC() { console.log('single ctrl-c'); },
  function doubleControlC() { console.log('double ctrl-c'); },
  function tripleControlC() { console.log('triple ctrl-c'); this.remove(); },
  function ignoreControlC() {});

Parameters

  • handlers...: SIGINT handler functions, required

Returns

ControlC instance.

method: this.remove() and this.add()

Remove and add to hande SIGINT.

Format

var c1 = new ControlC(function () {},
  function () { this.remove(); });
c1.remove();
c1.add();

property: ControlC.interval

Control-C timeout interval. milliseconds.

Format

ControlC.interval = 400;
console.log(ControlC.interval);

Parameters

  • interval: Control-C timeout interval, between 200 and 2000 msec, default 400 msec

EXAMPLE:

'use strict';

var ControlC = require('control-c');

var singleCount = 0;
var doubleCount = 0;

ControlC(
  function singleControlC() { console.log('Single:', ++singleCount); },
  function doubleControlC() { console.log('Double:', ++doubleCount); },
  function tripleControlC() { console.log('Reset'); singleCount = doubleCount = 0; },
  function quadrupleControlC() { console.log('Exit'); process.nextTick(process.exit); },
  function ignoreControlC() {});

console.log('press control-c in 30 seconds.');
setTimeout(function () {}, 30000);

LICENSE:

MIT

Keywords

FAQs

Package last updated on 04 Jul 2015

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