Util

WikidataPain. Util

# new Util()

Methods

# (static) commonParameters(parameters, config) → {Object}

Parameters:
Name Type Description
parameters Object
config Object
Properties
Name Type Description
editgroup string
summary string
Returns:
Type
Object

# (static) comparePropertyValues(leftSnakMap, rightSnakMap) → {WikidataPain.PrecisionComparison}

Parameters:
Name Type Description
leftSnakMap Object.<string, Array.<WikidataPain.Snak>>
rightSnakMap Object.<string, Array.<WikidataPain.Snak>>

# (static) currentEntityId() → (nullable) {string}

Get the entity-ID of the entity that's currently open.
Returns:
Type
string

# (static) entityIdFromClaimId(claimId) → {string}

Parameters:
Name Type Description
claimId string Wikidata claim-ID.
Returns:
Wikidata Q-ID which the claimId belongs to.
Type
string

# (async, static) filterAsync(array, callbackFn) → {Promise.<Array.<T>>}

Parameters:
Name Type Description
array Array.<T>
callbackFn function
Returns:
Type
Promise.<Array.<T>>

# (static) invertPrecision(precision) → {WikidataPain.PrecisionComparison}

Reverses the "direction" of a precision comparison.
Parameters:
Name Type Description
precision WikidataPain.PrecisionComparison

# (static) makeArrayUnique(array) → {Array.<T>}

Parameters:
Name Type Description
array Array.<T>
Returns:
Type
Array.<T>

# (static) randomClaimId(entity) → {string}

Parameters:
Name Type Description
entity string Wikidata claim-ID.
Returns:
Type
string

# (static) randomEditGroup() → {string}

Returns a random ID which can be used for EditGroups.
Returns:
Type
string

# (static) randomUuidV4() → {string}

Random UUID which can be used as claim-id. Stolen from StackOverflow (of course): https://stackoverflow.com/a/2117523
Returns:
Type
string

# (static) sleep(ms) → {Promise.<void>}

Waits the given number of miliseconds using `setTimeout`, then resolves the promise.
Parameters:
Name Type Description
ms number
Returns:
Type
Promise.<void>

# (static) summary(editgroup, summary) → {string}

Parameters:
Name Type Default Description
editgroup string null
summary string null
Returns:
Type
string