diff --git a/scripts/net.js b/scripts/net.js new file mode 100644 index 0000000..263d328 --- /dev/null +++ b/scripts/net.js @@ -0,0 +1,19 @@ +/* net.js + This script provides network utilities. +*/ + +export async function download(URL, type) { + let connect = await fetch(URL), + data; + + if (connect.ok) { + if (type ? type.includes(`json`) || type.includes(`dictionary`) : false) { + data = connect.json(); + } else { + data = connect.text(); + } + } + + // Return the filter. + return data; +}