template-helpers
Advanced tools
+1
-2
@@ -164,3 +164,2 @@ 'use strict'; | ||
| var ctx = object.merge({}, this && this.context, context); | ||
| var len = arr.length; | ||
@@ -420,3 +419,3 @@ var idx = -1; | ||
| var rand = utils.random(0, i); | ||
| if (i != rand) { | ||
| if (i !== rand) { | ||
| res[i] = res[rand]; | ||
@@ -423,0 +422,0 @@ } |
+46
-0
@@ -18,1 +18,47 @@ 'use strict'; | ||
| }; | ||
| /** | ||
| * Filter the given array or object to contain only the matching values. | ||
| * | ||
| * ```js | ||
| * <%= filter(['foo', 'bar', 'baz']) %> | ||
| * //=> '["a", "b", "c"]' | ||
| * ``` | ||
| * | ||
| * @param {Array} `arr` | ||
| * @return {Array} | ||
| * @api public | ||
| */ | ||
| exports.filter = function filter(val, fn, context) { | ||
| if (utils.isEmpty(val)) return ''; | ||
| var iterator = function() {}; | ||
| if (typeof fn === 'string') { | ||
| var prop = fn; | ||
| iterator = function(target) { | ||
| if (typeof target === 'string') { | ||
| return target === prop; | ||
| } | ||
| return target[prop]; | ||
| }; | ||
| } else { | ||
| iterator = utils.makeIterator(fn, context); | ||
| } | ||
| if (typeof val === 'string') { | ||
| return iterator(val); | ||
| } | ||
| if (Array.isArray(val)) { | ||
| return val.filter(iterator); | ||
| } | ||
| if (utils.isObject(val)) { | ||
| var obj = val; | ||
| var res = {}; | ||
| for (var key in obj) { | ||
| if (obj.hasOwnProperty(key) && iterator(key)) { | ||
| res[key] = obj[key]; | ||
| } | ||
| } | ||
| return res; | ||
| } | ||
| }; |
+2
-2
@@ -278,3 +278,3 @@ 'use strict'; | ||
| if (len) { | ||
| var re =new RegExp('^[ \\t]{' + len + '}', 'gm'); | ||
| var re = new RegExp('^[ \\t]{' + len + '}', 'gm'); | ||
| return str.replace(re, ''); | ||
@@ -476,3 +476,3 @@ } | ||
| exports.titlecase = function titlecase(str, length) { | ||
| exports.titlecase = exports.titleize = function titlecase(str, length) { | ||
| return exports.isString(str) ? utils.titlecase(str) : ''; | ||
@@ -479,0 +479,0 @@ }; |
@@ -24,2 +24,3 @@ 'use strict'; | ||
| require('kind-of', 'typeOf'); | ||
| require('make-iterator'); | ||
| require('object.omit', 'omit'); | ||
@@ -33,3 +34,3 @@ require('relative'); | ||
| utils.isEmpty = function(val) { | ||
| utils.isEmpty = function(val) { | ||
| if (typeof val === 'function') { | ||
@@ -36,0 +37,0 @@ return false; |
+9
-9
| { | ||
| "name": "template-helpers", | ||
| "description": "Generic JavaScript helpers that can be used with any template engine. Handlebars, Lo-Dash, Underscore, or any engine that supports helper functions.", | ||
| "version": "0.6.4", | ||
| "version": "0.6.5", | ||
| "homepage": "https://github.com/jonschlinkert/template-helpers", | ||
@@ -38,2 +38,3 @@ "author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
| "lazy-cache": "^2.0.1", | ||
| "make-iterator": "^0.3.0", | ||
| "object.omit": "^2.0.0", | ||
@@ -48,13 +49,12 @@ "relative": "^3.0.2", | ||
| "gulp": "^3.9.1", | ||
| "gulp-eslint": "^2.0.0", | ||
| "gulp-format-md": "^0.1.8", | ||
| "gulp-istanbul": "^0.10.4", | ||
| "gulp-eslint": "^3.0.1", | ||
| "gulp-format-md": "^0.1.9", | ||
| "gulp-istanbul": "^1.0.0", | ||
| "gulp-mocha": "^2.2.0", | ||
| "helper-coverage": "^0.1.3", | ||
| "lodash": "^4.11.1", | ||
| "lodash.template": "^4.2.5", | ||
| "markdown-link": "^0.1.1", | ||
| "mocha": "^2.4.5", | ||
| "should": "^8.3.1", | ||
| "mocha": "^2.5.3", | ||
| "through2": "^2.0.1", | ||
| "verb-readme-generator": "^0.1.16" | ||
| "verb-generate-readme": "^0.1.21" | ||
| }, | ||
@@ -74,3 +74,3 @@ "keywords": [ | ||
| "verb": { | ||
| "toc": false, | ||
| "toc": true, | ||
| "helpers": [ | ||
@@ -77,0 +77,0 @@ "helper-coverage" |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 2 instances in 1 package
44252
2.2%11
-8.33%1801
2.45%19
5.56%+ Added
+ Added