This simple SCORM API wrapper is designed to give developers a simple interface to the SCORM 1.2 API. This library is small and simple. It is tree shaking friendly. Only import the functions you are using.
Install using npm and webpack/rollup etc.
npm install scorm-promised
Then functions can then be imported and used.
import { init, get, set } from 'scorm-promised';
Before using the library you must initialise the module. This will find the SCORM API in the window and begin the session.
import { init } from 'scorm-promised';
init().then(() => console.log('Init library'));
import { set } from 'scorm-promised';
set('cmi.suspend_data', 'example')
.then(() => console.log('Value set'));
import { get } from 'scorm-promised';
get('cmi.suspend_data')
.then(val => console.log(val));
import { terminate } from 'scorm-promised';
terminate().then(() => console.log('API Terminated'));
import { getErrorCode } from 'scorm-promised';
getErrorCode().then(code => console.log(code));