@nodeart/event_emitter
Advanced tools
Comparing version 1.1.0 to 1.2.0
{ | ||
"name": "@nodeart/event_emitter", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Simple EventEmitter pattern", | ||
"main": "./src/index.js", | ||
"main": "./index.js", | ||
"repository": { | ||
@@ -11,3 +11,2 @@ "type": "git", | ||
"scripts": { | ||
"start": "node ./src/index.js", | ||
"test": "node ./tests.js" | ||
@@ -14,0 +13,0 @@ }, |
@@ -0,0 +0,0 @@ [![bitHound Overall Score](https://www.bithound.io/github/NodeArt/EventEmitter/badges/score.svg)](https://www.bithound.io/github/NodeArt/EventEmitter) |
32
tests.js
@@ -7,8 +7,22 @@ /** | ||
const assert = require('assert'); | ||
const EventEmitter = require('./src/'); | ||
const EventEmitter = require('./'); | ||
const events = new EventEmitter(); | ||
const [extend, inherit] = [{}, {}]; | ||
// extend test | ||
assert.equal( | ||
Object.getPrototypeOf(EventEmitter.extend(extend)), | ||
Object.prototype, | ||
'Prototype should stay the same (Array.prototype)' | ||
); | ||
// inherit test | ||
assert.equal( | ||
Object.getPrototypeOf(EventEmitter.inherit(inherit)), | ||
EventEmitter.prototype, | ||
'Prototype should be EventEmitter prototype' | ||
); | ||
const ctx = { ctx : true }; | ||
events | ||
@@ -28,3 +42,3 @@ .once( | ||
assert.equal(Object.keys(events._events['event1']).length, 2, 'Once test error'); | ||
assert.equal(events._events.get('event1').length, 2, 'Once test error'); | ||
@@ -38,3 +52,3 @@ const fn = (...args) => assert.deepEqual(args, [1, 2, 3], 'Args test error'); | ||
assert.equal(events._events['event2'], undefined, 'Off test error'); | ||
assert.equal(events._events.get('event2'), undefined, 'Off test error'); | ||
@@ -45,2 +59,10 @@ events | ||
assert.deepEqual(events._events, {}, 'OffAll test error'); | ||
assert.deepEqual(events._events, new Map(), 'OffAll test error'); | ||
let counter = 0; | ||
events | ||
.times('event', 3, () => counter += 1) | ||
.emit('event') | ||
.emit('event') | ||
.emit('event'); | ||
assert.equal(counter, 3, 'Times test error'); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
8082
192