babel-plugin-htmlbars-inline-precompile
Advanced tools
Comparing version 0.1.0 to 0.1.1
12
index.js
@@ -0,4 +1,14 @@ | ||
var crypto = require('crypto'); | ||
module.exports = function(precompile, _options) { | ||
var options = _options || {}; | ||
var cacheKey = options.cacheKey; | ||
// cacheKey can be very large; do not retain it | ||
options = _options = null; | ||
if (typeof cacheKey === 'string') { | ||
cacheKey = crypto.createHash('md5').update(cacheKey).digest('hex'); | ||
} | ||
function htmlbarsInlineCompilerPlugin(babel) { | ||
@@ -90,3 +100,3 @@ var t = babel.types; | ||
htmlbarsInlineCompilerPlugin.cacheKey = function() { | ||
return options.cacheKey; | ||
return cacheKey; | ||
}; | ||
@@ -93,0 +103,0 @@ |
{ | ||
"name": "babel-plugin-htmlbars-inline-precompile", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Babel plugin to replace tagged template strings with precompiled HTMLBars templates", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -6,2 +6,3 @@ var assert = require('assert'); | ||
var HTMLBarsInlinePrecompile = require('../index'); | ||
var crypto = require('crypto'); | ||
@@ -65,6 +66,8 @@ var transform; | ||
describe('caching', function() { | ||
it('passes through second argument as `cacheKey`', function() { | ||
it('captures an md4 hash of the `cacheKey` in its second arg', function() { | ||
var plugin = HTMLBarsInlinePrecompile(function() {}, { cacheKey: 'asdfasdf' }); | ||
assert.equal(plugin.cacheKey(), 'asdfasdf'); | ||
var digest = crypto.createHash('md5').update('asdfasdf').digest("hex"); | ||
assert.equal(plugin.cacheKey(), digest); | ||
}); | ||
@@ -71,0 +74,0 @@ |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
12006
169