Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nampdn/elex

Perform election speed check on list of gateways to find the fastest url
https://github.com/nampdn/elex

browser gateway http ipfs javascript node react-native speedtest typescript

Last synced: about 2 months ago
JSON representation

Perform election speed check on list of gateways to find the fastest url

Awesome Lists containing this project

README

        

# elex
Perform election speed check on list of gateways to find the fastest url

[![npm version](https://badge.fury.io/js/elex.svg)](https://badge.fury.io/js/elex) [![Build Status](https://travis-ci.com/nampdn/elex.svg?branch=master)](https://travis-ci.com/nampdn/elex)
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fnampdn%2Felex.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Fnampdn%2Felex?ref=badge_shield)
## Installation

```bash
yarn add elex
```

## Usage

### Elect some (some most fastest):

```javascript
import {electSome} from 'elex'

(async () => {
const urlsToCheck = ['https://google.com', 'https://bing.com', 'https://vgm.tv', 'https://not-found-404.com']
const someFastUrls = await electSome(urlsToCheck, {count: 2, retries: 1}); // ['http://google.com', 'https://vgm.tv']
})()
```

### Elect any (the fastest one):

```javascript
import {electAny} from 'elex'

(async () => {
const urlsToCheck = ['https://google.com', 'https://bing.com', 'https://vgm.tv', 'https://not-found-404.com']
const mostFastUrls = await electAny(urlsToCheck, {prefer: 'https://vgm.tv', retries: 1}); // 'https://vgm.tv'
})()
```

## License
[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fnampdn%2Felex.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fnampdn%2Felex?ref=badge_large)