MemBeanTrainingSession

The MemBean client API

Constructor

new MemBeanTrainingSession(id, auth)

Begins the training session

Parameters:
NameTypeDescription
idNumber

The training session ID

authString

The authentication token

Methods

(async) advance(advancement, timeOnPageopt) → {Promise.<void>}

Advances the training session

Parameters:
NameTypeAttributesDefaultDescription
advancement
timeOnPageNumber<optional>
5

The time spent on the page, in seconds

Returns:
Type: 
Promise.<void>
Example
await session.advance(<TODO>, 5);

parseQuiz($) → {MembeanQuizState}

Parses the quiz data from the user state

Parameters:
NameTypeDescription
$cheerio.Cheerio

The Cheerio instance

Returns:

The parsed quiz data

Type: 
MembeanQuizState

parseSpellCheck($) → {MembeanSpellTestState}

Parses the spell check data from the user state

Parameters:
NameTypeDescription
$cheerio.Cheerio

The Cheerio instance

Returns:

The parsed spell check data

Type: 
MembeanSpellTestState

(async) parseTakeABreak($) → {Object}

Parses the take a break data from the user state, and terminates the session

Parameters:
NameTypeDescription
$cheerio.Cheerio

The Cheerio instance

Returns:

The parsed take a break data

Type: 
Object

(async) parseUserState() → {Promise.<void>}

Parses the user state

Returns:
Type: 
Promise.<void>
Example
await session.parseUserState();

parseWordLearn($, type) → {MembeanWordLearnState.<("new_word"|"restudy")>}

Parses the word learn data from the user state

Parameters:
NameTypeDescription
$cheerio.Cheerio

The Cheerio instance

type"new_word" | "restudy"

The type of word learn, for the emitter

Returns:

The parsed word learn data

Type: 
MembeanWordLearnState.<("new_word"|"restudy")>

Events

new_word

Emitted on a 'new_word' state

Type:
Example
session.on('new_word', (data) => console.log(data));

quiz

Emitted on a 'quiz' state

Example
session.on('quiz', (data) => console.log(data));

restudy

Emitted on a 'restudy' state

Type:
Example
session.on('restudy', (data) => console.log(data));

spelltest

Emitted on a 'spelltest' state

Example
session.on('spelltest', (data) => console.log(data));

take_a_break

Emitted on a 'take_a_break' state

Type:
  • null
Example
session.on('take_a_break', () => console.log('done'));