XML_MIME

Type: string

JSON_MIME

dist/util.mjs
JSON_MIME

Type: string

JSONAPI_MIME

dist/util.mjs
JSONAPI_MIME

Type: string

SVG_MIME

Type: string

TEXT_MIME

dist/util.mjs
TEXT_MIME

Type: string

BINARY_MIME

dist/util.mjs
BINARY_MIME

Type: string

UTC_OPTIONS

dist/util.mjs
UTC_OPTIONS
Static Members
hasArgs(value: any)
Parameters
value (any)

hasNoArgs

dist/util.mjs
hasNoArgs(value: any)
Parameters
value (any)

isStringArg

dist/util.mjs
isStringArg(value: any)
Parameters
value (any)
isNumArg(value: any)
Parameters
value (any)

isNonEmptyStringArg

dist/util.mjs
isNonEmptyStringArg(value: any)
Parameters
value (any)
isObject(obj: any)
Parameters
obj (any)
isDef(value: any)
Parameters
value (any)

reErrorWithMessage

dist/util.mjs
reErrorWithMessage(err: any, message: any)
Parameters
err (any)
message (any)

asStringDictionary

dist/util.mjs
asStringDictionary(inobj: any)
Parameters
inobj (any)

doStringGetterSetter

dist/util.mjs
doStringGetterSetter(inobj: any, field: any, value: any)
Parameters
inobj (any)
field (any)
value (any)

doBoolGetterSetter

dist/util.mjs
doBoolGetterSetter(inobj: any, field: any, value: any)
Parameters
inobj (any)
field (any)
value (any)

doIntGetterSetter

dist/util.mjs
doIntGetterSetter(inobj: any, field: any, value: any)
Parameters
inobj (any)
field (any)
value (any)

doFloatGetterSetter

dist/util.mjs
doFloatGetterSetter(inobj: any, field: any, value: any)
Parameters
inobj (any)
field (any)
value (any)

doMomentGetterSetter

dist/util.mjs
doMomentGetterSetter(inobj: any, field: any, value: any)
Parameters
inobj (any)
field (any)
value (any)

dataViewToString

dist/util.mjs

Converts entire DataView to a string as utf-8.

dataViewToString(dataView: any): any
Parameters
dataView (any) bytes to convert
Returns
any: 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: any)
Parameters
msg (any) the message to log

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): any
Parameters
maybeError (any) obejct that might be an Error object
Returns
any: an Error object

DEBUG_ELEMENT

dist/util.mjs
DEBUG_ELEMENT

Type: string

SeisPlotDebugElement

dist/util.mjs
new SeisPlotDebugElement()

Extends HTMLElement

Instance Members
getCodeElement()
debug(msg)
clear()

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: any)
Parameters
msg (any) the message to log

stringify

dist/util.mjs

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

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

isoToDateTime

dist/util.mjs
isoToDateTime(val: any)
Parameters
val (any)

Create a luxon Interval from a start and end.

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

startDuration

dist/util.mjs

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: any, duration: any): any
Parameters
start (any) start of the interval as iso string or DateTime
duration (any) duration of the interval as iso string, number of seconds, or Duration
Returns
any: the interval

durationEnd

dist/util.mjs

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: any, end: any): any
Parameters
duration (any) duration of the interval as iso string, number of seconds, or Duration
end (any) end of the interval as string or DateTime
Returns
any: the interval

centerTimeDuration

dist/util.mjs

Create a luxon Interval from a duration and a center time. The final duration will be twice the input.

centerTimeDuration(center: any, duration: any, end: any): any
Parameters
center (any)
duration (any) half duration of the interval as iso string, number of seconds, or Duration
end (any) center of the interval as string or DateTime
Returns
any: the interval

calcClockOffset

dist/util.mjs

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: any): any
Parameters
serverTimeUTC (any) now as reported by remote server
Returns
any: offset in seconds to now on local machine

WAY_FUTURE

dist/util.mjs
WAY_FUTURE
WAY_PAST

checkStringOrDate

