Authentification token/code provider.
The PriorityListGroupMap
is a map to map the (integer) priority to a PriorityListGroup.
Copy methods and properties from one prototype into another.
Class to mix methods and properties into.
Class to take all methods and properties from.
Copy methods from one prototype into another.
Class to mix methods into.
Class to take all methods from.
Returns base URL of given resource URL.
Url
with trailing slash are considered genuine 'locations', they are returned as is, however if
url
ends with name component it is treated as "leaf", so last path component is removed.
Standalone files (without any folder structure) are considered relative to ./
.
Examples:
https://foo.com/themes/a.json -> https://foo.com/themes/
https://foo.com/themes/ -> https://foo.com/themes/
https://foo.com/themes -> https://foo.com/ // note, themes is treated as leaf
themes/day.json -> themes/
themes -> ./
Chains two functions for further assigning as one wrapped callback function
Deep clone of object.
Like JSON.parse(JSON.stringify(obj))
, but supports basic javascript types (string, number,
object), Date
and RegExp
s and cycles.
Throws error if enounters object with prototype
assuming that in general class instances
cannot be reliably cloned by generic algorithm.
Compose URI resolvers.
Creates new UriResolver that applies resolvers in orders or arguments.
Example:
const themeUrl = ...; // url of parent object
const childUrlResolver = composeUrlResolvers(
new RelativeUriResolver(themeUrl),
defaultUrlResolver
);
Converts webgl1-compatible fragment shader glsl code to webgl2.
String containing the fragment shader glsl code.
the converted glsl code.
Converts webgl1-compatible vertex shader glsl code to webgl2.
String containing the vertex shader glsl code.
the converted glsl code.
Get base URL for from where relative URLs will be loaded.
In browser, it resolves to baseUrl(location.href)
i.e document's base URL
(see: https://www.w3.org/TR/WD-html40-970917/htmlweb.html#h-5.1.2).
In node, it resolves to file://${process.cwd()}
.
Get first defined value.
Specialized "replacement" for a || b || c
used frequently to get value from various sources
(defaults, configs constants).
In contrast to ||
, this function provides proper typing for usual use cases (constant as last
argument) and correct treatment of null
and undefined
.
If last parameter is "defined" then return type is T
, otherwise return type is T | undefined
.
Usage example:
interface Config {
x?: number;
}
const someConfig: Config = {};
const val: number | undefined = undefined;
const DEFAULT = 5;
const x = getOptionValue(val, someConfig.x, DEFAULT);
// typeof x === 'number' because DEFAULT is defined
const y = getOptionValue(val, someConfig.x);
// typeof y === 'number | undefined' because someConfig.x is possibly undefined
Parse host
and protocol
part from URL.
Get origin
part of URL.
input URL
origin of given URL
Pick props
from `object.
Runtime version of Pick<T,K>
.
Resolve URI of referenced object w.r.t parent URI.
Resolves childUri
as it would be loaded from location specified by parentUri
.
If childUri
is absolute, then it is returned unchanged.
If childUri
is origin-absolute path, then only origin path is taken from parentUri
.
See [[baseUri]] for reference how base URL of parentUri
is determined.
Supports http:
, https:
, file:
, data:
schemes.
Examples:
// normal case, child is sibling
https://foo.com/themes/day.json + images/foo.png -> https://foo.com/themes/images/foo.png
// parent is "folder", so child is just located in this folder
https://foo.com/themes/ + images/foo.png -> https://foo.com/themes/images/foo.png
// parent looks like leaf, so last component is stripped
https://foo.com/themes + images/foo.png -> https://foo.com/images/foo.png
// origin-absolute URL, takes only origin from parent
https://foo.com/themes/day.json + /fonts/foo.json -> https://foo.com/fonts/foo.json
URI of parent resource
URI of child as referenced from parent resource
childUrl
as if anchored in location of parentUrl
Returns a bilinear-interpolated texture sample for a given texture.
Two-dimensional texture to sample.
Texture width.
Texture height.
Number between 0 and 1 representing the location to sample in the width dimension.
Number between 0 and 1 representing the location to sample in the height dimension.
Generated using TypeDoc
@here/harp-utils
Overview
This module provides utility classes. Such as, but not limited to:
Logger
Custom logger for writing messages to browser console or separate window. Messages could be filtered by log names or completely disabled via URI parameters or UI. Logger name is required and cannot be empty.
import { LoggerManager, LogLevel } from '@here/harp-utils'; const loggerManager = LoggerManager.instance; // Create named logger and configure it to Warn log level. const logger: ILogger = loggerManager.create('my logger', { level: LogLevel.Warn }); // Warning 'my logger: something' logged to output. logger.warn('something...'); // Won't be logged because log level is 'warn'. logger.log('not logged...'); // Now, message is logged. logger.level = LogLevel.Log; logger.log('logged...'); // Be good developer. Free resources after you done. // Unregister logger from global registry. loggerManager.dispose(logger);