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

power-assert-formatter

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

power-assert-formatter - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

14

CHANGELOG.md

@@ -0,1 +1,15 @@

## [1.1.0](https://github.com/power-assert-js/power-assert-formatter/releases/tag/v1.1.0) (2015-09-14)
#### Bug Fixes
* fix location detection of infix operator ([f6e0d691](https://github.com/power-assert-js/power-assert-formatter/commit/f6e0d6919ee32045c18983c00d60011d0dc4a0d1))
#### Features
* expose built-in Renderer classes ([c19ee541](https://github.com/power-assert-js/power-assert-formatter/commit/c19ee5411fbe5bd8eed5be418252d8576aa75e0f))
* introduce new Renderer initialization style ([ee643548](https://github.com/power-assert-js/power-assert-formatter/commit/ee6435484143ae5fadae913608ff97df66ca8f23))
### [1.0.2](https://github.com/power-assert-js/power-assert-formatter/releases/tag/v1.0.2) (2015-08-25)

@@ -2,0 +16,0 @@

8

lib/built-in/assertion.js
'use strict';
function AssertionRenderer (traversal, config) {
function AssertionRenderer (config) {
}
AssertionRenderer.prototype.init = function (traversal) {
var assertionLine;

@@ -12,3 +15,4 @@ traversal.on('start', function (context) {

});
}
};
module.exports = AssertionRenderer;

@@ -9,3 +9,3 @@ 'use strict';

function BinaryExpressionRenderer(traversal, config) {
function BinaryExpressionRenderer(config) {
this.config = config;

@@ -15,2 +15,5 @@ this.stringify = config.stringify;

this.espathToPair = {};
}
BinaryExpressionRenderer.prototype.init = function (traversal) {
var _this = this;

@@ -48,3 +51,3 @@ traversal.on('esnode', function (esNode) {

});
}
};

@@ -51,0 +54,0 @@ BinaryExpressionRenderer.prototype.compare = function (pair, writer) {

@@ -5,3 +5,3 @@ 'use strict';

function DiagramRenderer (traversal, config) {
function DiagramRenderer (config) {
this.config = config;

@@ -12,2 +12,5 @@ this.events = [];

this.initialVertivalBarLength = 1;
}
DiagramRenderer.prototype.init = function (traversal) {
var _this = this;

@@ -32,3 +35,3 @@ traversal.on('start', function (context) {

});
}
};

@@ -35,0 +38,0 @@ DiagramRenderer.prototype.initializeRows = function () {

'use strict';
function FileRenderer (traversal, config) {
function FileRenderer (config) {
}
FileRenderer.prototype.init = function (traversal) {
var filepath, lineNumber;

@@ -16,3 +19,4 @@ traversal.on('start', function (context) {

});
}
};
module.exports = FileRenderer;

@@ -13,9 +13,14 @@ 'use strict';

var AssertionRenderer = require('./built-in/assertion');
var FileRenderer = require('./built-in/file');
var DiagramRenderer = require('./built-in/diagram');
var BinaryExpressionRenderer = require('./built-in/binary-expression');
// "Browserify can only analyze static requires. It is not in the scope of browserify to handle dynamic requires."
// https://github.com/substack/node-browserify/issues/377
var defaultRendererClasses = {
'./built-in/file': require('./built-in/file'),
'./built-in/assertion': require('./built-in/assertion'),
'./built-in/diagram': require('./built-in/diagram'),
'./built-in/binary-expression': require('./built-in/binary-expression')
'./built-in/file': FileRenderer,
'./built-in/assertion': AssertionRenderer,
'./built-in/diagram': DiagramRenderer,
'./built-in/binary-expression': BinaryExpressionRenderer
};

@@ -63,3 +68,10 @@

var renderers = map(rendererClasses, function (RendererClass) {
return new RendererClass(traversal, extend(config));
var renderer;
if (RendererClass.length === 2) {
renderer = new RendererClass(traversal, extend(config));
} else {
renderer = new RendererClass(extend(config));
renderer.init(traversal);
}
return renderer;
});

@@ -75,4 +87,10 @@ traversal.emit('start', context);

create.renderers = {
AssertionRenderer: AssertionRenderer,
FileRenderer: FileRenderer,
DiagramRenderer: DiagramRenderer,
BinaryExpressionRenderer: BinaryExpressionRenderer
};
create.defaultOptions = defaultOptions;
create.stringWidth = stringWidth;
module.exports = create;

@@ -65,3 +65,2 @@ 'use strict';

token.loc.end.column < toColumn &&
token.type === 'Punctuator' && // esprima
token.value === expression.operator) {

@@ -68,0 +67,0 @@ return token;

{
"name": "power-assert-formatter",
"description": "Power Assert output formatter",
"version": "1.0.2",
"version": "1.1.0",
"author": {

@@ -44,3 +44,3 @@ "name": "Takuto Wada",

"jshint-stylish": "^2.0.1",
"licensify": "^1.4.0",
"licensify": "^2.0.1",
"mocha": "^2.2.5",

@@ -47,0 +47,0 @@ "mocha-lcov-reporter": "^0.0.2",

@@ -240,3 +240,3 @@ (function (root, factory) {

}
rendererCustomizationTest('without binary-expression renderer', {
rendererCustomizationTest('with old-style custom renderer', {
renderers: [

@@ -262,4 +262,64 @@ './built-in/file',

(function () {
function NewCustomRenderer (config) {
}
NewCustomRenderer.prototype.init = function (traversal) {
var assertionLine;
traversal.on('start', function (context) {
assertionLine = context.source.content;
});
traversal.on('render', function (writer) {
writer.write('');
writer.write('$$ ' + assertionLine + ' $$');
});
};
rendererCustomizationTest('with new-style custom renderer', {
renderers: [
'./built-in/file',
NewCustomRenderer,
'./built-in/binary-expression'
]
}, [
'comment # test/some_test.js:1',
' ',
' $$ assert.ok(hoge === fuga, "comment") $$',
' ',
' --- [string] fuga',
' +++ [string] hoge',
' @@ -1,3 +1,3 @@',
' -bar',
' +foo',
' ',
' '
]);
})();
rendererCustomizationTest('with exposed Renderer classes', {
renderers: [
createFormatter.renderers.FileRenderer,
createFormatter.renderers.AssertionRenderer,
createFormatter.renderers.DiagramRenderer,
createFormatter.renderers.BinaryExpressionRenderer
]
}, [
'comment # test/some_test.js:1',
' ',
' assert.ok(hoge === fuga, "comment")',
' | | | ',
' | | "bar" ',
' | false ',
' "foo" ',
' ',
' --- [string] fuga',
' +++ [string] hoge',
' @@ -1,3 +1,3 @@',
' -bar',
' +foo',
' ',
' '
]);
});
}));

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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