Comparing version 0.3.3 to 0.3.4
@@ -251,2 +251,12 @@ var shim = require('./shim'); | ||
MagicPen.prototype.installPlugin = function (plugin) { | ||
if (typeof plugin !== 'function') { | ||
throw new Error('Expected first argument given to installPlugin to be a function'); | ||
} | ||
plugin(this); | ||
return this; | ||
}; | ||
module.exports = MagicPen; |
@@ -457,2 +457,12 @@ /*! | ||
MagicPen.prototype.installPlugin = function (plugin) { | ||
if (typeof plugin !== 'function') { | ||
throw new Error('Expected first argument given to installPlugin to be a function'); | ||
} | ||
plugin(this); | ||
return this; | ||
}; | ||
module.exports = MagicPen; | ||
@@ -459,0 +469,0 @@ |
{ | ||
"name": "magicpen", | ||
"version": "0.3.3", | ||
"version": "0.3.4", | ||
"description": "Styled output in both consoles and browsers", | ||
@@ -5,0 +5,0 @@ "main": "./lib/MagicPen.js", |
@@ -320,2 +320,19 @@ # MagicPen | ||
### installPlugin(plugin) | ||
MagicPen plugins are just functions that uses the `addStyle` | ||
method to add new custom styles to the MagicPen instance. | ||
```js | ||
var pen = magicpen(); | ||
function starPlugin(pen) { | ||
pen.addStyle('stars', function (content) { | ||
this.text(String(content).replace(/./g, '*')); | ||
}); | ||
} | ||
pen.installPlugin(starPlugin); | ||
pen.stars('secret'); | ||
expect(pen.toString(), 'to equal', '******'); | ||
``` | ||
## Aliases | ||
@@ -322,0 +339,0 @@ |
@@ -66,2 +66,19 @@ /*global describe, it, beforeEach*/ | ||
describe('installPlugin', function () { | ||
it('calls the given plugin with the magicpen instance as the parameter', function (done) { | ||
var pen = magicpen(); | ||
var plugin = function (magicpenInstance) { | ||
expect(magicpenInstance, 'to be', pen); | ||
done(); | ||
}; | ||
pen.installPlugin(plugin); | ||
}); | ||
it('throws if the given arguments is not a function', function () { | ||
expect(function () { | ||
magicpen().installPlugin({}); | ||
}, 'to throw', 'Expected first argument given to installPlugin to be a function'); | ||
}); | ||
}); | ||
describe('in text mode', function () { | ||
@@ -68,0 +85,0 @@ beforeEach(function () { |
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
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
122266
2093
417
0