Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dot-event

Package Overview
Dependencies
Maintainers
1
Versions
85
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dot-event

Powerful event emitter

  • 3.0.16
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
91
increased by4450%
Maintainers
1
Weekly downloads
 
Created
Source

dot-event

Javascript event emitter, foundation of everything.

neutron star

Buzzwords

Dot-event produces code that is:

  • Asynchronous
  • Debuggable
  • Decoupled
  • Extensible
  • Testable

Story

One day, a dot instance was born:

dot = require("dot-event")()

Each time dot went into a composer, the composer added some functionality to it:

module.exports = function(dot) {
  dot.any("sayHi", function() {
    console.log("hi!")
  })
}

The user had an easy time composing their dot:

require("./hi")(dot)
require("./whatsUp")(dot)
require("./yo")(dot)

dot.sayHi()

Far away, a library author noticed the first argument behaves as expected...

dot.any("say", function(arg) {
  console.log("arg:", arg)
})

dot.say("yo") // arg: yo

But the second argument does not!

dot.any("say", function(arg, opts) {
  console.log("arg:", arg)
  console.log("opts:", opts)
})

dot.say("yo", "hello")
// arg: hello
// opts: { dot: <DotEvent>, ns: "say", prop: "yo", propArr: ["yo"] }

And adding even more arguments only added more props!

dot.say("sup", "yo", "hello")
// arg: hello
// opts: { dot: <DotEvent>, ns: "say", prop: "sup.yo", propArr: ["sup", "yo"] }

And thus their journey began...

End user guide

dot.someEvent("a.b.c", ["d", "e", "f"], { opt: true })
//  ^—— event ^—— prop ^—— prop         ^—— arg
  • The last argument (arg) may be of any type the event requires.
  • All arguments before the last are props. If a prop is not a String or Array.<String>, it is not included.

Author guide

dot.any("someEvent", function(arg, opts) {
  //    ^—— event             ^——  ^—— { dot, event, prop, propArr }
})
  • The first listener argument (arg) may be of any type the event requires.
  • The second argument is an object containing: the dot-event instance, an event name String, a prop String, and a prop Array.<String>.

Existing dot composers

LibraryDescriptionURL
argRun functions from CLI or webhttps://github.com/dot-event/arg
logLog functionshttps://github.com/dot-event/log2
storeImmutable storehttps://github.com/dot-event/store2

Keywords

FAQs

Package last updated on 12 Jan 2019

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc