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

d3-dispatch

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-dispatch - npm Package Compare versions

Comparing version 0.2.1 to 0.2.2

build/dispatch.cjs.js

10

build/dispatch.js

@@ -7,2 +7,6 @@ (function (global, factory) {

function dispatch() {
return new Dispatch(arguments);
}
function Dispatch(types) {

@@ -94,10 +98,6 @@ var i = -1,

function dispatch() {
return new Dispatch(arguments);
}
dispatch.prototype = Dispatch.prototype;
dispatch.prototype = Dispatch.prototype; // allow instanceof
exports.dispatch = dispatch;
}));

@@ -1,1 +0,1 @@

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.dispatch={})}(this,function(e){"use strict";function n(e){function n(e){var n=(e+="").indexOf("."),t=e;if(n>=0?e=e.slice(0,n):t+=".",e&&!u.hasOwnProperty(e))throw new Error("unknown type: "+e);return{type:e,name:t}}function t(e){return function(){for(var n,t,r=u[e],i=-1,o=r.length;++i<o;)(t=(n=r[i]).value)&&t.apply(this,arguments);return f}}var r,i=-1,o=e.length,u={},a={},f=this;for(f.on=function(e,t){if(e=n(e),arguments.length<2)return(t=a[e.name])&&t.value;if(e.type){var r,i=u[e.type],o=a[e.name];o&&(o.value=null,r=i.indexOf(o),u[e.type]=i=i.slice(0,r).concat(i.slice(r+1)),delete a[e.name]),t&&(t={value:t},a[e.name]=t,i.push(t))}else if(null==t)for(var l in u)if(t=a[l+e.name]){t.value=null;var i=u[l],r=i.indexOf(t);u[l]=i.slice(0,r).concat(i.slice(r+1)),delete a[t.name]}return f};++i<o;){if(r=e[i]+"",!r||r in f)throw new Error("illegal or duplicate type: "+r);u[r]=[],f[r]=t(r)}}function t(){return new n(arguments)}t.prototype=n.prototype,e.dispatch=t});
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.dispatch={})}(this,function(e){"use strict";function n(){return new t(arguments)}function t(e){function n(e){var n=(e+="").indexOf("."),t=e;if(n>=0?e=e.slice(0,n):t+=".",e&&!u.hasOwnProperty(e))throw new Error("unknown type: "+e);return{type:e,name:t}}function t(e){return function(){for(var n,t,r=u[e],i=-1,o=r.length;++i<o;)(t=(n=r[i]).value)&&t.apply(this,arguments);return f}}var r,i=-1,o=e.length,u={},a={},f=this;for(f.on=function(e,t){if(e=n(e),arguments.length<2)return(t=a[e.name])&&t.value;if(e.type){var r,i=u[e.type],o=a[e.name];o&&(o.value=null,r=i.indexOf(o),u[e.type]=i=i.slice(0,r).concat(i.slice(r+1)),delete a[e.name]),t&&(t={value:t},a[e.name]=t,i.push(t))}else if(null==t)for(var l in u)if(t=a[l+e.name]){t.value=null;var i=u[l],r=i.indexOf(t);u[l]=i.slice(0,r).concat(i.slice(r+1)),delete a[t.name]}return f};++i<o;){if(r=e[i]+"",!r||r in f)throw new Error("illegal or duplicate type: "+r);u[r]=[],f[r]=t(r)}}n.prototype=t.prototype,e.dispatch=n});
{
"name": "d3-dispatch",
"version": "0.2.1",
"version": "0.2.2",
"description": "Register named callbacks and call them with arguments.",

@@ -24,12 +24,12 @@ "keywords": [

"scripts": {
"pretest": "mkdir -p build && d3-bundler --format=umd --name=dispatch -- index.js > build/dispatch.js",
"pretest": "mkdir -p build && d3-bundler -x -f cjs -o build/dispatch.cjs.js",
"test": "faucet `find test -name '*-test.js'`",
"prepublish": "npm run test && uglifyjs build/dispatch.js -c -m -o build/dispatch.min.js && rm -f build/dispatch.zip && zip -j build/dispatch.zip -- LICENSE README.md build/dispatch.js build/dispatch.min.js"
"prepublish": "npm run test && d3-bundler -n dispatch -o build/dispatch.js && uglifyjs build/dispatch.js -c -m -o build/dispatch.min.js && rm -f build/dispatch.zip && zip -j build/dispatch.zip -- LICENSE README.md build/dispatch.js build/dispatch.min.js"
},
"devDependencies": {
"d3-bundler": "~0.2.5",
"d3-bundler": "~0.4.0",
"faucet": "0.0",
"tape": "4",
"uglifyjs": "2"
"uglify-js": "2"
}
}

@@ -5,20 +5,6 @@ # d3-dispatch

[![dispatching events](http://bl.ocks.org/mbostock/raw/5872848/thumbnail.png)](http://bl.ocks.org/mbostock/5872848)
For example, if you create a dispatch `d` for `"start"` and `"end"` callbacks:
Changes from D3 3.x:
* It is now an error to attempt to register a callback type that: conflicts with a built-in property on all objects, such as `__proto__` or `hasOwnProperty`; conflicts with a built-in method on dispatch (e.g., `on`); conflicts with another type on the same dispatch (e.g., `dispatch("foo", "foo")`); is the empty string.
* The exposed [*dispatch*.*type*](#type) field is now strictly a method for invoking callbacks. Use `dispatch.on(type, …)` to get or set callbacks, rather than `dispatch[type].on(…)`.
* The `instanceof` operator now works as expected with dispatch objects.
<a name="dispatch" href="#dispatch">#</a> <b>dispatch</b>(<i>types…</i>)
Creates a new dispatch object for the specified *types*. Each *type* is a string representing the name of a callback type, such as `"zoom"` or `"change"`; for each type, a method is exposed on the returned dispatch object for invoking the callbacks of that type.
For example, if you create a dispatch for `"start"` and `"end"` callbacks:
```js
var dispatcher = dispatch("start", "end");
var d = dispatch("start", "end");
```

@@ -29,13 +15,25 @@

```js
dispatcher.on("start", callback1);
dispatcher.on("start.foo", callback2);
dispatcher.on("end", callback3);
d.on("start", callback1);
d.on("start.foo", callback2);
d.on("end", callback3);
```
Lastly, you can invoke any `"start"` callbacks using [*dispatch*.*type*](#type):
Then, you can invoke the `"start"` callbacks using [*dispatch*.*type*](#type):
```js
dispatcher.start("pass arguments to callbacks here");
d.start("pass arguments to callbacks here");
```
Want a more involved example? See how to use [d3-dispatch for coordinated views](http://bl.ocks.org/mbostock/5872848).
## Installing
If you use NPM, `npm install d3-dispatch`. Otherwise, download the [latest release](https://github.com/d3/d3-dispatch/releases/latest).
## API Reference
<a name="dispatch" href="#dispatch">#</a> <b>dispatch</b>(<i>types…</i>)
Creates a new dispatch object for the specified *types*. Each *type* is a string representing the name of a callback type, such as `"zoom"` or `"change"`; for each type, a method is exposed on the returned dispatch object for invoking the callbacks of that type.
<a name="on" href="#on">#</a> *dispatch*.<b>on</b>(<i>type</i>[, <i>callback</i>])

@@ -62,1 +60,9 @@

You can pass whatever arguments you want to callbacks; most commonly, you might create an object that represents an event, or pass the current datum (*d*) and index (*i*). See [function.call](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/Call) and [function.apply](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/Apply) for further information.
## Changes from D3 3.x:
* It is now an error to attempt to register a callback type that: conflicts with a built-in property on all objects, such as `__proto__` or `hasOwnProperty`; conflicts with a built-in method on dispatch (e.g., `on`); conflicts with another type on the same dispatch (e.g., `dispatch("foo", "foo")`); is the empty string.
* The exposed [*dispatch*.*type*](#type) field is now strictly a method for invoking callbacks. Use `dispatch.on(type, …)` to get or set callbacks, rather than `dispatch[type].on(…)`.
* The `instanceof` operator now works as expected with dispatch objects.
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