Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hipc

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hipc - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

34

index.js
var http = require('http'),
fs = require('fs'),
defaultOpts = {chmod: "777", autoClose: true};
defaultOpts = { chmod: "777", autoClose: true, autoUnlink: true };
module.exports = function (onconnect) {
var server = {
getOpts: function (opts) {
if (typeof opts == "string") opts = { path: opts };
return Object.assign({}, defaultOpts, opts);
},
unlinkOnExists: function (opts) {
opts = server.getOpts(opts);
if (!opts.autoUnlink) return;
if (!fs.existsSync(opts.path)) return;
return fs.unlinkSync(opts.path);
},
listen: function (opts, cb) {
if(!cb) cb = function () {};
if(typeof opts == "string") opts = {path: opts};
opts = Object.assign({}, defaultOpts, opts);
if(typeof opts.path !== "string") throw "opts.path required";
opts = server.getOpts(opts);
if (!cb) cb = function () {};
if (typeof opts.path !== "string") throw "opts.path required";
server.unlinkOnExists(opts);
server.httpServer.listen(opts.path, function (e) {
if(e) return cb(e);
fs.chmod(opts.path, opts.chmod, function (e) {
if(e) return cb(e);
if(opts.autoClose) server.initAutoClose(opts.onclose);
if (e) return cb(e);
if (opts.autoClose) server.initAutoClose(opts.onclose);
cb();

@@ -22,2 +32,10 @@ });

},
listenPromise: function (opts) {
return new Promise(function(resolve, reject) {
server.listen(opts, function (err) {
if (err) return reject(err);
resolve();
});
});
},
initAutoClose: function (cb) {

@@ -27,3 +45,3 @@ process.stdin.resume();

server.httpServer.close(function (e) {
if(cb) cb();
if (cb) cb();
process.exit();

@@ -30,0 +48,0 @@ });

{
"name": "hipc",
"version": "0.1.1",
"version": "0.2.0",
"description": "http ipc server",

@@ -5,0 +5,0 @@ "main": "index.js",

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