UNPKG

d3-let

Version:

A small set of utilities for d3 plugins

1 lines 2.89 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.d3=t.d3||{})}(this,function(t){"use strict";var e=Object.getOwnPropertySymbols,r=Object.prototype.hasOwnProperty,n=Object.prototype.propertyIsEnumerable;var o=function(){try{if(!Object.assign)return!1;var t=new String("abc");if(t[5]="de","5"===Object.getOwnPropertyNames(t)[0])return!1;for(var e={},r=0;r<10;r++)e["_"+String.fromCharCode(r)]=r;if("0123456789"!==Object.getOwnPropertyNames(e).map(function(t){return e[t]}).join(""))return!1;var n={};return"abcdefghijklmnopqrst".split("").forEach(function(t){n[t]=t}),"abcdefghijklmnopqrst"===Object.keys(Object.assign({},n)).join("")}catch(t){return!1}}()?Object.assign:function(t,o){for(var i,c,s=function(t){if(null===t||void 0===t)throw new TypeError("Object.assign cannot be called with null or undefined");return Object(t)}(t),u=1;u<arguments.length;u++){i=Object(arguments[u]);for(var a in i)r.call(i,a)&&(s[a]=i[a]);if(e){c=e(i);for(var f=0;f<c.length;f++)n.call(i,c[f])&&(s[c[f]]=i[c[f]])}}return s},i=Object.prototype.toString,c="undefined"!=typeof window&&"[object Object]"!==i.call(window),s=c?window.console:console;function u(t){return"[object Object]"===i.call(t)}function a(t){return"[object Array]"===i.call(t)}function f(t){return"[object Error]"===i.call(t)}function l(){this._array=[]}function h(t,e){var r=new l;if(t instanceof l)t.each(function(t,e){r.set(e,t)});else if(Array.isArray(t)){var n,o=-1,i=t.length;if(null==e)for(;++o<i;)r.set(o,t[o]);else for(;++o<i;)r.set(e(n=t[o],o,t),n)}else if(t)for(var c in t)r.set(c,t[c]);return r}l.prototype=h.prototype={constructor:l,size:function(){return this._array.length},get:function(t){return this["$"+t]},set:function(t,e){return this.has(t)||this._array.push(t),this["$"+t]=e,this},has:function(t){return"$"+t in this},clear:function(){var t=this;this.each(function(e,r){delete t["$"+r]}),this._array.splice(0)},keys:function(){var t=[];return this.each(function(e,r){t.push(r)}),t},values:function(){var t=[];return this.each(function(e){t.push(e)}),t},each:function(t){for(var e,r=this._array,n=0;n<r.length;++n)e=r[n],t(this.get(e),e,n)}};t.assign=o,t.inBrowser=c,t.logger=s,t.pop=function(t,e){var r=void 0;if(u(t))return r=t[e],delete t[e],r;if(a(t)){var n=+e;return n==n?t.splice(n,1)[0]:(r=t[e],delete t[e],r)}},t.isObject=u,t.isString=function(t){return"[object String]"===i.call(t)},t.isFunction=function(t){return"[object Function]"===i.call(t)},t.isArray=a,t.isDate=function(t){return"[object Date]"===i.call(t)},t.isNumber=function(t){return"[object Number]"===i.call(t)},t.isError=f,t.isPromise=function(t){return"[object Promise]"===i.call(t)},t.resolvedPromise=function(t){return new Promise(function(e,r){f(t)?r(t):e(t)})},t.orderedMap=h,t.letVersion="0.4.0",Object.defineProperty(t,"__esModule",{value:!0})});