dist/util.mjs

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: any): any
Parameters
d (any) 'now', string time, Date, number of milliseconds since epoch, or DateTime
Returns
any: DateTime created from argument

makeParam

dist/util.mjs

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

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

makePostParam

dist/util.mjs

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

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

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

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

validStartTime

dist/util.mjs

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

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

validEndTime

dist/util.mjs

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

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

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

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

checkLuxonValid

dist/util.mjs

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: any, msg: any): any
Parameters
d (any) luxon object
msg (any) optional message to add to error
Returns
any: passed in object if valid

nameForTimeZone

dist/util.mjs

Create string name for a timezone. Uses zone name except for UTC, which returns "UTC".

nameForTimeZone(zone: any, atTime: any): any
Parameters
zone (any) timezone to describe
atTime (any) optional time to calc name at ie EST vs EDT
Returns
any: string version of zone

Utility method to pull raw text result from a url. Result returned is an Promise.

pullText(url: any, timeoutSec: any): any
Parameters
url (any) the url
timeoutSec (any)
Returns
any: promise to string result

Utility method to pull raw json result from a url. Result returned is an Promise.

pullJson(url: any, timeoutSec: any): any
Parameters
url (any) the url
timeoutSec (any)
Returns
any: promise to string result

checkProtocol

dist/util.mjs
checkProtocol(defaultProtocol: any): any
Parameters
defaultProtocol (any = "http:")
Returns
any: the protocol, http: or https: for the document if possible. Note this includes the colon.

fixProtocolInUrl

dist/util.mjs

Upgrade url protocol to https if document location is https

fixProtocolInUrl(url: any): any
Parameters
url (any) url to upgrade
Returns
any: upgraded url

defaultFetchInitObj

dist/util.mjs

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: any): any
Parameters
mimeType (any) requested mime type
Returns
any: object with fetch configuration parameters

cloneFetchInitObj

dist/util.mjs
cloneFetchInitObj(fetchInit: any)
Parameters
fetchInit (any)

errorFetch

dist/util.mjs
errorFetch(_url: any, _init: any)
Parameters
_url (any)
_init (any)

default_fetch

dist/util.mjs
default_fetch

setDefaultFetch

dist/util.mjs
setDefaultFetch(fetcher: any)
Parameters
fetcher (any)
getFetch()

doFetchWithTimeout

dist/util.mjs

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

doFetchWithTimeout(url: any, fetchInit: any, timeoutSec: any, fetcher: any): any
Parameters
url (any) url to retrieve
fetchInit (any) fetch configuration, initialization
timeoutSec (any) maximum time to wait in seconds
fetcher (any) optional fetch to use instead of global fetch
Returns
any: promise to the result
Throws
  • any: Error if time out or other failure

downloadBlobAsFile

dist/util.mjs

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

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

meanOfSlice

dist/util.mjs

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: any, totalPts: any): any
Parameters
dataSlice (any) slice of a seismogram
totalPts (any) number of points in the original seismogram
Returns
any: sum of slice data points divided by totalPts
SVG_NS

Type: string

XHTML_NS

Type: string

createSVGElement

dist/util.mjs
createSVGElement(name: any)
Parameters
name (any)

mightBeXml

dist/util.mjs
mightBeXml(buf: any)
Parameters
buf (any)

updateVersionText

dist/util.mjs
updateVersionText(selector: any)
Parameters
selector (any = ".sp_version")

Parses a string of the form 'an+b', where 'a' is a positive integer (can be omitted if 1), 'n' is a literal character, and 'b' is an integer (or omitted for zero). Examples include: '3n+1', 'n', '2n', '4n-2'. The resulting 'b' value will be reduced to its smallest positive form; for example, the previous example would return [4, 2] (-2 % 4 = 2), which is an equivalent representation when considering the bias for an infinite series.

anplusb(value: any): any
Parameters
value (any) String of the form 'an+b'
Returns
any: The 'a' and 'b' values parsed and reduced from the given 'value' string, returned as an array