🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

bare-signals

Package Overview
Dependencies
Maintainers
2
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bare-signals - npm Package Compare versions

Comparing version

to
4.0.0

37

index.js

@@ -7,4 +7,6 @@ /* global Bare */

const Signal = module.exports = exports = class Signal extends EventEmitter {
constructor (signum) {
const signals = os.constants.signals
module.exports = exports = class Signal extends EventEmitter {
constructor(signum) {
super()

@@ -23,11 +25,9 @@

this._closing = null
Signal._signals.add(this)
}
_onsignal () {
_onsignal() {
this.emit('signal', this._signum)
}
_onclose () {
_onclose() {
this._handle = null

@@ -38,7 +38,7 @@

start () {
start() {
binding.start(this._handle, this._signum)
}
stop () {
stop() {
if (this._closing) return

@@ -48,11 +48,11 @@ binding.stop(this._handle)

ref () {
ref() {
binding.ref(this._handle)
}
unref () {
unref() {
binding.unref(this._handle)
}
close () {
close() {
if (this._closing) return this._closing

@@ -63,10 +63,6 @@ this._closing = EventEmitter.once(this, 'close')

Signal._signals.delete(this)
return this._closing
}
static _signals = new Set()
static send (signum, pid = os.pid()) {
static send(signum, pid = os.pid()) {
os.kill(pid, signum)

@@ -78,10 +74,3 @@ }

const signals = exports.constants = os.constants.signals
exports.constants = signals
exports.errors = errors
Bare
.on('exit', () => {
for (const signal of Signal._signals) {
signal.close()
}
})

@@ -5,3 +5,3 @@ const EventEmitter = require('bare-events')

module.exports = class SignalEmitter extends EventEmitter {
constructor () {
constructor() {
super()

@@ -12,8 +12,9 @@

this
.on('newListener', this._onnewlistener)
.on('removeListener', this._onremovelistener)
this.on('newListener', this._onnewlistener).on(
'removeListener',
this._onremovelistener
)
}
ref () {
ref() {
this._unrefed = false

@@ -23,3 +24,3 @@ for (const signal of this._signals.values()) signal.ref()

unref () {
unref() {
this._unrefed = true

@@ -29,3 +30,3 @@ for (const signal of this._signals.values()) signal.unref()

_onnewlistener (name) {
_onnewlistener(name) {
if (name === 'newListener' || name === 'removeListener') return

@@ -36,5 +37,3 @@

signal
.on('signal', this._onsignal.bind(this, name))
.start()
signal.on('signal', this._onsignal.bind(this, name)).start()

@@ -47,3 +46,3 @@ if (this._unrefed) signal.unref()

_onremovelistener (name) {
_onremovelistener(name) {
if (name === 'newListener' || name === 'removeListener') return

@@ -62,5 +61,5 @@

_onsignal (name) {
_onsignal(name) {
this.emit(name)
}
}
module.exports = class SignalError extends Error {
constructor (msg, code, fn = SignalError) {
constructor(msg, code, fn = SignalError) {
super(`${code}: ${msg}`)

@@ -11,9 +11,9 @@ this.code = code

get name () {
get name() {
return 'SignalError'
}
static UNKNOWN_SIGNAL (msg) {
static UNKNOWN_SIGNAL(msg) {
return new SignalError(msg, 'UNKNOWN_SIGNAL', SignalError.UNKNOWN_SIGNAL)
}
}
{
"name": "bare-signals",
"version": "3.0.2",
"version": "4.0.0",
"description": "Native signal handling for JavaScript",

@@ -21,3 +21,3 @@ "exports": {

"scripts": {
"test": "standard && bare test.js"
"test": "prettier . --check && bare test.js"
},

@@ -34,2 +34,5 @@ "repository": {

"homepage": "https://github.com/holepunchto/bare-signals#readme",
"engines": {
"bare": ">=1.7.0"
},
"dependencies": {

@@ -42,4 +45,5 @@ "bare-events": "^2.0.0",

"cmake-bare": "^1.1.6",
"standard": "^17.0.0"
"prettier": "^3.4.1",
"prettier-config-standard": "^7.0.0"
}
}

@@ -11,3 +11,3 @@ # bare-signals

``` js
```js
const Signal = require('bare-signals')

@@ -17,5 +17,3 @@

sigint
.on('signal', () => console.log('SIGINT caught'))
.start()
sigint.on('signal', () => console.log('SIGINT caught')).start()
```

@@ -22,0 +20,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet