Package Exports
- @locustjs/extensions-options
- @locustjs/extensions-options/dist/index.js
- @locustjs/extensions-options/src/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@locustjs/extensions-options) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
About
This library provides a helper ExtensionHelper class that is used in other @locustjs/extensions-... libraries.
Options
ExtensionHelper constructor has two parameters:
ExtensionHelper(options, logger)constructor parameters
| Parameter | Type | Required |
|---|---|---|
options |
object, string, array |
yes |
logger |
object |
no |
Structure of options as an object is as follows:
{
"include": [...],
"exclude": [...]
}include specifies list of function names that are going to be extended on a target object. The default value is *. It says all functions should be extended.
exclude specifies list of function names that should be skipped or ignored and should be extended on the target obejct.
If a string or array is passed as options parameter to ExtensionHelper constructor, it is used as a value for includes property.
methods
| method | description |
|---|---|
configure(options) |
gets an options argument in the form of object, string or array, validate it and returns an options object |
shouldExtend(fnName) |
Based on an options passed to current ExtensionHelper instance, checks whether given fnName should be extended or not and returns true or false. |
extend(obj, fnName, fn) |
Checks whether fnName function could be extended or not and if so, extends fn function with the name fnName on given obj object. |
Example
const eh = new ExtensionHelper('min, max')
eh.extend(Array, 'min', function () {
...
})