util

Utility functions for common queries and operations

Details

Methods


<static> firstGM() → {User|undefined}

Description

A helper functions that returns the first active GM level user.

Returns

First active GM User

Details

<static> firstOwner( doc ) → {User|undefined}

Description

Returns the first active user with owner permissions for the given document, falling back to the firstGM should there not be any. Returns false if the document is falsey. In the case of token documents it checks the permissions for the token's actor as tokens themselves do not have a permission object.

Parameters
Name Type Description
doc Object | Object | Actor
Returns
Details

<static> isFirstGM() → {boolean}

Description

Checks whether the user calling this function is the user returned by warpgate.util.firstGM. Returns true if they are, false if they are not.

Returns

Is the current user the first active GM user?

Details

<static> isFirstOwner() → {boolean}

Description

Checks whether the user calling this function is the user returned by warpgate.util.firstOwner when the function is passed the given document. Returns true if they are the same, false if they are not.

As firstOwner, biases towards players first.

Returns

the current user is the first player owner. If no owning player, first GM.

Details

<async, static> waitFor( fn [, maxIter [, iterWaitTime ] ] ) → {Boolean}

Description

Advanced helper function similar to warpgate.wait that allows for non-deterministic waits based on the predicate function, fn, provided.

Parameters
Name Type Attributes Default Description
fn function

Given the current wait iteration number and the time spent waiting as parameters, return a boolean indicating if we should continue to wait.

maxIter number <optional>
600

Negative value will allow unbounded wait based on fn. Positive values act as a timeout. Defaults will cause a timeout after 1 minute.

iterWaitTime number <optional>
100

Time (in ms) between each predicate function check for continued waiting

Returns

Indicates if the function return was caused by timeout during waiting

Details