Class: Shelf

data.Shelf(options)

new Shelf(options)

Shelf handles persistent key/value pairs, which are stored in the shelf collection on the server, and accessed in a safe, concurrent fashion.

Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Default Description
psychoJS module:core.PsychoJS the PsychoJS instance
autoLog boolean <optional>
false whether or not to log
Source:

Extends

  • PsychObject

Members

(static) MAX_KEY_LENGTH :number

Maximum number of components in a key
Type:
  • number
Source:

(readonly) Status :Symbol

Shelf status
Type:
  • Symbol
Source:

Methods

_checkAvailability(methodNameopt)

Check whether it is possible to run a given shelf command.
Parameters:
Name Type Attributes Default Description
methodName string <optional>
"" name of the method requiring a check
Source:

_checkKey(key)

Check the validity of the key.
Parameters:
Name Type Description
key object key whose validity is to be checked
Source:

counterBalanceSelect(keyopt, groups, groupSizes) → {Promise.<any>}

Get the name of a group, using a counterbalanced design.
Parameters:
Name Type Attributes Default Description
key Array.<string> <optional>
[] key as an array of key components
groups Array.<string> the names of the groups
groupSizes Array.<number> the size of the groups
Source:
Returns:
Type
Promise.<any>

getDictionaryFieldNames(keyopt) → {Promise.<any>}

Get the names of the fields in the dictionary record associated with the given key.
Parameters:
Name Type Attributes Default Description
key Array.<string> <optional>
[] key as an array of key components
Source:
Returns:
Type
Promise.<any>

getDictionaryValue(keyopt, fieldName, defaultValueopt) → {Promise.<any>}

Get the value of a given field in the dictionary record associated with the given key.
Parameters:
Name Type Attributes Default Description
key Array.<string> <optional>
[] key as an array of key components
fieldName string the name of the field
defaultValue <optional>
default value
Source:
Returns:
Type
Promise.<any>

getValue(keyopt, defaultValueopt) → {Promise.<any>}

Get the value associated with the given key.
Parameters:
Name Type Attributes Default Description
key Array.<string> <optional>
[] key as an array of key components
defaultValue <optional>
default value
Source:
Returns:
Type
Promise.<any>

increment(keyopt, incrementopt) → {Promise.<any>}

Increment the integer counter associated with the given key by the given amount.
Parameters:
Name Type Attributes Default Description
key Array.<string> <optional>
[] key as an array of key components
increment number <optional>
1 increment
Source:
Returns:
Type
Promise.<any>

incrementComponent(key, increment, callback) → {function}

Schedulable component that will block the experiment until the counter associated with the given key has been incremented by the given amount.
Parameters:
Name Type Description
key
increment
callback
Source:
Returns:
a component that can be scheduled
Type
function
Example
const flowScheduler = new Scheduler(psychoJS);
var experimentCounter = '<>';
flowScheduler.add(psychoJS.shelf.incrementComponent(['counter'], 1, (value) => experimentCounter = value));

setDictionaryField(keyopt, fieldName, fieldValue) → {Promise.<any>}

Set a field in the dictionary record associated to the given key.
Parameters:
Name Type Attributes Default Description
key Array.<string> <optional>
[] key as an array of key components
fieldName
fieldValue
Source:
Returns:
Type
Promise.<any>

setValue(keyopt, value) → {Promise.<any>}

Set the value associated with the given key.

This creates a new key/value pair if the key was previously unknown.

Parameters:
Name Type Attributes Default Description
key Array.<string> <optional>
[] key as an array of key components
value
Source:
Returns:
Type
Promise.<any>