Socket
Socket
Sign inDemoInstall

nanoevents

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nanoevents - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

3

CHANGELOG.md
# Change Log
This project adheres to [Semantic Versioning](http://semver.org/).
## 0.2
* Throw a error on non-function listener.
## 0.1
* Initial release.

41

index.js

@@ -22,3 +22,3 @@ /**

*/
function NanoEvents () {
module.exports = function NanoEvents () {
/**

@@ -32,6 +32,10 @@ * Event names in keys and arrays with listeners in values.

function add (events, event, cb) {
if (typeof cb !== 'function') {
throw new Error('Expected event listener to be a function')
}
var added = true
var listener = { fn: cb }
var l = { fn: cb }
listener.rm = function () {
l.rm = function () {
if (!added) return

@@ -41,3 +45,3 @@ added = false

if (list.length > 1) {
list.splice(list.indexOf(listener), 1)
list.splice(list.indexOf(l), 1)
} else {

@@ -49,19 +53,11 @@ delete events[event]

if (events[event]) {
events[event].push(listener)
events[event].push(l)
} else {
events[event] = [listener]
events[event] = [l]
}
return listener
return l
}
function run (l, args) {
var array = new Array(args.length - 1)
for (var i = 1; i < args.length; i++) {
array[i - 1] = args[i]
}
return l.fn.apply(this, array)
}
module.exports.prototype = {
NanoEvents.prototype = {
/**

@@ -122,4 +118,7 @@ * Add a listener for a given event.

var i
var rm = []
var args = new Array(arguments.length - 1)
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i]
}

@@ -129,8 +128,6 @@ for (i = 0; i < list.length; i++) {

if (l.once) rm.push(l)
run(l, arguments)
l.fn.apply(this, args)
}
for (i = 0; i < rm.length; i++) {
rm[i].rm()
}
for (i = 0; i < rm.length; i++) rm[i].rm()

@@ -141,3 +138,1 @@ return true

}
module.exports = NanoEvents
{
"name": "nanoevents",
"version": "0.1.0",
"version": "0.2.0",
"description": "Small and simple events API",

@@ -5,0 +5,0 @@ "keywords": [

@@ -6,3 +6,3 @@ # Nano Events

* No node.js [EventEmitter] compatibility.
* Only 923 bytes after Uglify.
* Only 921 bytes after Uglify.
* `on` and `once` methods return `unbind` function. You don’t need to save

@@ -9,0 +9,0 @@ callback to variable for `removeListener`.

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc