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

wait-for-localhost

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wait-for-localhost - npm Package Compare versions

Comparing version 3.3.0 to 4.0.0

67

index.d.ts

@@ -1,50 +0,35 @@

declare namespace waitForLocalhost {
export interface Options {
/**
@default 80
*/
port?: number;
export interface Options {
/**
@default 80
*/
port?: number;
/**
Use a custom path.
For example, `/health` for a health-check endpoint.
/**
Use a custom path.
@default '/'
*/
path?: string;
For example, `/health` for a health-check endpoint.
/**
Use the `GET` HTTP-method instead of `HEAD` to check if the server is running.
@default '/'
*/
path?: string;
@default false
*/
useGet?: boolean;
}
}
declare const waitForLocalhost: {
/**
Wait for localhost to be ready.
Use the `GET` HTTP-method instead of `HEAD` to check if the server is running.
@example
```
import waitForLocalhost = require('wait-for-localhost');
@default false
*/
useGet?: boolean;
}
(async () => {
await waitForLocalhost({port: 8080});
console.log('Server is ready');
})();
```
*/
(options?: waitForLocalhost.Options): Promise<void>;
/**
Wait for localhost to be ready.
// TODO: Remove this for the next major release, refactor the whole definition to:
// declare function waitForLocalhost(
// options?: waitForLocalhost.Options
// ): Promise<void>;
// export = waitForLocalhost;
default: typeof waitForLocalhost;
};
@example
```
import waitForLocalhost from 'wait-for-localhost';
export = waitForLocalhost;
await waitForLocalhost({port: 8080});
console.log('Server is ready');
```
*/
export default function waitForLocalhost(options?: Options): Promise<void>;

@@ -1,16 +0,16 @@

'use strict';
const http = require('http');
import http from 'node:http';
const waitForLocalhost = options => {
options = Object.assign({}, options);
export default function waitForLocalhost({port, path, useGet} = {}) {
return new Promise(resolve => {
const retry = () => setTimeout(main, 200);
const retry = () => {
setTimeout(main, 200);
};
const method = options.useGet ? 'GET' : 'HEAD';
const method = useGet ? 'GET' : 'HEAD';
const main = () => {
const request = http.request({method, port: options.port, path: options.path}, response => {
const request = http.request({method, port, path}, response => {
if (response.statusCode === 200) {
return resolve();
resolve();
return;
}

@@ -27,6 +27,2 @@

});
};
module.exports = waitForLocalhost;
// TODO: Remove this for the next major release
module.exports.default = waitForLocalhost;
}
{
"name": "wait-for-localhost",
"version": "3.3.0",
"version": "4.0.0",
"description": "Wait for localhost to be ready",
"license": "MIT",
"repository": "sindresorhus/wait-for-localhost",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=6"
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},

@@ -32,8 +35,8 @@ "scripts": {

"devDependencies": {
"ava": "^1.4.1",
"create-test-server": "^2.4.0",
"delay": "^4.1.0",
"tsd": "^0.7.2",
"xo": "^0.24.0"
"ava": "^3.15.0",
"create-test-server": "^3.0.1",
"delay": "^5.0.0",
"tsd": "^0.17.0",
"xo": "^0.44.0"
}
}

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

# wait-for-localhost [![Build Status](https://travis-ci.org/sindresorhus/wait-for-localhost.svg?branch=master)](https://travis-ci.org/sindresorhus/wait-for-localhost)
# wait-for-localhost

@@ -7,25 +7,20 @@ > Wait for localhost to be ready

## Install
```
$ npm install --global wait-for-localhost
$ npm install wait-for-localhost
```
## Usage
```js
const waitForLocalhost = require('wait-for-localhost');
import waitForLocalhost from 'wait-for-localhost';
(async () => {
await waitForLocalhost({port: 8080});
console.log('Server is ready');
})();
await waitForLocalhost({port: 8080});
console.log('Server is ready');
```
## API
### waitForLocalHost([options])
### waitForLocalHost(options?)

@@ -36,7 +31,7 @@ Returns a `Promise` that settles when localhost is ready.

Type: `Object`
Type: `object`
##### port
Type: `number`<br>
Type: `number`\
Default: `80`

@@ -46,3 +41,3 @@

Type: `string`<br>
Type: `string`\
Default: `'/'`

@@ -56,3 +51,3 @@

Type: `boolean`<br>
Type: `boolean`\
Default: `false`

@@ -62,3 +57,2 @@

## Related

@@ -68,6 +62,1 @@

- [delay](https://github.com/sindresorhus/delay) - Delay execution for a given amount of seconds
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)

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