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

power-assert-renderer-assertion

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

power-assert-renderer-assertion - npm Package Compare versions

Comparing version 1.0.7 to 1.1.0

37

index.js
'use strict';
var BaseRenderer = require('power-assert-renderer-base');
var stringWidth = require('power-assert-util-string-width');
var inherits = require('util').inherits;

@@ -12,2 +13,3 @@

AssertionRenderer.prototype.onStart = function (context) {
this.context = context;
this.assertionLine = context.source.content;

@@ -19,4 +21,39 @@ };

this.write(this.assertionLine);
var e = this.context.source.error;
if (e && e instanceof SyntaxError) {
var re = /Unexpected token \(1\:(\d+)\)/;
var matchResult = re.exec(e.message);
if (matchResult) {
var syntaxErrorIndex = Number(matchResult[1]);
this.renderValueAt(syntaxErrorIndex, '?');
this.renderValueAt(syntaxErrorIndex, '?');
this.renderValueAt(syntaxErrorIndex, e.toString());
this.renderValueAt(0, '');
this.renderValueAt(0, 'If you are using `babel-plugin-espower` and want to use experimental syntax in your assert(), you should set `embedAst` option to true.');
this.renderValueAt(0, 'see: https://github.com/power-assert-js/babel-plugin-espower#optionsembedast');
}
}
};
AssertionRenderer.prototype.renderValueAt = function (idx, str) {
var row = createRow(stringWidth(this.assertionLine), ' ');
replaceColumn(idx, row, str);
this.write(row.join(''));
};
function replaceColumn (columnIndex, row, str) {
var i, width = stringWidth(str);
for (i = 0; i < width; i += 1) {
row.splice(columnIndex + i, 1, str.charAt(i));
}
}
function createRow (numCols, initial) {
var row = [], i;
for(i = 0; i < numCols; i += 1) {
row[i] = initial;
}
return row;
}
module.exports = AssertionRenderer;

8

package.json
{
"name": "power-assert-renderer-assertion",
"description": "assertion renderer for power-assert context",
"version": "1.0.7",
"version": "1.1.0",
"author": {

@@ -14,6 +14,8 @@ "name": "Takuto Wada",

"dependencies": {
"power-assert-renderer-base": "^1.0.7"
"power-assert-renderer-base": "^1.1.0",
"power-assert-util-string-width": "^1.1.0"
},
"devDependencies": {
"mocha": "^2.4.5"
"mocha": "^2.4.5",
"power-assert-context-reducer-ast": "^1.1.0"
},

@@ -20,0 +22,0 @@ "files": [

@@ -49,3 +49,3 @@ [![power-assert][power-assert-banner]][power-assert-url]

[license-url]: http://twada.mit-license.org/
[license-url]: https://github.com/twada/power-assert-runtime/blob/master/LICENSE
[license-image]: https://img.shields.io/badge/license-MIT-brightgreen.svg
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