RSVP

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

rethrowWithMessage

src/util.ts
rethrowWithMessage(err: any, message: string): never
Parameters
err (any)
message (string)
Returns
never

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)
Returns
any

typescript-y convert errors.

toError(maybeError: any): Error
Parameters
maybeError (any)
Returns
Error

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

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

StartEndDuration

src/util.ts

Any two of startTime, endTime and duration can be specified, or just duration which then assumes endTime is now. startTime and endTime are DateTime objects, duration is in seconds. clockOffset is the seconds that should be subtracted from the computer time to get real world time, ie computerUTC - UTC or DateTime.utc().diff(serverTimeUTC, 'seconds', true). default is zero.

new StartEndDuration(startTime: (DateTime | string | null), endTime: (DateTime | string | null), duration: (Duration | string | number | null), clockOffset: (number | null))
Parameters
startTime ((DateTime | string | null))
endTime ((DateTime | string | null))
duration ((Duration | string | number | null) = null)
clockOffset ((number | null) = 0)
Instance Members
_startTime
_endTime
_duration
_clockOffset
start
startTime
end
endTime
duration
clockOffset
contains(other)
overlaps(other)
intersect(other)
union(other)
toString()

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.

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.

defaultFetchInitObj(mimeType: string?): Record<string, any>
Parameters
mimeType (string?) requested mime type
Returns
Record<string, any>: object with fetch configuration parameters

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') ='application/octet-stream' mimeType

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