assert-polyfill

an exterminate 'TypeError: undefined is not a function' you encounter in node-v0

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
assert-polyfill
300.0.07 years ago7 years agoMinified + gzip package size for assert-polyfill in KB

Readme

Assert polyfill

<img src="https://img.shields.io/npm/v/assert-polyfill.svg?style=flat-square">
<img src="http://img.shields.io/travis/59naga/assert-polyfill.svg?style=flat-square">
<img src="https://img.shields.io/codeclimate/github/59naga/assert-polyfill.svg?style=flat-square">
<img src="https://img.shields.io/codeclimate/coverage/github/59naga/assert-polyfill.svg?style=flat-square">
<img src="https://img.shields.io/gemnasium/59naga/assert-polyfill.svg?style=flat-square">

Installation

npm install assert-polyfill --save

Why?

NodeJS v0 deepStrictEqual/notDeepStrictEqual is unavailable.
var assert = require('power-assert');
assert.deepStrictEqual(['foo'], ['foo'])
// TypeError: undefined is not a function

assert.notDeepStrictEqual(['foo'], ['bar'])
// TypeError: undefined is not a function

if above function is undefined, assert-polyfill defines the polyfill functions.
require('assert-polyfill');
var assert = require('power-assert');
assert.deepStrictEqual(['foo'], ['foo']) // pass
assert.notDeepStrictEqual(['foo'], ['bar']) // pass

even if --require in mocha, it is similar.
mocha --require assert-polyfill

Development

Requirement global
  • NodeJS v0.12.13
  • Npm v2.15.0

git clone https://github.com/59naga/assert-polyfill
cd assert-polyfill
npm install

npm test

License

MIT