Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

magicpen

Package Overview
Dependencies
Maintainers
2
Versions
93
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

magicpen - npm Package Compare versions

Comparing version 0.3.3 to 0.3.4

10

lib/MagicPen.js

@@ -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 @@

2

package.json
{
"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 () {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc