Installations
npm install power-assert-formatter
Releases
Unable to fetch releases
Developer
power-assert-js
Developer Guide
Module System
CommonJS
Min. Node Version
Typescript Support
No
Node Version
6.2.2
NPM Version
3.9.5
Statistics
6 Stars
380 Commits
3 Forks
12 Watching
1 Branches
9 Contributors
Updated on 13 Aug 2018
Bundle Size
238.22 kB
Minified
71.64 kB
Minified + Gzipped
Languages
JavaScript (99.46%)
HTML (0.54%)
Total Downloads
Cumulative downloads
Total Downloads
62,505,249
Last day
-19.5%
22,446
Compared to previous day
Last week
7.4%
175,106
Compared to previous week
Last month
10.8%
640,782
Compared to previous month
Last year
-28.2%
6,559,534
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dependencies
7
Dev Dependencies
28
power-assert-formatter
Power Assert output formatter.
DESCRIPTION
power-assert-formatter
is a formatter module for Power Assert output.
Pull-requests, issue reports and patches are always welcomed. See power-assert project for more documentation.
CHANGELOG
See CHANGELOG
API
var createFormatter = require('power-assert-formatter');
return type |
---|
function |
Returns creator function for power-assert.
var formatter = createFormatter([options]);
return type |
---|
function |
Create formatter function with options. options
argument is optional.
options
type | default value |
---|---|
object | (return value of createFormatter.defaultOptions() ) |
Configuration options. If not passed, default options will be used.
options.lineDiffThreshold
type | default value |
---|---|
number | 5 |
Threshold to show diff at character level or line level. If number of lines in target string is greater than lineDiffThreshold
, then line diff mode will be used to show diff output.
options.maxDepth
type | default value |
---|---|
number | 1 |
Depth of object traversal. If object depth is greater than maxDepth
, compound object (IOW, Array
or object
) will be pruned with #
like ["foo",#Array#,#Object#]
.
options.outputOffset
type | default value |
---|---|
number | 2 |
Number of spaces inserted at the left in power-assert output.
options.anonymous
type | default value |
---|---|
string | "Object" |
Type name to show when target object is created by anonymous constructor.
options.circular
type | default value |
---|---|
string | "#@Circular#" |
Name to show when target object is detected as circular structure.
options.lineSeparator
type | default value |
---|---|
string | "\n" |
Line separator in power assert output.
options.ambiguousEastAsianCharWidth
type | default value |
---|---|
number | 2 |
Width of 'Ambiguous' characters defined in Unicode Standard Annex #11 EAST ASIAN WIDTH. Configure options.ambiguousEastAsianCharWidth
to treat ambiguous east asian character as fullwidth (= 2
) or narrow (= 1
). Default is 2
.
options.widthOf
type | default value |
---|---|
function | string-width.js |
Function to calculate width of string.
options.stringify
type | default value |
---|---|
function | stringifier module |
Function to stringify any target value.
options.diff
type | default value |
---|---|
function | udiff.js |
Function to create diff string between two strings.
options.writerClass
type | default value |
---|---|
function | string-writer.js |
Constructor Function for output writer class.
options.renderers
type | default value |
---|---|
Array of (string or function ) | shown below |
1[ 2 './built-in/file', 3 './built-in/assertion', 4 './built-in/diagram', 5 './built-in/binary-expression' 6]
Output renderers. Power assert output is rendered by renderers in order. You can create custom renderer and add its constructor function to customize power-assert-output.
1[ 2 './built-in/file', 3 './built-in/assertion', 4 YourCustomRenderer, 5 './built-in/binary-expression' 6]
var options = createFormatter.defaultOptions();
Returns default options object for createFormatter function. In other words, returns
1{ 2 lineDiffThreshold: 5, 3 maxDepth: 1, 4 anonymous: 'Object', 5 circular: '#@Circular#', 6 lineSeparator: '\n', 7 ambiguousEastAsianCharWidth: 2, 8 renderers: [ 9 './built-in/file', 10 './built-in/assertion', 11 './built-in/diagram', 12 './built-in/binary-expression' 13 ] 14};
var formattedText = formatter(powerAssertContext);
return type |
---|
string |
Format powerAssertContext
into formattedText
. powerAssertContext
is an internal object structure, containing informations to render. Example of powerAssertContext
is:
1{ 2 source: { 3 content: "assert.equal(foo, bar)", 4 filepath: "/path/to/some_test.js", 5 line: 1 6 }, 7 args: [ 8 { 9 value: "foo", 10 events: [ 11 { 12 value: "foo", 13 espath: "arguments/0" 14 } 15 ] 16 }, 17 { 18 value: "bar", 19 events: [ 20 { 21 value: "bar", 22 espath: "arguments/1" 23 } 24 ] 25 } 26 ] 27}
Note that structure of powerAssertContext may change.
INSTALL
via npm
Install
$ npm install --save-dev power-assert-formatter
use power-assert-formatter npm module on browser
powerAssertFormatter
function is exported
<script type="text/javascript" src="./path/to/node_modules/power-assert-formatter/build/power-assert-formatter.js"></script>
via bower
Install
$ bower install --save-dev power-assert-formatter
Then load (powerAssertFormatter
function is exported)
<script type="text/javascript" src="./path/to/bower_components/power-assert-formatter/build/power-assert-formatter.js"></script>
AUTHOR
CONTRIBUTORS
LICENSE
Licensed under the MIT license.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: MIT-LICENSE.txt:0
- Info: FSF or OSI recognized license: MIT License: MIT-LICENSE.txt:0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/24 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 7 are checked with a SAST tool
Score
3
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More