d3-dispatch
Advanced tools
Comparing version 0.0.0 to 0.0.1
136
index.js
@@ -1,133 +0,3 @@ | ||
(function() { | ||
!function() { | ||
var d3 = { | ||
version: "3.4.4" | ||
}; | ||
function d3_class(ctor, properties) { | ||
try { | ||
for (var key in properties) { | ||
Object.defineProperty(ctor.prototype, key, { | ||
value: properties[key], | ||
enumerable: false | ||
}); | ||
} | ||
} catch (e) { | ||
ctor.prototype = properties; | ||
} | ||
} | ||
d3.map = function(object) { | ||
var map = new d3_Map(); | ||
if (object instanceof d3_Map) object.forEach(function(key, value) { | ||
map.set(key, value); | ||
}); else for (var key in object) map.set(key, object[key]); | ||
return map; | ||
}; | ||
function d3_Map() {} | ||
d3_class(d3_Map, { | ||
has: d3_map_has, | ||
get: function(key) { | ||
return this[d3_map_prefix + key]; | ||
}, | ||
set: function(key, value) { | ||
return this[d3_map_prefix + key] = value; | ||
}, | ||
remove: d3_map_remove, | ||
keys: d3_map_keys, | ||
values: function() { | ||
var values = []; | ||
this.forEach(function(key, value) { | ||
values.push(value); | ||
}); | ||
return values; | ||
}, | ||
entries: function() { | ||
var entries = []; | ||
this.forEach(function(key, value) { | ||
entries.push({ | ||
key: key, | ||
value: value | ||
}); | ||
}); | ||
return entries; | ||
}, | ||
size: d3_map_size, | ||
empty: d3_map_empty, | ||
forEach: function(f) { | ||
for (var key in this) if (key.charCodeAt(0) === d3_map_prefixCode) f.call(this, key.substring(1), this[key]); | ||
} | ||
}); | ||
var d3_map_prefix = "\x00", d3_map_prefixCode = d3_map_prefix.charCodeAt(0); | ||
function d3_map_has(key) { | ||
return d3_map_prefix + key in this; | ||
} | ||
function d3_map_remove(key) { | ||
key = d3_map_prefix + key; | ||
return key in this && delete this[key]; | ||
} | ||
function d3_map_keys() { | ||
var keys = []; | ||
this.forEach(function(key) { | ||
keys.push(key); | ||
}); | ||
return keys; | ||
} | ||
function d3_map_size() { | ||
var size = 0; | ||
for (var key in this) if (key.charCodeAt(0) === d3_map_prefixCode) ++size; | ||
return size; | ||
} | ||
function d3_map_empty() { | ||
for (var key in this) if (key.charCodeAt(0) === d3_map_prefixCode) return false; | ||
return true; | ||
} | ||
d3.dispatch = function() { | ||
var dispatch = new d3_dispatch(), i = -1, n = arguments.length; | ||
while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch); | ||
return dispatch; | ||
}; | ||
function d3_dispatch() {} | ||
d3_dispatch.prototype.on = function(type, listener) { | ||
var i = type.indexOf("."), name = ""; | ||
if (i >= 0) { | ||
name = type.substring(i + 1); | ||
type = type.substring(0, i); | ||
} | ||
if (type) return arguments.length < 2 ? this[type].on(name) : this[type].on(name, listener); | ||
if (arguments.length === 2) { | ||
if (listener == null) for (type in this) { | ||
if (this.hasOwnProperty(type)) this[type].on(name, null); | ||
} | ||
return this; | ||
} | ||
}; | ||
function d3_dispatch_event(dispatch) { | ||
var listeners = [], listenerByName = new d3_Map(); | ||
function event() { | ||
var z = listeners, i = -1, n = z.length, l; | ||
while (++i < n) if (l = z[i].on) l.apply(this, arguments); | ||
return dispatch; | ||
} | ||
event.on = function(name, listener) { | ||
var l = listenerByName.get(name), i; | ||
if (arguments.length < 2) return l && l.on; | ||
if (l) { | ||
l.on = null; | ||
listeners = listeners.slice(0, i = listeners.indexOf(l)).concat(listeners.slice(i + 1)); | ||
listenerByName.remove(name); | ||
} | ||
if (listener) listeners.push(listenerByName.set(name, { | ||
on: listener | ||
})); | ||
return dispatch; | ||
}; | ||
return event; | ||
} | ||
if (typeof define === "function" && define.amd) { | ||
define(d3); | ||
} else if (typeof module === "object" && module.exports) { | ||
module.exports = d3; | ||
} else { | ||
this.d3 = d3; | ||
} | ||
}(); | ||
})(); | ||
import dispatch from "./src/dispatch"; | ||
export default dispatch; |
{ | ||
"name": "d3-dispatch", | ||
"version": "0.0.0", | ||
"description": "The d3.dispatch function from d3", | ||
"main": "index.js", | ||
"scripts": { | ||
"build": "smash node_modules/d3/src/start.js node_modules/d3/src/event/dispatch.js node_modules/d3/src/end.js | uglifyjs - -b -indent-level=2 -o index.js", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"version": "0.0.1", | ||
"description": "Register named callbacks and call them with arguments.", | ||
"keywords": [ | ||
"d3", | ||
"event", | ||
"listener", | ||
"dispatch" | ||
], | ||
"homepage": "https://github.com/d3/d3-dispatch", | ||
"license" : "BSD-3-Clause", | ||
"author": { | ||
"name": "Mike Bostock", | ||
"url": "http://bost.ocks.org/mike" | ||
}, | ||
"main": "build/dispatch", | ||
"jsnext:main": "index", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/jfsiii/d3-dispatch.git" | ||
"url": "https://github.com/d3/d3-dispatch.git" | ||
}, | ||
"keywords": [ | ||
"d3" | ||
], | ||
"author": "JFSIII", | ||
"license": "ISC", | ||
"scripts": { | ||
"pretest": "mkdir -p build && d3-bundler --polyfill-map --format=umd --name=dispatch -- index.js > build/dispatch.js", | ||
"test": "faucet `find test -name '*-test.js'`", | ||
"prepublish": "npm run test && uglifyjs build/dispatch.js -c -m -o build/dispatch.min.js" | ||
}, | ||
"devDependencies": { | ||
"d3": "^3.4.4", | ||
"smash": "0.0.12", | ||
"uglify-js": "^2.4.13" | ||
"d3-bundler": "~0.2.5", | ||
"faucet": "0.0", | ||
"tape": "4", | ||
"uglifyjs": "2" | ||
} | ||
} | ||
} |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
No tests
QualityPackage does not have any tests. This is a strong signal of a poorly maintained or low quality package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
10169
8
169
1
0
6
4
2