Module: kongUtilWeb

Methods

(inner) createFormData(object)

Creates a new FormData from an object

Parameters:
Name Type Description
object Object | URLSearchParams
Source:
Returns:

FormData

(inner) fetchCSV(…args) → {Promise.<Object>}

Download a CSV file and parse it to an array of objects

Parameters:
Name Type Attributes Description
args any <repeatable>

same as fetchEx()

Source:
Returns:
Type
Promise.<Object>

(inner) fetchDOM(…args) → {Promise.<HTMLDocument>}

Download an HTML file and parse it to HTMLDocument

Parameters:
Name Type Attributes Description
args any <repeatable>

same as fetchEx()

Source:
Returns:
Type
Promise.<HTMLDocument>

(inner) fetchEx(resource, optionsopt)

Similar to fetch() but works different if body exists.

  1. if body is a normal object (such as those created by {}), construct a URLSearchParams from it.
  2. if body is an HTMLFormElement, construct a FormData from it.
  3. if body is a normal object or a URLSearchParams, and method is set to 'GET' explicitly, convert the request into a URL with search param without, and then make the request without body.
  4. if body exists without setting method, warn and request with POST method.
Parameters:
Name Type Attributes Description
resource string | URL | Request
options RequestInit <optional>
Source:

(inner) fetchJSON(…args) → {Promise.<Object>}

Download a JSON file and deserialize it.

Parameters:
Name Type Attributes Description
args any <repeatable>

same as fetchEx()

Source:
Returns:
Type
Promise.<Object>

(inner) fetchStrict(args) → {Promise.<Response>}

Similar to fetchEx() but rejects if HTTP error (e.g "404 not found").

Parameters:
Name Type Description
args Array.<any>

same as fetchEx()

Source:
Returns:
Type
Promise.<Response>

(inner) fetchText(…args) → {Promise.<string>}

Download a plain text file and read it.

Parameters:
Name Type Attributes Description
args any <repeatable>

same as fetchEx()

Source:
Returns:
Type
Promise.<string>

(inner) readFile(blob, type) → {Promise.<any>}

Promise version of FileReader.

Parameters:
Name Type Description
blob Blob
type string

arrayBuffer, binaryString, dataURL, or text

Source:
Returns:
Type
Promise.<any>