forked from d3/d3.github.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
d3-collection.v0.1.min.js
1 lines (1 loc) · 2.65 KB
/
d3-collection.v0.1.min.js
1
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(n.d3_collection=n.d3_collection||{})}(this,function(n){"use strict";function t(){}function e(n,e){var r=new t;if(n instanceof t)n.each(function(n,t){r.set(t,n)});else if(Array.isArray(n)){var i,u=-1,o=n.length;if(null==e)for(;++u<o;)r.set(u,n[u]);else for(;++u<o;)r.set(e(i=n[u],u,n),i)}else if(n)for(var s in n)r.set(s,n[s]);return r}function r(){function n(t,i,u,o){if(i>=a.length)return f?f(t):r?t.sort(r):t;for(var s,c,h,v=-1,l=t.length,p=a[i++],y=e(),d=u();++v<l;)(h=y.get(s=p(c=t[v])+""))?h.push(c):y.set(s,[c]);return y.each(function(t,e){o(d,e,n(t,i,u,o))}),d}function t(n,e){if(e>=a.length)return n;var r=[],i=h[e++];return n.each(function(n,i){r.push({key:i,values:t(n,e)})}),i?r.sort(function(n,t){return i(n.key,t.key)}):r}var r,f,c,a=[],h=[];return c={object:function(t){return n(t,0,i,u)},map:function(t){return n(t,0,o,s)},entries:function(e){return t(n(e,0,o,s),0)},key:function(n){return a.push(n),c},sortKeys:function(n){return h[a.length-1]=n,c},sortValues:function(n){return r=n,c},rollup:function(n){return f=n,c}}}function i(){return{}}function u(n,t,e){n[t]=e}function o(){return e()}function s(n,t,e){n.set(t,e)}function f(){}function c(n,t){var e=new f;if(n instanceof f)n.each(function(n){e.add(n)});else if(n){var r=-1,i=n.length;if(null==t)for(;++r<i;)e.add(n[r]);else for(;++r<i;)e.add(t(n[r],r,n))}return e}function a(n){var t=[];for(var e in n)t.push(e);return t}function h(n){var t=[];for(var e in n)t.push(n[e]);return t}function v(n){var t=[];for(var e in n)t.push({key:e,value:n[e]});return t}var l="$";t.prototype=e.prototype={constructor:t,has:function(n){return l+n in this},get:function(n){return this[l+n]},set:function(n,t){return this[l+n]=t,this},remove:function(n){var t=l+n;return t in this&&delete this[t]},clear:function(){for(var n in this)n[0]===l&&delete this[n]},keys:function(){var n=[];for(var t in this)t[0]===l&&n.push(t.slice(1));return n},values:function(){var n=[];for(var t in this)t[0]===l&&n.push(this[t]);return n},entries:function(){var n=[];for(var t in this)t[0]===l&&n.push({key:t.slice(1),value:this[t]});return n},size:function(){var n=0;for(var t in this)t[0]===l&&++n;return n},empty:function(){for(var n in this)if(n[0]===l)return!1;return!0},each:function(n){for(var t in this)t[0]===l&&n(this[t],t.slice(1),this)}};var p=e.prototype;f.prototype=c.prototype={constructor:f,has:p.has,add:function(n){return n+="",this[l+n]=n,this},remove:p.remove,clear:p.clear,values:p.keys,size:p.size,empty:p.empty,each:p.each};var y="0.1.2";n.version=y,n.nest=r,n.set=c,n.map=e,n.keys=a,n.values=h,n.entries=v});