moment
RSVP

XML_MIME

src/util.js
XML_MIME

Type: string

JSON_MIME

src/util.js
JSON_MIME

Type: string

JSONAPI_MIME

src/util.js
JSONAPI_MIME

Type: string

TEXT_MIME

src/util.js
TEXT_MIME

Type: string

hasArgs(value: any): boolean
Parameters
value (any)
Returns
boolean

hasNoArgs

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

isStringArg

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

isNumArg

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

isNonEmptyStringArg

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

isObject

src/util.js
isObject(obj: any): boolean
Parameters
obj (any)
Returns
boolean
isDef(v: any): boolean
Parameters
v (any)
Returns
boolean

dataViewToString

src/util.js

Converts entire DataView to a string as utf-8.

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

stringify

src/util.js

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

calcClockOffset

src/util.js

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

StartEndDuration

src/util.js

Any two of startTime, endTime and duration can be specified, or just duration which then assumes endTime is now. startTime and endTime are moment 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 moment.utc().diff(serverTimeUTC, 'seconds', true). default is zero.

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

checkStringOrDate

src/util.js

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

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

makeParam

src/util.js

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

toIsoWoZ

src/util.js

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

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

checkProtocol

src/util.js
checkProtocol(): string
Returns
string: the protocol, http or https for the document if possible. *

defaultFetchInitObj

src/util.js

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

doFetchWithTimeout

src/util.js

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

doFetchWithTimeout(url: (string | URL), fetchInit: {}?, timeoutSec: number?): Promise<Response>
Parameters
url ((string | URL)) url to retrieve
fetchInit ({}?) 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

meanOfSlice

src/util.js

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