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 🙏

© 2025 – Pkg Stats / Ryan Hefner

fetch2curl

v1.0.7

Published

Convert fetch arguments to a curl command.

Downloads

31

Readme

fetch2curl

Build Status Build status

npm (scoped) Dependency Status devDependency Status

License: MIT

Converts fetch arguments to a curl command.

install

$ npm i fetch2curl -S
# or
$ yarn add fetch2curl

usage

You can get executable curl command immediately and easily. Do anything with it, for example posting to chat.

parser

import { parser } from 'fetch2curl'

const command = parser('https://example.com', { method: 'POST' })
console.log(command) // curl https://example.com -X POST

hook fetch execution

import { inject, eject } from 'fetch2curl'

// hook fetch
inject(command => console.log(`COMMAND: \`${command}\``))
fetch('https://example.com', { method: 'POST' }) // COMMAND: `curl https://example.com -X POST`

// unregister the hook
eject()

development

$ git clone https://github.com/kamataryo/fetch-to-curl.git
$ cd fetch-to-curl
$ npm test

Available init options (the 2nd argument)

https://developer.mozilla.org/ja/docs/Web/API/WindowOrWorkerGlobalScope/fetch

  • [x] method: The request method, e.g., GET, POST.
  • [x] headers: Any headers you want to add to your request, contained within a Headers object or an object literal with ByteString values.
  • [x] body: Any body that you want to add to your request: this can be a Blob, BufferSource, FormData, URLSearchParams, or USVString object. Note that a request using the GET or HEAD method cannot have a body.
  • [ ] mode: The mode you want to use for the request, e.g., cors, no-cors, or same-origin.
  • [ ] credentials: The request credentials you want to use for the request: omit, same-origin, or include. To automatically send cookies for the current domain, this option must be provided. Starting with Chrome 50, this property also takes a FederatedCredential instance or a PasswordCredential instance.
  • [x] cache: The cache mode you want to use for the request: default, no-store, reload, no-cache, force-cache, or only-if-cached.
  • [x] redirect: The redirect mode to use: follow (automatically follow redirects), error (abort with an error if a redirect occurs), or manual (handle redirects manually). In Chrome the default is follow (before Chrome 47 it defaulted to manual).
  • [ ] referrer: A USVString specifying no-referrer, client, or a URL. The default is client.
  • [ ] referrerPolicy: Specifies the value of the referer HTTP header. May be one of no-referrer, no-referrer-when-downgrade, origin, origin-when-cross-origin, unsafe-url.
  • [ ] integrity: Contains the subresource integrity value of the request (e.g., sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=).
  • [ ] keepalive: The keepalive option can be used to allow the request to outlive the page. Fetch with the keepalive flag is a replacement for the Navigator.sendBeacon() API.
  • [ ] signal: An AbortSignal object instance; allows you to communicate with a fetch request and abort it if desired via an AbortController.