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

sync-rpc

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sync-rpc - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

12

lib/find-port.js

@@ -5,6 +5,8 @@ 'use strict';

getPort().then(port => process.stdout.write('' + port)).catch(err =>
setTimeout(() => {
throw err;
}, 0)
);
getPort()
.then(port => process.stdout.write('' + port))
.catch(err =>
setTimeout(() => {
throw err;
}, 0)
);

@@ -9,3 +9,13 @@ 'use strict';

const host = '127.0.0.1';
const NC_PATH = require.resolve('./nc');
function nodeNetCatSrc(port, input) {
return (
"var c=require('net').connect(" +
port +
",'127.0.0.1',()=>{c.end(" +
JSON.stringify(input)
.replace(/\u2028/g, '\\u2028')
.replace(/\u2029/g, '\\u2029') +
').pipe(process.stdout)});'
);
}

@@ -63,6 +73,14 @@ const FUNCTION_PRIORITY = [nativeNC, nodeNC];

let response = null;
while (response !== 'pong') {
let err = null;
let timeout = Date.now() + 1000;
while (response !== 'pong' && Date.now() < timeout) {
const result = nodeNC(port, 'ping\r\n');
response = result.stdout && result.stdout.toString();
err = result.stderr && result.stderr.toString();
}
if (response !== 'pong') {
throw new Error(
'Timed out waiting for ping to return pong:\n\n' + err + '\n' + response
);
}
}

@@ -75,3 +93,3 @@

function nodeNC(port, input) {
return spawnSync(process.execPath, [NC_PATH, host, port], {input: input});
return spawnSync(process.execPath, ['-e', nodeNetCatSrc(port, input)]);
}

@@ -78,0 +96,0 @@

{
"name": "sync-rpc",
"version": "1.1.1",
"version": "1.2.0",
"main": "lib/index.js",

@@ -21,4 +21,4 @@ "description": "Run asynchronous commands synchronously by putting them in a separate process",

"precommit": "lint-staged",
"prettier": "prettier --single-quote --trailing-comma es5 --no-bracket-spacing --write \"lib/**/*.js\"",
"prettier:check": "prettier --single-quote --trailing-comma es5 --no-bracket-spacing --list-different \"lib/**/*.js\"",
"prettier": "prettier --write \"lib/**/*.js\"",
"prettier:check": "prettier--list-different \"lib/**/*.js\"",
"test": "jest --coverage",

@@ -29,3 +29,3 @@ "watch": "jest --coverage --watch"

"*.js": [
"prettier --single-quote --trailing-comma es5 --no-bracket-spacing --write",
"prettier --write",
"git add"

@@ -32,0 +32,0 @@ ]

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