Module: opensearch/utils

Methods

(static) assign(target, …sources) → {object}

Sort of polyfill for Object.assign
Parameters:
Name Type Attributes Description
target object the target to set the properties on.
sources object <repeatable>
the source objects to copy properties from.
Source:
Returns:
the target
Type
object

(static) createRequest(url, baseRequestopt) → {Request}

Returns a Request object for the fetch API.
Parameters:
Name Type Attributes Description
url string The request URL
baseRequest object <optional>
the baseRequest
Source:
Returns:
The constructed request.
Type
Request

(static) createXHR(url, baseRequestopt) → {XMLHttpRequest}

Creates (and sends) an XMLHttpRequest.
Parameters:
Name Type Attributes Description
url string The request URL
baseRequest object <optional>
the baseRequest
Source:
Returns:
The constructed request.
Type
XMLHttpRequest

(static) find(arr, predicate, thisArg) → {*}

Sort of polyfill for Array.prototype.find
Parameters:
Name Type Description
arr Array the array to find the entry on.
predicate function the callback to find the value.
thisArg * the `this` for the predicate function.
Source:
Returns:
the found item or undefined
Type
*

(static) lookupPrefix(node, namespaceURI) → {String}

Looks up the the namespace prefix on the given DOM Node and the given namespace
Parameters:
Name Type Description
node DOMNode The node to look up the namespace prefix
namespaceURI String The namespace URI to look up the namespace definition
Source:
Returns:
The namespace prefix
Type
String

(static) simplePath(element, path, singleopt) → {object|string|Array.<object>|Array.<string>}

Resolves an xPath like query with the given element as basis. All parts of the path must be specified, none may be omitted. Allows to select attributes using the `@attrName` postfix or the text of an element using the `text()` as the last path part.
Parameters:
Name Type Attributes Default Description
element object The root element to start the query on. Must be a DOM compliant object.
path string The search path: parts are separated by the `/` character and may contain a supported namespace prefix (separated by the color character). Examples: `os:Url@type`, `atom:entry/atom:title/text()`, `channel/item/georss:box/text()`
single boolean <optional>
false Whether multiple elements are expected. When false, an array is returned, otherwise single values.
Source:
Returns:
Depending on the query and the single parameter, either a DOM Node or a string, or arrays thereof.
Type
object | string | Array.<object> | Array.<string>