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

@zambezi/d3-utils

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@zambezi/d3-utils - npm Package Compare versions

Comparing version 3.0.0-2 to 3.0.0-3

.package.json.swo

418

dist/d3-utils.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-selection'), require('underscore')) :
typeof define === 'function' && define.amd ? define(['exports', 'd3-selection', 'underscore'], factory) :
(factory((global.d3Utils = global.d3Utils || {}),global.d3,global._));
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('d3-selection'), require('underscore')) :
typeof define === 'function' && define.amd ? define(['exports', 'd3-selection', 'underscore'], factory) :
(factory((global.d3Utils = global.d3Utils || {}),global.d3,global._));
}(this, function (exports,d3Selection,underscore) { 'use strict';
function appendFromTemplate(template) {
var div = document.createElement('div');
function appendFromTemplate(template) {
var div = document.createElement('div');
div.innerHTML = template;
div.innerHTML = template;
var prototype = div.firstChild;
var prototype = div.firstChild;
return function append(d, i) {
return this.appendChild(prototype.cloneNode(true));
};
}
return function append(d, i) {
return this.appendChild(prototype.cloneNode(true));
};
}
function appendIfMissing(tagAndClasses, initAttributes) {
function appendIfMissing(tagAndClasses, initAttributes) {
return function append(d, i) {
var target = d3Selection.select(this),
selection = target.select(tagAndClasses);
return function append(d, i) {
var target = d3Selection.select(this),
selection = target.select(tagAndClasses);
var elements = void 0,
classes = void 0,
tag = void 0,
element = void 0;
var elements = void 0,
classes = void 0,
tag = void 0,
element = void 0;
if (!selection.empty()) return selection.node();
if (!selection.empty()) return selection.node();
elements = tagAndClasses.split('.');
tag = _.first(elements);
classes = _.rest(elements);
elements = tagAndClasses.split('.');
tag = _.first(elements);
classes = _.rest(elements);
element = target.append(tag);
element = target.append(tag);
if (initAttributes) element.attr(initAttributes);
if (classes.length) element.classed(classes.join(' '), true);
if (initAttributes) element.attr(initAttributes);
if (classes.length) element.classed(classes.join(' '), true);
return element.node();
};
}
return element.node();
};
}
function call(component) {
return function call(s) {
return s.call(component);
};
}
function call(component) {
return function call(s) {
return s.call(component);
};
}
function createDispatchCustomEvent() {
var type = void 0,
canBubble = true,
cancelable = true,
detail = void 0;
function createDispatchCustomEvent() {
var type = void 0,
canBubble = true,
cancelable = true,
detail = void 0;
function dispatchCustomEvent(d, i) {
var evt = document.createEvent('CustomEvent');
evt.initCustomEvent(type, canBubble, cancelable, detail);
this.dispatchEvent(evt);
}
function dispatchCustomEvent(d, i) {
var evt = document.createEvent('CustomEvent');
evt.initCustomEvent(type, canBubble, cancelable, detail);
this.dispatchEvent(evt);
}
dispatchCustomEvent.type = function (value) {
if (!arguments.length) return type;
type = value;
return dispatchCustomEvent;
};
dispatchCustomEvent.type = function (value) {
if (!arguments.length) return type;
type = value;
return dispatchCustomEvent;
};
dispatchCustomEvent.canBubble = function (value) {
if (!arguments.length) return canBubble;
canBubble = value;
return dispatchCustomEvent;
};
dispatchCustomEvent.canBubble = function (value) {
if (!arguments.length) return canBubble;
canBubble = value;
return dispatchCustomEvent;
};
dispatchCustomEvent.cancelable = function (value) {
if (!arguments.length) return cancelable;
cancelable = value;
return dispatchCustomEvent;
};
dispatchCustomEvent.cancelable = function (value) {
if (!arguments.length) return cancelable;
cancelable = value;
return dispatchCustomEvent;
};
dispatchCustomEvent.detail = function (value) {
if (!arguments.length) return detail;
detail = value;
return dispatchCustomEvent;
};
dispatchCustomEvent.detail = function (value) {
if (!arguments.length) return detail;
detail = value;
return dispatchCustomEvent;
}
};
function each(c) {
return function each(s) {
return s.each(then);
function then() {
c.apply(this, arguments);
}
};
}
return dispatchCustomEvent;
}
function emptyIfFormat(predicate, fn, d) {
if (predicate(d)) return '';
return fn.apply(this, underscore.rest(underscore.rest(arguments)));
}
function each(c) {
return function each(s) {
return s.each(then);
function then() {
c.apply(this, arguments);
}
};
}
// to be used for wrapping normal formatters:
//
// format = _.wrap(d3.time.format('%x'), empty)
//
// will create a function that returns an empty string if the provided value
// is undefined. Otherwise it'll try to parse it using the d3 formatter.
function emptyIfFormat(predicate, fn, d) {
if (predicate(d)) return '';
return fn.apply(this, underscore.rest(underscore.rest(arguments)));
}
var emptyIfUndefinedFormat = underscore.partial(emptyIfFormat, underscore.isUndefined);
// to be used for wrapping normal formatters:
//
// format = _.wrap(d3.time.format('%x'), empty)
//
// will create a function that returns an empty string if the provided value
// is undefined. Otherwise it'll try to parse it using the d3 formatter.
function fromTarget(fn) {
return function handler() {
d3Selection.select(d3Selection.event.target).each(fn);
};
}
function fromDetail(fn) {
return function handler() {
fn.call(this, d3Selection.event.detail);
};
}
var emptyIfUndefinedFormat = underscore.partial(emptyIfFormat, underscore.isUndefined);
function rebind() {
var objects = [];
function fromTarget(fn) {
return function handler() {
d3Selection.select(d3Selection.event.target).each(fn);
};
}
function fromDetail(fn) {
return function handler() {
fn.call(this, d3Selection.event.detail);
};
}
function rebind(target) {
return objects.reduce(rebindForObject, target);
}
function rebind() {
var objects = [];
rebind.from = function (source) {
objects.push({ source: source, properties: underscore.rest(arguments) });
return rebind;
};
function rebind(target) {
return objects.reduce(rebindForObject, target);
}
rebind.from = function (source) {
objects.push({ source: source, properties: underscore.rest(arguments) });
return rebind;
};
function rebindForObject(target, current, index, array) {
return rebind;
var source = current.source;
current.properties.forEach(rebindProperty);
function rebindForObject(target, current, index, array) {
return target;
var source = current.source;
current.properties.forEach(rebindProperty);
function rebindProperty(name) {
var i = name.indexOf(':'),
same = !~i,
sourceName = same ? name : name.substring(0, i),
targetName = same ? name : name.substring(i + 1);
return target;
target[targetName] = r(target, source, source[sourceName]);
function rebindProperty(name) {
var i = name.indexOf(':'),
same = !~i,
sourceName = same ? name : name.substring(0, i),
targetName = same ? name : name.substring(i + 1);
function r(target, source, method) {
return function proxy() {
var value = method.apply(source, arguments);
return value === source ? target : value;
};
}
target[targetName] = r(target, source, source[sourceName]);
function r(target, source, method) {
return function proxy() {
var value = method.apply(source, arguments);
return value === source ? target : value;
};
}
}
}
}
var toConsumableArray = function (arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
var toConsumableArray = function (arr) {
if (Array.isArray(arr)) {
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i];
return arr2;
} else {
return Array.from(arr);
}
};
return arr2;
} else {
return Array.from(arr);
}
};
function redraw(component) {
return function run(s) {
var args = underscore.rest(arguments),
context = this;
function redraw(component) {
return function run(s) {
var args = underscore.rest(arguments),
context = this;
s.on('redraw.component-redraw', draw);
draw();
s.on('redraw.component-redraw', draw);
draw();
function draw() {
component.apply(context, [s].concat(toConsumableArray(args)));
}
};
}
function draw() {
component.apply(context, [s].concat(toConsumableArray(args)));
}
};
}
var dispatchRedraw = createDispatchCustomEvent().type('redraw');
var dispatchSizeDirty = createDispatchCustomEvent().type('size-dirty');
function createResize() {
var type = underscore.uniqueId('resize.resize_'),
w = d3Selection.select(window);
var dispatchRedraw = createDispatchCustomEvent().type('redraw');
var dispatchSizeDirty = createDispatchCustomEvent().type('size-dirty');
function createResize() {
var type = underscore.uniqueId('resize.resize_'),
w = d3Selection.select(window);
var wait = 300;
var wait = 300;
function resize(s) {
w.on(type, underscore.debounce(onWindowResize, wait));
function resize(s) {
w.on(type, underscore.debounce(onWindowResize, wait));
function onWindowResize() {
s.each(dispatchSizeDirty).each(dispatchRedraw);
}
function onWindowResize() {
s.each(dispatchSizeDirty).each(dispatchRedraw);
}
}
resize.wait = function (value) {
if (!arguments.length) return wait;
wait = value;
return resize;
};
resize.wait = function (value) {
if (!arguments.length) return wait;
wait = value;
return resize;
}
};
function selectionChanged() {
return resize;
}
var previousDataKey = underscore.uniqueId('__data-changed-');
function selectionChanged() {
var debug = false,
key = void 0;
var previousDataKey = underscore.uniqueId('__data-changed-');
function changed(d, i) {
var debug = false,
key = void 0;
if (!key) {
if (debug) console.debug('--(KEY UNDEFINED)--');
return this;
}
function changed(d, i) {
var oldKey = this[previousDataKey],
newKey = key.call(this, d, i);
if (!key) {
if (debug) console.debug('--(KEY UNDEFINED)--');
return this;
}
this[previousDataKey] = newKey;
var oldKey = this[previousDataKey],
newKey = key.call(this, d, i);
if (debug) console.debug('selection changed?', 'old:', oldKey, 'new:', newKey, newKey === oldKey ? '--(SAME)--' : '++(CHANGED)++');
this[previousDataKey] = newKey;
return oldKey === newKey ? null : this;
}
if (debug) console.debug('selection changed?', 'old:', oldKey, 'new:', newKey, newKey === oldKey ? '--(SAME)--' : '++(CHANGED)++');
changed.debug = function (value) {
if (!arguments.length) return debug;
debug = value;
return changed;
};
return oldKey === newKey ? null : this;
}
changed.key = function (value) {
if (!arguments.length) return key;
key = value;
return changed;
};
changed.debug = function (value) {
if (!arguments.length) return debug;
debug = value;
return changed;
};
changed.key = function (value) {
if (!arguments.length) return key;
key = value;
return changed;
}
};
function throttle$1(component) {
var wait = arguments.length <= 1 || arguments[1] === undefined ? 150 : arguments[1];
return changed;
}
var throttled = underscore.throttle(execute, wait);
return function run(s) {
var args = underscore.rest(arguments),
context = this;
function throttle$1(component) {
var wait = arguments.length <= 1 || arguments[1] === undefined ? 150 : arguments[1];
throttled.apply(context, [s].concat(toConsumableArray(args)));
};
var throttled = underscore.throttle(execute, wait);
return function run(s) {
var args = underscore.rest(arguments),
context = this;
function execute() {
component.apply(this, arguments);
}
throttled.apply(context, [s].concat(toConsumableArray(args)));
};
function execute() {
component.apply(this, arguments);
}
}
exports.appendFromTemplate = appendFromTemplate;
exports.appendIfMissing = appendIfMissing;
exports.call = call;
exports.createDispatchCustomEvent = createDispatchCustomEvent;
exports.each = each;
exports.emptyIfFormat = emptyIfFormat;
exports.emptyIfUndefinedFormat = emptyIfUndefinedFormat;
exports.fromDetail = fromDetail;
exports.fromTarget = fromTarget;
exports.rebind = rebind;
exports.redraw = redraw;
exports.createResize = createResize;
exports.selectionChanged = selectionChanged;
exports.throttle = throttle$1;
exports.appendFromTemplate = appendFromTemplate;
exports.appendIfMissing = appendIfMissing;
exports.call = call;
exports.createDispatchCustomEvent = createDispatchCustomEvent;
exports.each = each;
exports.emptyIfFormat = emptyIfFormat;
exports.emptyIfUndefinedFormat = emptyIfUndefinedFormat;
exports.fromDetail = fromDetail;
exports.fromTarget = fromTarget;
exports.rebind = rebind;
exports.redraw = redraw;
exports.createResize = createResize;
exports.selectionChanged = selectionChanged;
exports.throttle = throttle$1;
Object.defineProperty(exports, '__esModule', { value: true });
}));
//# sourceMappingURL=d3-utils.js.map
{
"name": "@zambezi/d3-utils",
"version": "3.0.0-2",
"version": "3.0.0-3",
"description": "Common utility functions to use with d3",

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

@@ -0,0 +0,0 @@ # d3-utils

@@ -0,0 +0,0 @@ import babel from 'rollup-plugin-babel'

@@ -0,0 +0,0 @@ import { select } from 'd3-selection'

@@ -0,0 +0,0 @@ export function call(component) {

@@ -0,0 +0,0 @@ export function createDispatchCustomEvent() {

@@ -0,0 +0,0 @@ export function each(c) {

@@ -0,0 +0,0 @@ // to be used for wrapping normal formatters:

@@ -0,0 +0,0 @@ import { emptyIfFormat } from './empty-if-format'

@@ -0,0 +0,0 @@ import { select, event } from 'd3-selection'

@@ -0,0 +0,0 @@ export { appendFromTemplate } from './append-from-template'

@@ -0,0 +0,0 @@ import { rest } from 'underscore'

@@ -0,0 +0,0 @@ import { rest } from 'underscore'

@@ -0,0 +0,0 @@ import { uniqueId } from 'underscore'

@@ -0,0 +0,0 @@ import { rest, throttle as thr } from 'underscore'

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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