S.A.R.A.H. utils lib
Library with helpful class for S.A.R.A.H.
Installation
> npm install sarah-lib-utils --save
Usage
S.A.R.A.H. integration
/** your_plugin_name.js */ const sarahLibUtils = ;const SarahActionContext = sarahLibUtilsSarahActionContext;const SarahActionHelper = sarahLibUtilsSarahActionHelper;const version = sarahLibUtilsversion; exports { var context = data callback; var helper = context; if version context; // For v3 compatibility var monModule = ; monModule;};
Version
Provide helpful methods to deal with Sarah version
// Loadconst version = ;// Helpervar isV3 = version;var isV4 = version;var sarahVersion = version;if versionv3 == versionNumber ...if versionv4 == sarahVersionNumber ...
Logger
SarahLogger will automatically add the channel in front of the message string
// Loadconst SarahLogger = ;// Instantiatevar logger = 'channel';// Helpervar message = 'myMessage';logger; // Will output 'debug: [channel] myMessage'logger; // Will output 'log: [channel] myMessage'logger; // Will output 'info: [channel] myMessage'logger; // Will output 'warn: [channel] myMessage'logger; // Will output 'error: [channel] myMessage'
Action Context
SarahActionContext is a simple wrapper for action data
// Loadconst SarahActionContext = ;// Instantiatevar context = data callback;// Settercontext;// Gettercontext;context;context;
Action Helper
SarahActionHelper provide helpful methods regarding action for module which want to run in SARAH v3 AND v4
Basics
// Loadconst SarahActionHelper = ;// Instantiatevar helper = <SarahActionContext> actionContext;// helperhelper;// Getterhelper;
S.A.R.A.H. module integration
/** MyModule.js *//** * @public * * @param * @param */MyModuleprototype { helper; /** @var */ var context = helper; /** @var */ var data = context; /** @var */ var callback = context; /** @var var sarah = context.getSARAH(); if (data.action == 'action1') { ... } ...};
Tests
> npm test
Coverage
> npm run coverage
Then open the coverage/index.js.html
file in a browser
EsLint
> npm run eslint
Release History
1.0.0
: Initial release1.1.0
: Readme badges1.1.1
: Fix npm version1.1.2
: Fix npm link1.1.3
: Fix npm version