XML_MIME

src/util.ts
XML_MIME

Type: string

JSON_MIME

src/util.ts
JSON_MIME

Type: string

JSONAPI_MIME

src/util.ts
JSONAPI_MIME

Type: string

SVG_MIME

src/util.ts
SVG_MIME

Type: string

TEXT_MIME

src/util.ts
TEXT_MIME

Type: string

BINARY_MIME

src/util.ts
BINARY_MIME

Type: string

UTC_OPTIONS

src/util.ts
UTC_OPTIONS
Static Members
zone
hasArgs(value: any): boolean
Parameters
value (any)
Returns
boolean

hasNoArgs

src/util.ts
hasNoArgs(value: any): boolean
Parameters
value (any)
Returns
boolean

isStringArg

src/util.ts
isStringArg(value: any): any
Parameters
value (any)
Returns
any

isNumArg

src/util.ts
isNumArg(value: any): any
Parameters
value (any)
Returns
any

isNonEmptyStringArg

src/util.ts
isNonEmptyStringArg(value: any): any
Parameters
value (any)
Returns
any

isObject

src/util.ts
isObject(obj: any): any
Parameters
obj (any)
Returns
any
isDef(value: (Value | undefined | null)): any
Parameters
value ((Value | undefined | null))
Returns
any

reErrorWithMessage

src/util.ts
reErrorWithMessage(err: any, message: string): Error
Parameters
err (any)
message (string)
Returns
Error

StringDictionary

src/util.ts
StringDictionary

asStringDictionary

src/util.ts
asStringDictionary(inobj: any): StringDictionary
Parameters
inobj (any)
Returns
StringDictionary

doStringGetterSetter

src/util.ts
doStringGetterSetter(inobj: any, field: string, value: string?)
Parameters
inobj (any)
field (string)
value (string?)

doBoolGetterSetter

src/util.ts
doBoolGetterSetter(inobj: any, field: string, value: boolean?)
Parameters
inobj (any)
field (string)
value (boolean?)

doIntGetterSetter

src/util.ts
doIntGetterSetter(inobj: any, field: string, value: number?)
Parameters
inobj (any)
field (string)
value (number?)

doFloatGetterSetter

src/util.ts
doFloatGetterSetter(inobj: any, field: string, value: number?)
Parameters
inobj (any)
field (string)
value (number?)

doMomentGetterSetter

src/util.ts
doMomentGetterSetter(inobj: any, field: string, value: (DateTime | string)?)
Parameters
inobj (any)
field (string)
value ((DateTime | string)?)

dataViewToString

src/util.ts

Converts entire DataView to a string as utf-8.

dataViewToString(dataView: DataView): string
Parameters
dataView (DataView) bytes to convert
Returns
string: the string

Log a message to the console. Put here to limit lint console errors for the times we really do want to use console.log. Will also append a p tag to a div#debug if it exists.

log(msg: string): void
Parameters
msg (string) the message to log
Returns
void

typescript-y check if Error.

isError(error: any): any
Parameters
error (any) object that might be an Error
Returns
any: true if Error object

typescript-y convert errors.

toError(maybeError: any): Error
Parameters
maybeError (any) obejct that might be an Error object
Returns
Error: an Error object

Log a warning message to the console. Put here to limit lint console errors for the times we really do want to use console.log. Will also append a p tag to a div#debug if it exists.

warn(msg: string): void
Parameters
msg (string) the message to log
Returns
void

stringify

src/util.ts

String representation of input. This is kind of dumb but makes flow happier.

stringify(value: any): string
Parameters
value (any) any kind of thing that can be turned into a string
Returns
string: a string

isoToDateTime

src/util.ts
isoToDateTime(val: string): DateTime
Parameters
val (string)
Returns
DateTime

startEnd

src/util.ts

Create a luxon Interval from a start and end.

startEnd(start: (string | DateTime), end: (string | DateTime)): Interval
Parameters
start ((string | DateTime)) start of the interval as iso string or DateTime
end ((string | DateTime)) end of the interval as string or DateTime
Returns
Interval: the interval

startDuration

src/util.ts

Create a luxon Interval from a start and a duration. If the duration is negative, the start time will become the end time. This differs from luxon Interval.after which will return an invalid Interval instead.

startDuration(start: (string | DateTime), duration: (string | Duration | number)): Interval
Parameters
start ((string | DateTime)) start of the interval as iso string or DateTime
duration ((string | Duration | number)) duration of the interval as iso string, number of seconds, or Duration
Returns
Interval: the interval

durationEnd

src/util.ts

Create a luxon Interval from a duration and a end. If the duration is negative, the end time will become the start time. This differs from luxon Interval.before which will return an invalid Interval instead.

durationEnd(duration: (string | Duration | number), end: (string | DateTime)): Interval
Parameters
duration ((string | Duration | number)) duration of the interval as iso string, number of seconds, or Duration
end ((string | DateTime)) end of the interval as string or DateTime
Returns
Interval: the interval

calcClockOffset

src/util.ts

Calculates offset of remote server versus local time. It is assumed that the argument was acquired as close in time to calling this as possible.

calcClockOffset(serverTimeUTC: DateTime): number
Parameters
serverTimeUTC (DateTime) now as reported by remote server
Returns
number: offset in seconds to now on local machine

WAY_FUTURE

src/util.ts
WAY_FUTURE

Type: DateTime

checkStringOrDate

src/util.ts

converts the input value is a DateTime, throws Error if not a string, Date or DateTime. Zero length string or "now" return current time.

checkStringOrDate(d: (string | Date | DateTime)): DateTime
Parameters
d ((string | Date | DateTime)) 'now', string time, Date, number of milliseconds since epoch, or DateTime
Returns
DateTime: DateTime created from argument

