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 - npm Package Compare versions

Comparing version 2.4.0 to 2.5.0

4

dist/core.js

@@ -21,4 +21,2 @@ "use strict";

var _debug = require("./debug");
var _op = require("./op");

@@ -80,4 +78,2 @@

}
(0, _debug.debug)(this);
}

@@ -84,0 +80,0 @@

// Helpers
import { emitTypes } from "./build"
import { contextComposer } from "./context"
import { debug } from "./debug"
import { opBase } from "./op"

@@ -34,4 +33,2 @@

}
debug(this)
}

@@ -38,0 +35,0 @@

4

package.json

@@ -15,4 +15,4 @@ {

],
"version": "2.4.0",
"description": "Build beautiful and extensible eventing APIs",
"version": "2.5.0",
"description": "Powerful event emitter",
"keywords": [

@@ -19,0 +19,0 @@ "props",

# dot-event
Build beautiful and extensible eventing APIs.
Powerful event emitter.

@@ -20,6 +20,8 @@ ![dot event](dot.gif)

```js
import Events from "dot-event"
const events = new Events()
import dotEvent from "dot-event"
events.on(() => {})
const events = dotEvent()
events.on(() => {
/* do something */
})
events.emit()

@@ -39,6 +41,6 @@ ```

Identify subscriptions by dot-prop string:
Use dot-props to maintain distinct subscriptions:
```js
events.on("hello.world", () => {})
events.on("emit.hello.world", () => {})
events.emit("hello.world") // emits

@@ -51,3 +53,3 @@ events.emit() // doesn't emit

```js
events.onAny("hello", () => {})
events.onAny("emit.hello", () => {})
events.emit("hello") // emits

@@ -58,9 +60,37 @@ events.emit("hello.world") // emits

## Operations
Why do we have to specify `emit` before the the prop in this example?
```js
events.on("emit.hello", () => {})
events.emit("hello")
```
Because `emit` is an "operation", and you can have more than one.
First, define the operation:
```js
events.setOp("create")
```
Then use it:
```js
events.on("create", () => {})
events.create() // emits the create operation
```
Operation functions take the same arguments and behave similar to `emit`.
## Subscription listener argument
Subscription listeners receive a single object argument. To add to that object, use the `withOptions` function on emit:
Subscription listeners receive a single object argument. To add to that object, pass an object to the emitter:
```js
events.on(({ hello }) => {})
events.withOptions({ hello: "world" }).emit()
events.on(({ hello }) => {
/* hello === "world" */
})
events.emit({ hello: "world" })
```

@@ -84,13 +114,2 @@

## Operation
An "operation" is a way to namespace your events and make a custom emitter function:
```js
events.withOp("create").on(() => {})
events.create() // emits
```
Operation functions take the same arguments and behave similar to `emit`.
## Prepositions (before or after)

@@ -101,5 +120,11 @@

```js
events.before().on(() => {})
events.on(() => {})
events.after().on(() => {})
events.on("before", () => {
/* 1 */
})
events.on(() => {
/* 2 */
})
events.on("after", () => {
/* 3 */
})
events.emit()

@@ -125,3 +150,3 @@ ```

```js
events.onAny("hello", () => {})
events.onAny("emit.hello", () => {})
events.emit("hello") // emits

@@ -148,3 +173,3 @@ events.emit("hello.world") // emits

events.emit("hello.world")
events.onAnyEmitted("hello", () => {}) // emits immediately
events.onAnyEmitted("emit.hello", () => {}) // emits immediately
events.emit("hello.world") // emits

@@ -177,3 +202,3 @@ events.emit() // doesn't emit

```js
events.onceAny("hello", () => {})
events.onceAny("emit.hello", () => {})
events.emit("hello.world") // emits

@@ -189,3 +214,3 @@ events.emit("hello.world") // doesn't emit

events.emit("hello.world")
events.onceAnyEmitted("hello", () => {}) // emits immediately
events.onceAnyEmitted("emit.hello", () => {}) // emits immediately
events.emit("hello.world") // doesn't emit

@@ -200,4 +225,4 @@ ```

events.on({
hello: () => {},
"hello.world": () => {},
"emit.hello": () => {},
"emit.hello.world": () => {},
})

@@ -204,0 +229,0 @@ ```

Sorry, the diff of this file is not supported yet

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