helper-cache
Advanced tools
Comparing version 0.2.3 to 0.2.4
@@ -1,4 +0,1 @@ | ||
--- | ||
tags: ['verb-tag-jscomments'] | ||
--- | ||
# {%= name %} {%= badge("fury") %} | ||
@@ -28,20 +25,4 @@ | ||
// '.b': [Function] } | ||
var mixins = new Cache(); | ||
mixins.set('a', function (str) { | ||
return str.toLowerCase(); | ||
}); | ||
mixins.set('b', function (str) { | ||
return str.toUpperCase(); | ||
}); | ||
console.log(mixins); | ||
//=> { options: { bindFunctions: false }, | ||
// '.a': [Function], | ||
// '.b': [Function] } | ||
``` | ||
## API | ||
{%= jscomments("index.js") %} | ||
## Author | ||
@@ -48,0 +29,0 @@ {%= include("authors", { |
24
index.js
@@ -43,2 +43,3 @@ /*! | ||
* @option {Boolean} [options] `bindFunctions` Bind functions to `this`. Defaults to `false`. | ||
* @option {Boolean} [options] `thisArg` The context to use. | ||
* @api public | ||
@@ -61,6 +62,3 @@ */ | ||
var obj = { | ||
helpersAsync: {}, | ||
waiting: [] | ||
}; | ||
var obj = {helpersAsync: {}, waiting: []}; | ||
defineGetter(this, '_', function () { | ||
@@ -93,3 +91,2 @@ return obj; | ||
} | ||
return this; | ||
@@ -125,3 +122,3 @@ }.bind(this); | ||
var args = [].slice.call(arguments); | ||
self._.waiting.push({id: id, key: key, args: args}); | ||
self._.waiting.push({id: id, key: key, args: args, fn: fn.bind(this)}); | ||
return id; | ||
@@ -221,2 +218,11 @@ }); | ||
/** | ||
* Getter method to resolve async helper values that were called during | ||
* the render process. | ||
* | ||
* @param {String} `content` Rendered string containing async ids | ||
* @param {Function} `cb` | ||
* @api public | ||
*/ | ||
defineGetter(Helpers.prototype, 'resolve', function () { | ||
@@ -232,3 +238,4 @@ return function (content, cb) { | ||
// original async helper | ||
var fn = self.getHelperAsync(helper.key); | ||
var fn = helper.fn; | ||
if (!fn) return next(null, content); | ||
@@ -248,4 +255,5 @@ if (content.indexOf(helper.id) === -1) { | ||
} | ||
fn.apply(self, args); | ||
fn.apply(fn, args); | ||
} else { | ||
@@ -252,0 +260,0 @@ // call final callback |
{ | ||
"name": "helper-cache", | ||
"description": "Easily get and set helper functions to pass to any application or template engine.", | ||
"version": "0.2.3", | ||
"version": "0.2.4", | ||
"homepage": "https://github.com/jonschlinkert/helper-cache", | ||
@@ -36,2 +36,6 @@ "author": { | ||
}, | ||
"dependencies": { | ||
"load-helpers": "^0.1.0", | ||
"randomatic": "^0.1.4" | ||
}, | ||
"devDependencies": { | ||
@@ -67,7 +71,3 @@ "lodash": "^2.4.1", | ||
"yaml" | ||
], | ||
"dependencies": { | ||
"load-helpers": "^0.1.0", | ||
"randomatic": "^0.1.4" | ||
} | ||
] | ||
} |
@@ -30,40 +30,4 @@ # helper-cache [![NPM version](https://badge.fury.io/js/helper-cache.svg)](http://badge.fury.io/js/helper-cache) | ||
// '.b': [Function] } | ||
var mixins = new Cache(); | ||
mixins.set('a', function (str) { | ||
return str.toLowerCase(); | ||
}); | ||
mixins.set('b', function (str) { | ||
return str.toUpperCase(); | ||
}); | ||
console.log(mixins); | ||
//=> { options: { bindFunctions: false }, | ||
// '.a': [Function], | ||
// '.b': [Function] } | ||
``` | ||
## API | ||
### [Helpers](index.js#L45) | ||
* `options` **{Object}**: Default options to use. | ||
- `bindFunctions` **{Boolean}**: Bind functions to `this`. Defaults to `false`. | ||
```js | ||
var Helpers = require('helper-cache'); | ||
var helpers = new Helpers(); | ||
``` | ||
Set helpers on the cache. | ||
See [load-helpers] for issues, API details and the full range of options. | ||
### [.exports](index.js#L124) | ||
* `key` **{String}**: The helper to get. | ||
* `returns` **{Object}**: The specified helper. If no `key` is passed, the entire cache is returned. | ||
Get a helper from the cache. | ||
## Author | ||
@@ -88,5 +52,5 @@ | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on August 29, 2014._ | ||
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on October 30, 2014._ | ||
[load-helpers]: https://github.com/assemble/load-helpers |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1149
39143
54