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

doStringGetterSetter

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

doBoolGetterSetter

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

doIntGetterSetter

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

doFloatGetterSetter

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

doMomentGetterSetter

src/util.ts
doMomentGetterSetter(obj: any, field: string, value: (DateTime | string)?)
Parameters
obj (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.

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.

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

checkProtocol

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

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

cloneFetchInitObj

src/util.ts
cloneFetchInitObj(fetchInit: Record<string, any>): Record<string, any>
Parameters
fetchInit (Record<string, any>)
Returns
Record<string, any>

doFetchWithTimeout

src/util.ts

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

doFetchWithTimeout(url: (string | URL), fetchInit: Record<string, any>?, timeoutSec: number?): Promise<Response>
Parameters
url ((string | URL)) url to retrieve
fetchInit (Record<string, any>?) fetch configuration, initialization
timeoutSec (number?) maximum time to wait in seconds
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

createSVGElement

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