Skip to content
/ elex Public

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

License

Notifications You must be signed in to change notification settings

nampdn/elex

Repository files navigation

elex

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

npm version Build Status FOSSA Status

Installation

yarn add elex

Usage

Elect some (some most fastest):

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):

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