How to use the abortcontroller-polyfill/dist/cjs-ponyfill.abortableFetch function in abortcontroller-polyfill

To help you get started, we’ve selected a few abortcontroller-polyfill examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github elbywan / wretch / test / node / wretch.spec.ts View on Github external
function (url, opts) {
        performance.mark(url + " - begin")
        const { fetch } = abortableFetch(nodeFetch) as any
        return fetch(url, opts).then(_ => {
            performance.mark(url + " - end")
            const measure = () => performance.measure(_.url, url + " - begin", url + " - end")
            performance.clearMarks(url + " - begin")
            if(timeout)
                setTimeout(measure, timeout)
            else
                measure()
            return _
        })
    }
github chainpoint / chainpoint-client-js / lib / utils / network.js View on Github external
* See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * helper functions related to interacting with chainpoint network objects
 * such as nodes and cores
 */

import { resolveTxt } from 'dns'
import { parse } from 'url'
import { promisify } from 'util'
import { isInteger, isFunction, isEmpty, slice, map, shuffle, filter, first, isString } from 'lodash'
import { isURL, isIP } from 'validator'
const { AbortController, abortableFetch } = require('abortcontroller-polyfill/dist/cjs-ponyfill')
const { fetch } = abortableFetch(require('node-fetch'))

import getConfig from '../config'
import { DNS_CORE_DISCOVERY_ADDR } from '../constants'
import { testArrayArg } from './helpers'

let config = getConfig()

/**
 * Check if valid Core URI
 *
 * @param {string} coreURI - The Core URI to test for validity
 * @returns {bool} true if coreURI is a valid Core URI, otherwise false
 */
export function isValidCoreURI(coreURI) {
  if (isEmpty(coreURI) || !isString(coreURI)) return false

abortcontroller-polyfill

Polyfill/ponyfill for the AbortController DOM API + optional patching of fetch (stub that calls catch, doesn't actually abort request).

MIT
Latest version published 12 days ago

Package Health Score

85 / 100
Full package analysis

Similar packages