Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsh

Package Overview
Dependencies
Maintainers
1
Versions
103
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsh - npm Package Compare versions

Comparing version 0.46.0 to 0.47.0

15

dist/index.d.ts

@@ -261,2 +261,13 @@ /// <reference types="node" />

/**
* Makes a POST HTTP request and uploads a file. Will throw an error if the response status code is not 2xx.
* @param url
* @param sourceFilePath
* @param contentType The media type of the file being uploaded (e.g. "image/png", "application/pdf", "text/plain", etc.)
* @param headers
* @returns
*/
upload<T_6>(url: string, sourceFilePath: string, contentType: string, headers?: {
[name: string]: string;
}): Promise<T_6 | undefined>;
/**
* Makes a GET HTTP request and saves the response to a file.

@@ -269,5 +280,5 @@ * Will throw an error if the response status code is not 2xx.

*/
download(url: string, filePath: string, headers?: {
download<T_7>(url: string, destinationFilePath: string, headers?: {
[name: string]: string;
}): Promise<IHttpResponse<any>>;
}): Promise<IHttpResponse<T_7>>;
};

@@ -274,0 +285,0 @@ /**

2

package.json
{
"name": "jsh",
"version": "0.46.0",
"version": "0.47.0",
"description": "Helpers for Bash like shell scripting in JavaScript",

@@ -5,0 +5,0 @@ "author": "Brady Holt",

@@ -106,4 +106,6 @@ # jsh [![Build](https://github.com/bradymholt/jsh/actions/workflows/build.yml/badge.svg)](https://github.com/bradymholt/jsh/actions/workflows/build.yml) [![NPM Package](https://img.shields.io/npm/v/jsh.svg)](https://www.npmjs.com/package/jsh)

| `await http("POST", "https://www.myapi.com", { data: "1" }, { headers: { Accept: "application/json" } })` | Make a HTTP request and return the response: (`{ data, headers, statusCode, statusMessage }`) |
| `await http.download("https://www.myapp.com/logo.jpg", "./logo.jpg")` | Download a file from a URL and save it to a local file path |
| `await http.upload("https://www.myapi.com/logo", "./logo.jpg", "image/jpg")` | Upload a file with a HTTP POST request |
| `await http.download("https://www.myapp.com/logo.jpg", "./logo.jpg")` | Perform a HTTP GET request and save the response to a local file path |
## Examples

@@ -299,3 +301,3 @@

#### Stream
You may also pass a readable Stream as `data`. This is common when sending a file as part of a request:
You may also pass a readable Stream as `data`. This is common when sending a file as part of a request.

@@ -309,6 +311,8 @@ ```js

"Content-Type": "image/jpeg",
"Content-Length": fileSize,
"Content-Length": fileSize.toString(),
});
```
_Note: If you are uploading a file, you can also use the `http.upload()` helper._
### Default Headers

@@ -315,0 +319,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc