mirror of
https://github.com/chenasraf/DefinitelyTyped.git
synced 2026-05-18 01:49:01 +00:00
* [got] Remove types * Change Bluebird dep from 2->3 This isn't strictly accurate, but makes the types work out, since p-cancelable's types, a transitive dependency of got, have a Promise.cancel return type that conflicts with bluebird@2's. Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
import * as fs from "fs";
|
|
import download = require("download");
|
|
|
|
// test type exports
|
|
type DownloadOptions = download.DownloadOptions;
|
|
|
|
download("http://unicorn.com/foo.jpg"); // $ExpectType Promise<Buffer> & GotEmitter & Duplex
|
|
download("http://unicorn.com/foo.jpg", "dist"); // $ExpectType Promise<Buffer> & GotEmitter & Duplex
|
|
download("http://unicorn.com/foo.jpg", "dist", { extract: true }); // $ExpectType Promise<Buffer> & GotEmitter & Duplex
|
|
download("http://unicorn.com/foo.jpg", "dist", { filename: "foo" }); // $ExpectType Promise<Buffer> & GotEmitter & Duplex
|
|
download("http://unicorn.com/foo.jpg", { extract: true }); // $ExpectType Promise<Buffer> & GotEmitter & Duplex
|
|
download("http://unicorn.com/foo.jpg", { filename: "foo" }); // $ExpectType Promise<Buffer> & GotEmitter & Duplex
|
|
|
|
download("http://unicorn.com/foo.jpg").then(data => {
|
|
fs.writeFileSync("dist/foo.jpg", data);
|
|
});
|
|
|
|
download("unicorn.com/foo.jpg").pipe(fs.createWriteStream("dist/foo.jpg"));
|
|
|
|
// Got options
|
|
download("unicorn.com/foo.jpg", "dest", {
|
|
decompress: true,
|
|
encoding: "utf8",
|
|
followRedirect: true,
|
|
query: "",
|
|
timeout: {
|
|
connect: 20,
|
|
request: 20,
|
|
socket: 20,
|
|
},
|
|
useElectronNet: true,
|
|
});
|
|
|
|
// Decompress options
|
|
download("unicorn.com/foo.jpg", "dest", {
|
|
filter: file => true,
|
|
map: file => file,
|
|
plugins: [],
|
|
strip: 1,
|
|
});
|