🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

finis

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

finis

Node.js program finisher - run your last callback with `exit code` and `signal name` as arguments

latest
Source
npmnpm
Version
0.4.5
Version published
Weekly downloads
25
66.67%
Maintainers
1
Weekly downloads
 
Created
Source

FINIS

Finis

Run your callback before node exit, pass exit code and signal name as arguments

INSTALLATION

npm install finis --save

USAGE

finis() installs a callback function which will be run just before the node process exits.

The callback function will be called when:

  • the process exits normally
  • the user presses Ctrl+C
  • an exception is uncaught

EXAMPLE

JavaScript

const finis = require('finis')

finis((code, signal, error) => {
  console.log(`finis(${code}, ${signal}, ${error})`)
})

TypeScript

import finis from 'finis'

finis((code: number, signal: 'exit'|'SIGINT'|'SIGTERM'|'uncaughtException', error?: Error) => {
  console.log(`finis(${code}, ${signal}, ${error})`)
})

You may call finis() multiple times to install multiple callback functions.

CHANGELOG

v0.4 Nov 2017

  • Do not call process.exit by default
  • Add support to SIGTERM
  • Add support to TypeScript

v0.1 Dev 2016

This module is inspired by @jtlapp/node-cleanup, which is borrowed and modified from CanyonCasa's answer to a stackoverflow question. I found the code necessary for all my node projects. See the stackoverflow answer for more examples of use.

MAINTAINER

Huan LI <zixia@zixia.net> (http://linkedin.com/in/zixia)

profile for zixia at Stack Overflow, Q&A for professional and enthusiast programmers
  • Code & Docs © 2016-2017 Huan LI <zixia@zixia.net>
  • Code released under the Apache-2.0 License
  • Docs released under Creative Commons

Keywords

node

FAQs

Package last updated on 18 Oct 2021

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