Methods
(static) attach(base, presetsopt, optsopt) → {function}
Attaches GrapplingHook methods to base
's prototype
.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
base |
function | ||
presets |
string |
<optional> |
presets name, see set |
opts |
options |
<optional> |
- Mixes In:
- Source:
- See:
-
- create for creating GrapplingHook instances.
- mixin for mixing GrapplingHook methods into instances.
Returns:
- Type
- function
Example
var grappling = require('grappling-hook');
var MyClass = function() {
};
MyClass.prototype.save = function(done) {
console.log('save!');
done();
};
grappling.attach(MyClass); // attach grappling-hook functionality to a 'class'
(static) create(presetsopt, optsopt) → {GrapplingHook}
Creates an object with GrapplingHook functionality.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
presets |
string |
<optional> |
presets name, see set |
opts |
options |
<optional> |
- Source:
- See:
-
- attach for attaching GrapplingHook methods to prototypes.
- mixin for mixing GrapplingHook methods into instances.
Returns:
- Type
- GrapplingHook
Example
var grappling = require('grappling-hook');
var instance = grappling.create(); // create an instance
(static) get(name) → {*}
Retrieves presets stored as name
. Or a specific value of a preset.
(The use of namespaces is to avoid the very unlikely case of name conflicts with deduped node_modules)
Parameters:
Name | Type | Description |
---|---|---|
name |
string |
Returns:
- Type
- *
Examples
grappling.get('grapplinghook:example.qualifiers.pre');
grappling.get('grapplinghook:example.qualifiers');
grappling.get('grapplinghook:example');
(static) isThenable(subject) → {Boolean}
Determines whether subject
is a thenable.
Parameters:
Name | Type | Description |
---|---|---|
subject |
* |
Returns:
- Type
- Boolean
(static) mixin(instance, presetsopt, optsopt) → {GrapplingHook}
Mixes GrapplingHook methods into instance
.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
instance |
Object | ||
presets |
string |
<optional> |
presets name, see set |
opts |
options |
<optional> |
- Mixes In:
- Source:
- See:
-
- attach for attaching GrapplingHook methods to prototypes.
- create for creating GrapplingHook instances.
Returns:
- Type
- GrapplingHook
Example
var grappling = require('grappling-hook');
var instance = {
};
grappling.mixin(instance); // add grappling-hook functionality to an existing object
(static) set(name, options) → {module:grappling-hook}
Store presets
as name
. Or set a specific value of a preset.
(The use of namespaces is to avoid the very unlikely case of name conflicts with deduped node_modules)
Parameters:
Name | Type | Description |
---|---|---|
name |
string | |
options |
options |
Returns:
Examples
//index.js - declaration
var grappling = require('grappling-hook');
grappling.set('grapplinghook:example', {
strict: false,
qualifiers: {
pre: 'before',
post: 'after'
}
});
//foo.js - usage
var instance = grappling.create('grapplinghook:example'); // uses options as cached for 'grapplinghook:example'
grappling.set('grapplinghook:example.qualifiers.pre', 'first');
grappling.set('grapplinghook:example.qualifiers.post', 'last');