Socket
Socket
Sign inDemoInstall

empower-core

Package Overview
Dependencies
3
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    empower-core

Power Assert feature enhancer for assert function/object


Version published
Maintainers
1
Install size
1.30 MB
Created

Changelog

Source

0.1.0 (2016-04-07)

Features
  • initial release

Readme

Source

empower-core

Build Status NPM package Bower package Dependency Status Coverage Status Code Climate License Built with Gulp

Power Assert feature enhancer for assert function/object.

DESCRIPTION

empower-core is a core module of power-assert family. empower-core enhances standard assert function or any assert-like object to work with power-assert feature added code instrumented by espower.

empower-core works with standard assert function (best fit with Mocha), and also supports assert-like objects/functions provided by various testing frameworks such as QUnit, buster.js, and nodeunit.

Pull-requests, issue reports and patches are always welcomed. See power-assert project for more documentation.

CHANGELOG

See CHANGELOG

API

var enhancedAssert = empowerCore(originalAssert, [options])

return type
function or object

empower-core function takes function or object(originalAssert) then returns PowerAssert feature added function/object based on originalAssert. If destructive option is falsy, originalAssert will be unchanged. If destructive option is truthy, originalAssert will be manipulated directly and returned enhancedAssert will be the same instance of originalAssert.

originalAssert
typedefault value
function or objectN/A

originalAssert is an instance of standard assert function or any assert-like object. see SUPPORTED ASSERTION LIBRARIES and ASSERTION LIBRARIES KNOWN TO WORK section. Be careful that originalAssert will be manipulated directly if destructive option is truthy.

options
typedefault value
object(return value of empowerCore.defaultOptions())

Configuration options. If not passed, default options will be used.

options.destructive
typedefault value
booleanfalse

If truthy, modify originalAssert destructively.

If false, empower-core mimics originalAssert as new object/function, so originalAssert will not be changed. If true, originalAssert will be manipulated directly and returned enhancedAssert will be the same instance of originalAssert.

options.onError
typedefault value
function(function defined in empowerCore.defaultOptions())

TBD

options.onSuccess
typedefault value
function(function defined in empowerCore.defaultOptions())

TBD

options.modifyMessageBeforeAssert
typedefault value
functionN/A

TBD

options.patterns
typedefault value
Array of stringobjects shown below
[
    'assert(value, [message])',
    'assert.ok(value, [message])',
    'assert.equal(actual, expected, [message])',
    'assert.notEqual(actual, expected, [message])',
    'assert.strictEqual(actual, expected, [message])',
    'assert.notStrictEqual(actual, expected, [message])',
    'assert.deepEqual(actual, expected, [message])',
    'assert.notDeepEqual(actual, expected, [message])',
    'assert.deepStrictEqual(actual, expected, [message])',
    'assert.notDeepStrictEqual(actual, expected, [message])'
]

Target patterns for power assert feature instrumentation.

Pattern detection is done by call-signature. Any arguments enclosed in bracket (for example, [message]) means optional parameters. Without bracket means mandatory parameters.

var options = empowerCore.defaultOptions();

Returns default options object for empowerCore function. In other words, returns

{
    destructive: false,
    onError: onError,
    onSuccess: onSuccess,
    patterns: [
        'assert(value, [message])',
        'assert.ok(value, [message])',
        'assert.equal(actual, expected, [message])',
        'assert.notEqual(actual, expected, [message])',
        'assert.strictEqual(actual, expected, [message])',
        'assert.notStrictEqual(actual, expected, [message])',
        'assert.deepEqual(actual, expected, [message])',
        'assert.notDeepEqual(actual, expected, [message])',
        'assert.deepStrictEqual(actual, expected, [message])',
        'assert.notDeepStrictEqual(actual, expected, [message])'
    ]
}

with sensible default for onError and onSuccess

function onError (errorEvent) {
    var e = errorEvent.error;
    if (errorEvent.powerAssertContext && e.name === 'AssertionError') {
        e.powerAssertContext = errorEvent.powerAssertContext;
    }
    throw e;
}

function onSuccess(successEvent) {
    return successEvent.returnValue;
}

SUPPORTED ASSERTION LIBRARIES

ASSERTION LIBRARIES KNOWN TO WORK

INSTALL

via npm

Install

$ npm install --save-dev empower-core
use empower-core npm module on browser

empowerCore function is exported

<script type="text/javascript" src="./path/to/node_modules/empower-core/build/empower-core.js"></script>

via bower

Install

$ bower install --save-dev empower-core

Then load (empowerCore function is exported)

<script type="text/javascript" src="./path/to/bower_components/empower-core/build/empower-core.js"></script>

AUTHOR

CONTRIBUTORS

LICENSE

Licensed under the MIT license.

Keywords

FAQs

Last updated on 30 Nov 2015

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc