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

find-free-ports

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

find-free-ports - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

isFree.js

2

index.d.ts
export * from "./src/index"
export { default } from "./src/findFreePorts"

@@ -1,2 +0,2 @@

module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(e,t){e.exports=require("net")},function(e,t,r){"use strict";r.r(t),r.d(t,"isFree",(function(){return o})),r.d(t,"default",(function(){return f})),r.d(t,"findFreePorts",(function(){return i}));var n=r(0);function o(e){return new Promise((t,r)=>{const o=n.createConnection(e);o.once("connect",()=>{o.end(),t(!1)}),o.once("error",e=>{o.destroy(),"ECONNREFUSED"===e.code?t(!0):r(e)})})}var u=o;async function i(e=1,t={}){var r,n,o;const i=null!==(r=t.startPort)&&void 0!==r?r:1025,f=null!==(n=t.endPort)&&void 0!==n?n:65535,l=Math.min(e,null!==(o=t.jobCount)&&void 0!==o?o:10);if(e>f-i)throw new Error("Could not find free ports: the range of allowed ports is not large enough for the requested amount of ports to find.");const a=Math.ceil((f-i)/l),c=[],d=[];for(let e=0;e<l;e++)d.push(s(i+a*e,Math.min(f,i+a*(e+1))));if(await Promise.all(d),c.length<e)throw new Error("Could not find free ports: there were not enough ports available.");return c;async function s(t,r){for(let n=t;n<r&&!(c.length>=e);n++)if(await u(n)){if(c.length>=e)break;c.push(n)}}}var f=i}]).default;
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=2)}([function(e,t){e.exports=require("net")},function(e,t,r){"use strict";r.r(t),r.d(t,"isFree",(function(){return o}));var n=r(0);function o(e){return new Promise((t,r)=>{const o=n.createConnection(e);o.once("connect",()=>{o.end(),t(!1)}),o.once("error",e=>{o.destroy(),"ECONNREFUSED"===e.code?t(!0):r(e)})})}t.default=o},function(e,t,r){"use strict";r.r(t),r.d(t,"findFreePorts",(function(){return o}));var n=r(1);async function o(e=1,t={}){var r,o,u;const i=null!==(r=t.startPort)&&void 0!==r?r:1025,f=null!==(o=t.endPort)&&void 0!==o?o:65535,l=Math.min(e,null!==(u=t.jobCount)&&void 0!==u?u:10);if(e>f-i)throw new Error("Could not find free ports: the range of allowed ports is not large enough for the requested amount of ports to find.");const a=Math.ceil((f-i)/l),c=[],d=[];for(let e=0;e<l;e++)d.push(s(i+a*e,Math.min(f,i+a*(e+1))));if(await Promise.all(d),c.length<e)throw new Error("Could not find free ports: there were not enough ports available.");return c;async function s(t,r){for(let o=t;o<r&&!(c.length>=e);o++)if(await Object(n.default)(o)){if(c.length>=e)break;c.push(o)}}}}]).default;
//# sourceMappingURL=index.js.map
{
"name": "find-free-ports",
"version": "2.0.1",
"version": "2.0.2",
"description": "Find multiple free ports on localhost",

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

export { isFree } from "./isFree"
export { default, findFreePorts } from "./findFreePorts"
export * from "./findFreePorts"

Sorry, the diff of this file is not supported yet

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