From 7845740637eb646c0b13dc541f043fd65136fc03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Fri, 18 Sep 2020 15:20:55 +0200 Subject: refactor: deno_fetch op crate (#7524) --- op_crates/fetch/01_fetch_util.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 op_crates/fetch/01_fetch_util.js (limited to 'op_crates/fetch/01_fetch_util.js') diff --git a/op_crates/fetch/01_fetch_util.js b/op_crates/fetch/01_fetch_util.js new file mode 100644 index 000000000..07f45d821 --- /dev/null +++ b/op_crates/fetch/01_fetch_util.js @@ -0,0 +1,20 @@ +// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. + +((window) => { + function requiredArguments( + name, + length, + required, + ) { + if (length < required) { + const errMsg = `${name} requires at least ${required} argument${ + required === 1 ? "" : "s" + }, but only ${length} present`; + throw new TypeError(errMsg); + } + } + + window.__bootstrap.fetchUtil = { + requiredArguments, + }; +})(this); -- cgit v1.2.3