npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

extra-request

v9.0.1

Published

Utilities for Request

Downloads

233

Readme

extra-request

Utilities for Request.

Install

npm install --save extra-request
# or
yarn add extra-request

Usage

import { post } from 'extra-request'
import { url, json } from 'extra-request/transformers'

const req = post(
  url('http://example.com')
, json({ hello: 'world' })
)
const res = await fetch(req)

API

interface IRequestOptions {
  url?: URL
  headers?: Headers
  payload?:
  | BodyInit // WHATWG
  | NodeJS.ReadableStream // node-fetch
  signal?: AbortSignal
  keepalive?: boolean
  redirect?: RequestRedirect
}

type IRequestOptionsTransformer = (options: IRequestOptions) => RequestOptions

get

function get(...transformers: Array<IRequestOptionsTransformer | Falsy>): Request

head

function head(...transformers: Array<IRequestOptionsTransformer | Falsy>: Request

post

function post(...transformers: Array<IRequestOptionsTransformer | Falsy>): Request

put

function put(...transformers: Array<IRequestOptionsTransformer | Falsy>): Request

patch

function patch(...transformers: Array<IRequestOptionsTransformer | Falsy>): Request

del

function del(...transformers: Array<IRequestOptionsTrransformer | Falsy>): Request

pipeRequestOptionsTransformers

function pipeRequestOptionsTransformers(
  ...transformers: Array<IRequestOptionsTransformer | Falsy>
): IRequestOptions

Transformers

url

function url(...urls: NonEmptyArray<string | URL>): IRequestOptionsTransformer

text

function text(payload: string): IRequestOptionsTransformer

json

function json<T extends JSONValue | JSONSerializable<any>>(
  payload: T
): IRequestOptionsTransformer

csv

function csv<T extends object>(payload: T[]): IRequestOptionsTransformer

signal

function signal(signal: AbortSignal): IRequestOptionsTransformer

header

function header(name: string, value: string): IRequestOptionsTransformer

appendHeader

function appendHeader(name: string, value: string): IRequestOptionsTransformer

headers

function headers<T extends Record<string, string>>(
  headers: T
): IRequestOptionsTransformer

host

function host(host: string): IRequestOptionsTransformer

port

function port(port: number): IRequestOptionsTransformer

pathname

function pathname(pathname: string): IRequestOptionsTransformer

appendPathname

function appendPathname(pathname: string): IRequestOptionsTransformer

search

function search(search: string): IRequestOptionsTransformer

searchParam

function searchParam(
  name: string
, value: string | number
): IRequestOptionsTransformer

appendSearchParam

function appendSearchParam(
  name: string
, value: string | number
): IRequestOptionsTransformer

searchParams

function searchParams<T extends Record<string, string | number>>(
  searchParams: T
): IRequestOptionsTransformer

formDataField

function formDataField(
  name: string
, value: string | string[] | Blob
): IRequestOptionsTransformer

basicAuth

function basicAuth(username: string, password: string): IRequestOptionsTransformer

bearerAuth

function bearerAuth(token: string): IRequestOptionsTransformer

keepalive

function keepalive(val: boolean = true): IRequestOptionsTransformer

redirect

function redirect(val: RequestRedirect): IRequestOptionsTransformer

body

function body(val: BodyInit | NodeJS.ReadableStream): IRequestOptionsTransformer