makeParam

src/util.ts

Converts name and value into a html query parameter, with appending ampersand.

makeParam(name: string, val: any): string
Parameters
name (string) parameter name
val (any) parameter value
Returns
string: formated query parameter

makePostParam

src/util.ts

Converts name and value into a parameter line, with appending newline, for including in POST body.

makePostParam(name: string, val: any): string
Parameters
name (string) parameter name
val (any) parameter value
Returns
string: formated query parameter

toIsoWoZ

src/util.ts

converts to ISO8601 but removes the trailing Z as FDSN web services do not allow that.

toIsoWoZ(date: DateTime): string
Parameters
date (DateTime) DateTime to convert to string
Returns
string: ISO8601 without timezone Z

validStartTime

src/util.ts

Extracts a valid starting DateTime from interval. Throws Error if interval is not valid.

validStartTime(interval: Interval): DateTime
Parameters
interval (Interval) luxon Interval
Returns
DateTime: start DateTime

validEndTime

src/util.ts

Extracts a valid ending DateTime from interval. Throws Error if interval is not valid.

validEndTime(interval: Interval): DateTime
Parameters
interval (Interval) luxon Interval
Returns
DateTime: end DateTime

toJSDate

src/util.ts

Converts a luxon DateTime to a Javascript Date, checking for null, undefined and isValid first. Throws Error in that case.

toJSDate(d: (DateTime | null | undefined)): any
Parameters
d ((DateTime | null | undefined)) luxon DateTime
Returns
any: Javascript Date

checkLuxonValid

src/util.ts

Check a Luxon DateTime, Interval or Duration for valid. Throws Error if not. THis is to avoid globally setting luxon's Settings.throwOnInvalid = true; but still throw/catch on invalid dates.

checkLuxonValid(d: (null | DateTime | Interval | Duration), msg: string?): any
Parameters
d ((null | DateTime | Interval | Duration)) luxon object
msg (string?) optional message to add to error
Returns
any: passed in object if valid

checkProtocol

src/util.ts
checkProtocol(): string
Returns
string: the protocol, http: or https: for the document if possible. Note this includes the colon.

FetchInitObject

src/util.ts
FetchInitObject

defaultFetchInitObj

src/util.ts

Create default fetch init object with the given mimeType. Sets no-cache, follow redirects, cors mode, referrer as seisplotjs and mimetype as a header. Note that redirect with POST may fail due to POST being changed to GET on a 301. Fetching with POST may wish to use redirect: "manual" to handle the 301 correctly by POSTing to the new URL.

defaultFetchInitObj(mimeType: string?): RequestInit
Parameters
mimeType (string?) requested mime type
Returns
RequestInit: object with fetch configuration parameters

cloneFetchInitObj

src/util.ts
cloneFetchInitObj(fetchInit: RequestInit): RequestInit
Parameters
fetchInit (RequestInit)
Returns
RequestInit

errorFetch

src/util.ts
errorFetch(_url: (URL | RequestInfo), _init: (RequestInit | undefined)?): Promise<Response>
Parameters
_url ((URL | RequestInfo))
_init ((RequestInit | undefined)?)
Returns
Promise<Response>

default_fetch

src/util.ts
default_fetch

Type: (null | function (url: (URL | RequestInfo), init: (RequestInit | undefined)): Promise<Response>)

setDefaultFetch

src/util.ts
setDefaultFetch(fetcher: function (url: (URL | RequestInfo), init: (RequestInit | undefined)): Promise<Response>)
Parameters
fetcher (function (url: (URL | RequestInfo), init: (RequestInit | undefined)): Promise<Response>)

getFetch

src/util.ts
getFetch(): function (url: (URL | RequestInfo), init: (RequestInit | undefined)): Promise<Response>
Returns
function (url: (URL | RequestInfo), init: (RequestInit | undefined)): Promise<Response>

doFetchWithTimeout

src/util.ts

Does a fetch, but times out if it takes too long.

doFetchWithTimeout(url: (string | URL), fetchInit: RequestInit?, timeoutSec: number?, fetcher: function (url: (URL | RequestInfo), init: (RequestInit | undefined)): Promise<Response>?): Promise<Response>
Parameters
url ((string | URL)) url to retrieve
fetchInit (RequestInit?) fetch configuration, initialization
timeoutSec (number?) maximum time to wait in seconds
fetcher (function (url: (URL | RequestInfo), init: (RequestInit | undefined)): Promise<Response>?) optional fetch to use instead of global fetch
Returns
Promise<Response>: promise to the result
Throws
  • any: Error if time out or other failure

downloadBlobAsFile

src/util.ts

Allows downloading of in memory data, as ArrayBuffer, to file as if the user clicked a download link.

downloadBlobAsFile(data: ArrayBuffer, filename: string, mimeType: any)
Parameters
data (ArrayBuffer) ArrayBuffer to download
filename (string) default filename
mimeType (any = "application/octet-stream") mimeType, default application/octet-stream

meanOfSlice

src/util.ts

Recursively calculates the mean of a slice of an array. This helps with very long seismograms to equally weight each sample point without overflowing.

meanOfSlice(dataSlice: (Int32Array | Float32Array | Float64Array), totalPts: number): number
Parameters
dataSlice ((Int32Array | Float32Array | Float64Array)) slice of a seismogram
totalPts (number) number of points in the original seismogram
Returns
number: sum of slice data points divided by totalPts
SVG_NS

Type: string

XHTML_NS

src/util.ts
XHTML_NS

Type: string

createSVGElement

src/util.ts
createSVGElement(name: string): SVGElement
Parameters
name (string)
Returns
SVGElement

updateVersionText

src/util.ts
updateVersionText(selector: any)
Parameters
selector (any = "#sp-version")