
Security News
MCP Steering Committee Launches Official MCP Registry in Preview
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.
power-assert-context-formatter
Advanced tools
Create function to format powerAssertContext
object provided by power-assert at runtime.
var createFormatter = require('power-assert-context-formatter');
var FileRenderer = require('power-assert-renderer-file');
var AssertionRenderer = require('power-assert-renderer-assertion');
var DiagramRenderer = require('power-assert-renderer-diagram');
var ComparisonRenderer = require('power-assert-renderer-comparison');
var format = createFormatter({
renderers: [
FileRenderer,
AssertionRenderer,
DiagramRenderer,
ComparisonRenderer
]
});
var assert = require('assert');
var foo = 'foo';
var bar = 'bar';
try {
assert(foo === bar);
} catch (e) {
var formattedText = format(e.powerAssertContext);
. . .
}
return type |
---|
function |
Returns creator function of formatter.
return type |
---|
function |
Create format function to format powerAssertContext
object provided by power-assert.
type | default value |
---|---|
Array of function or Array of object | null |
Array of constructor function of various Renderers.
Each Renderer is instantiated for each assertion and registered to ContextTraversal
.
Each renderer accepts its options via form of object literal.
var format = createFormatter({
renderers: [
{ ctor: FileRenderer },
{ ctor: AssertionRenderer },
{ ctor: DiagramRenderer, options: { maxDepth: 2 } },
{ ctor: ComparisonRenderer, options: { lineDiffThreshold: 3 } }
]
});
type | default value |
---|---|
Array of function | empty array |
Array of reducer function to be applied to powerAssertContext
.
type | default value |
---|---|
number | 2 |
Number of spaces inserted at the left in power-assert output.
type | default value |
---|---|
string | "\n" |
Line separator in power assert output.
type | default value |
---|---|
boolean | false |
When true
, new renderers and legacy renderer implementations can be used together.
return type |
---|
string |
Format powerAssertContext
into formattedText
. powerAssertContext
is an internal object structure, containing informations to render. Example of powerAssertContext
is:
{
source: {
content: 'assert(foo === bar)',
filepath: 'test/some_test.js',
line: 1,
ast: '### JSON representation of AST nodes ###',
tokens: '### JSON representation of AST tokens ###',
visitorKeys: '### JSON representation of AST visitor keys ###'
},
args: [
{
value: false,
events: [
{
value: "FOO",
espath: "arguments/0/left"
},
{
value: "BAR",
espath: "arguments/0/right"
},
{
value: false,
espath: "arguments/0"
}
]
}
]
}
$ npm install --save-dev power-assert-context-formatter
Licensed under the MIT license.
1.2.0 (2018-06-12)
empower-core
into monorepoFAQs
format power-assert context
The npm package power-assert-context-formatter receives a total of 237,412 weekly downloads. As such, power-assert-context-formatter popularity was classified as popular.
We found that power-assert-context-formatter demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.
Product
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.