Comparing version 1.0.2 to 1.1.0
@@ -179,2 +179,68 @@ (function (global, factory) { | ||
var NULL = {}; | ||
var fastmap = function(input) { | ||
var obj = {}, | ||
map, | ||
test; | ||
function has(key) { | ||
return obj.hasOwnProperty(key) && obj[key] !== NULL; | ||
} | ||
map = { | ||
size: 0, | ||
empty: 0, | ||
object: obj, | ||
has: has, | ||
get: function(key) { | ||
return has(key) ? obj[key] : undefined; | ||
}, | ||
set: function(key, value) { | ||
if (!has(key)) { | ||
++map.size; | ||
if (obj[key] === NULL) --map.empty; | ||
} | ||
obj[key] = value; | ||
return this; | ||
}, | ||
delete: function(key) { | ||
if (has(key)) { | ||
--map.size; | ||
++map.empty; | ||
obj[key] = NULL; | ||
} | ||
return this; | ||
}, | ||
clear: function() { | ||
map.size = map.empty = 0; | ||
map.object = obj = {}; | ||
}, | ||
test: function(_) { | ||
return arguments.length ? (test = _, map) : test; | ||
}, | ||
clean: function() { | ||
var next = {}, | ||
size = 0, | ||
key, value; | ||
for (key in obj) { | ||
value = obj[key]; | ||
if (value !== NULL && (!test || !test(value))) { | ||
next[key] = value; | ||
++size; | ||
} | ||
} | ||
map.size = size; | ||
map.empty = 0; | ||
map.object = (obj = next); | ||
} | ||
}; | ||
if (input) Object.keys(input).forEach(function(key) { | ||
map.set(key, input[key]); | ||
}); | ||
return map; | ||
} | ||
var inherits = function(child, parent) { | ||
@@ -299,2 +365,3 @@ var proto = (child.prototype = Object.create(parent.prototype)); | ||
exports.extentIndex = extentIndex; | ||
exports.fastmap = fastmap; | ||
exports.field = field; | ||
@@ -301,0 +368,0 @@ exports.inherits = inherits; |
@@ -1,1 +0,1 @@ | ||
!function(n,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(n.vega=n.vega||{})}(this,function(n){"use strict";function r(n){return null==n?null:n.fname}function t(n){return null==n?null:n.fields}function e(n){return"["!==n[0]?n:"'"!==n[1]&&'"'!==n[1]?n.slice(1,-1):n.slice(2,-2).replace(/\\(["'])/g,"$1")}function u(n){return f(n)?"["+n.map(u)+"]":l(n)||a(n)?JSON.stringify(n).replace("\u2028","\\u2028").replace("\u2029","\\u2029"):n}function o(n,r,t){var e=[r].concat([].slice.call(t));console[n].apply(console,e)}var i=function(n,r,t){return n.fields=r||[],n.fname=t,n},c=function(n){return String(n).match(/\[(.*?)\]|[^.\[]+/g).map(e)},f=Array.isArray,l=function(n){return n===Object(n)},a=function(n){return"string"==typeof n},s=function(n,r){var t=c(n).map(u),e=Function("_","return _["+t.join("][")+"];");return i(e,[n],r||n)},v=[],p=s("id"),g=i(function(n){return n},v,"identity"),h=i(function(){return 0},v,"zero"),d=i(function(){return 1},v,"one"),y=i(function(){return!0},v,"true"),m=i(function(){return!1},v,"false"),b=0,j=1,x=2,A=3,F=function(n){var r=n||b;return{level:function(n){return arguments.length?(r=+n,this):r},warn:function(){return r>=j&&o("warn","WARN",arguments),this},info:function(){return r>=x&&o("log","INFO",arguments),this},debug:function(){return r>=A&&o("log","DEBUG",arguments),this}}},N=function(n){return null!=n?f(n)?n:[n]:[]},O=function(n,r){if(null==n)return null;n=N(n);var t,e,o,f,l,a,s,v=n.map(function(n){return c(n).map(u).join("][")}),p=N(r),g=v.length-1,h="var u,v;return ";for(t=0;t<=g;++t)e=v[t],o="(u=a["+e+"])",f="(v=b["+e+"])",l="((v=v instanceof Date?+v:v),(u=u instanceof Date?+u:u))",a="descending"!==p[t]?(s=1,-1):(s=-1,1),h+="("+o+"<"+f+"||u==null)&&v!=null?"+a+":(u>v||v==null)&&u!=null?"+s+":"+l+"!==u&&v===v?"+a+":v!==v&&u===u?"+s+(t<g?":":":0");return i(Function("a","b",h+";"),n)},_=function(n){return"function"==typeof n},k=function(n){return _(n)?n:function(){return n}},w=function(n){throw Error(n)},D=function(n){for(var r,t,e=1,u=arguments.length;e<u;++e){r=arguments[e];for(t in r)n[t]=r[t]}return n},M=function(n,r){var t,e,u,o,i,c=-1,f=n.length;if(null==r){for(;++c<f;)if(null!=(e=n[c])&&e>=e){t=u=e;break}for(o=i=c;++c<f;)null!=(e=n[c])&&(t>e&&(t=e,o=c),u<e&&(u=e,i=c))}else{for(;++c<f;)if(null!=(e=r(n[c],c,n))&&e>=e){t=u=e;break}for(o=i=c;++c<f;)null!=(e=r(n[c],c,n))&&(t>e&&(t=e,o=c),u<e&&(u=e,i=c))}return[o,i]},S=function(n,r){var t=n.prototype=Object.create(r.prototype);return t.constructor=n,t},E=function(n){return"number"==typeof n},I=function(n){n=n?N(n):n;var r=n&&n.length?Function("_","return ''+"+n.map(function(n){return"_["+c(n).map(u).join("][")+"]"}).join("+'|'+")+";"):function(){return""};return i(r,n,"key")},z=function(n,r,t,e){var u=r.length,o=t.length;if(!o)return r;if(!u)return t;for(var i=e||new r.constructor(u+o),c=0,f=0,l=0;c<u&&f<o;++l)i[l]=n(r[c],t[f])>0?t[f++]:r[c++];for(;c<u;++c,++l)i[l]=r[c];for(;f<o;++f,++l)i[l]=t[f];return i},P=function(n,r){for(var t="";--r>=0;)t+=n;return t},W=function(n,r,t,e){var u=t||" ",o=n+"",i=r-o.length;return i<=0?o:"left"===e?P(u,i)+o:"center"===e?P(u,~~(i/2))+o+P(u,Math.ceil(i/2)):o+P(u,i)},B=function(n){return n[n.length-1]},G=function(n){for(var r={},t=0,e=n.length;t<e;++t)r[n[t]]=1;return r},J=function(n,r,t,e){var u=null!=e?e:"…",o=n+"",i=o.length,c=Math.max(0,r-u.length);return i<=r?o:"left"===t?u+o.slice(i-c):"center"===t?o.slice(0,Math.ceil(c/2))+u+o.slice(i-~~(c/2)):o.slice(0,c)+u},R=function(n,r,t){if(n){var e,u=0,o=n.length;if(r)for(;u<o;++u)(e=r(n[u]))&&t(e,u,n);else n.forEach(t)}};n.accessor=i,n.accessorName=r,n.accessorFields=t,n.id=p,n.identity=g,n.zero=h,n.one=d,n.truthy=y,n.falsy=m,n.logger=F,n.None=b,n.Warn=j,n.Info=x,n.Debug=A,n.array=N,n.compare=O,n.constant=k,n.error=w,n.extend=D,n.extentIndex=M,n.field=s,n.inherits=S,n.isArray=f,n.isFunction=_,n.isNumber=E,n.isObject=l,n.isString=a,n.key=I,n.merge=z,n.pad=W,n.peek=B,n.repeat=P,n.splitAccessPath=c,n.stringValue=u,n.toSet=G,n.truncate=J,n.visitArray=R,Object.defineProperty(n,"__esModule",{value:!0})}); | ||
!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(n.vega=n.vega||{})}(this,function(n){"use strict";function t(n){return null==n?null:n.fname}function e(n){return null==n?null:n.fields}function r(n){return"["!==n[0]?n:"'"!==n[1]&&'"'!==n[1]?n.slice(1,-1):n.slice(2,-2).replace(/\\(["'])/g,"$1")}function u(n){return f(n)?"["+n.map(u)+"]":l(n)||a(n)?JSON.stringify(n).replace("\u2028","\\u2028").replace("\u2029","\\u2029"):n}function i(n,t,e){var r=[t].concat([].slice.call(e));console[n].apply(console,r)}var o=function(n,t,e){return n.fields=t||[],n.fname=e,n},c=function(n){return String(n).match(/\[(.*?)\]|[^.\[]+/g).map(r)},f=Array.isArray,l=function(n){return n===Object(n)},a=function(n){return"string"==typeof n},s=function(n,t){var e=c(n).map(u),r=Function("_","return _["+e.join("][")+"];");return o(r,[n],t||n)},p=[],v=s("id"),h=o(function(n){return n},p,"identity"),g=o(function(){return 0},p,"zero"),y=o(function(){return 1},p,"one"),d=o(function(){return!0},p,"true"),m=o(function(){return!1},p,"false"),b=0,j=1,O=2,x=3,z=function(n){var t=n||b;return{level:function(n){return arguments.length?(t=+n,this):t},warn:function(){return t>=j&&i("warn","WARN",arguments),this},info:function(){return t>=O&&i("log","INFO",arguments),this},debug:function(){return t>=x&&i("log","DEBUG",arguments),this}}},k=function(n){return null!=n?f(n)?n:[n]:[]},A=function(n,t){if(null==n)return null;n=k(n);var e,r,i,f,l,a,s,p=n.map(function(n){return c(n).map(u).join("][")}),v=k(t),h=p.length-1,g="var u,v;return ";for(e=0;e<=h;++e)r=p[e],i="(u=a["+r+"])",f="(v=b["+r+"])",l="((v=v instanceof Date?+v:v),(u=u instanceof Date?+u:u))",a="descending"!==v[e]?(s=1,-1):(s=-1,1),g+="("+i+"<"+f+"||u==null)&&v!=null?"+a+":(u>v||v==null)&&u!=null?"+s+":"+l+"!==u&&v===v?"+a+":v!==v&&u===u?"+s+(e<h?":":":0");return o(Function("a","b",g+";"),n)},F=function(n){return"function"==typeof n},N=function(n){return F(n)?n:function(){return n}},_=function(n){throw Error(n)},w=function(n){for(var t,e,r=1,u=arguments.length;r<u;++r){t=arguments[r];for(e in t)n[e]=t[e]}return n},D=function(n,t){var e,r,u,i,o,c=-1,f=n.length;if(null==t){for(;++c<f;)if(null!=(r=n[c])&&r>=r){e=u=r;break}for(i=o=c;++c<f;)null!=(r=n[c])&&(e>r&&(e=r,i=c),u<r&&(u=r,o=c))}else{for(;++c<f;)if(null!=(r=t(n[c],c,n))&&r>=r){e=u=r;break}for(i=o=c;++c<f;)null!=(r=t(n[c],c,n))&&(e>r&&(e=r,i=c),u<r&&(u=r,o=c))}return[i,o]},E={},M=function(n){function t(n){return u.hasOwnProperty(n)&&u[n]!==E}var e,r,u={};return e={size:0,empty:0,object:u,has:t,get:function(n){return t(n)?u[n]:void 0},set:function(n,r){return t(n)||(++e.size,u[n]===E&&--e.empty),u[n]=r,this},delete:function(n){return t(n)&&(--e.size,++e.empty,u[n]=E),this},clear:function(){e.size=e.empty=0,e.object=u={}},test:function(n){return arguments.length?(r=n,e):r},clean:function(){var n,t,i={},o=0;for(n in u)t=u[n],t===E||r&&r(t)||(i[n]=t,++o);e.size=o,e.empty=0,e.object=u=i}},n&&Object.keys(n).forEach(function(t){e.set(t,n[t])}),e},S=function(n,t){var e=n.prototype=Object.create(t.prototype);return e.constructor=n,e},I=function(n){return"number"==typeof n},P=function(n){n=n?k(n):n;var t=n&&n.length?Function("_","return ''+"+n.map(function(n){return"_["+c(n).map(u).join("][")+"]"}).join("+'|'+")+";"):function(){return""};return o(t,n,"key")},W=function(n,t,e,r){var u=t.length,i=e.length;if(!i)return t;if(!u)return e;for(var o=r||new t.constructor(u+i),c=0,f=0,l=0;c<u&&f<i;++l)o[l]=n(t[c],e[f])>0?e[f++]:t[c++];for(;c<u;++c,++l)o[l]=t[c];for(;f<i;++f,++l)o[l]=e[f];return o},B=function(n,t){for(var e="";--t>=0;)e+=n;return e},G=function(n,t,e,r){var u=e||" ",i=n+"",o=t-i.length;return o<=0?i:"left"===r?B(u,o)+i:"center"===r?B(u,~~(o/2))+i+B(u,Math.ceil(o/2)):i+B(u,o)},J=function(n){return n[n.length-1]},R=function(n){for(var t={},e=0,r=n.length;e<r;++e)t[n[e]]=1;return t},U=function(n,t,e,r){var u=null!=r?r:"…",i=n+"",o=i.length,c=Math.max(0,t-u.length);return o<=t?i:"left"===e?u+i.slice(o-c):"center"===e?i.slice(0,Math.ceil(c/2))+u+i.slice(o-~~(c/2)):i.slice(0,c)+u},V=function(n,t,e){if(n){var r,u=0,i=n.length;if(t)for(;u<i;++u)(r=t(n[u]))&&e(r,u,n);else n.forEach(e)}};n.accessor=o,n.accessorName=t,n.accessorFields=e,n.id=v,n.identity=h,n.zero=g,n.one=y,n.truthy=d,n.falsy=m,n.logger=z,n.None=b,n.Warn=j,n.Info=O,n.Debug=x,n.array=k,n.compare=A,n.constant=N,n.error=_,n.extend=w,n.extentIndex=D,n.fastmap=M,n.field=s,n.inherits=S,n.isArray=f,n.isFunction=F,n.isNumber=I,n.isObject=l,n.isString=a,n.key=P,n.merge=W,n.pad=G,n.peek=J,n.repeat=B,n.splitAccessPath=c,n.stringValue=u,n.toSet=R,n.truncate=U,n.visitArray=V,Object.defineProperty(n,"__esModule",{value:!0})}); |
@@ -30,2 +30,3 @@ export { | ||
export {default as extentIndex} from './src/extentIndex'; | ||
export {default as fastmap} from './src/fastmap'; | ||
export {default as field} from './src/field'; | ||
@@ -32,0 +33,0 @@ export {default as inherits} from './src/inherits'; |
{ | ||
"name": "vega-util", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "JavaScript utilities for Vega.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -349,3 +349,3 @@ # vega-util | ||
<a name="truncate" href="#truncate">#</a> | ||
vega.<b>truncate</b>(<i>string</i> <i>length</i>[, <i>align</i>, <i>ellipsis</i>]) | ||
vega.<b>truncate</b>(<i>string</i>, <i>length</i>[, <i>align</i>, <i>ellipsis</i>]) | ||
[<>](https://github.com/vega/vega-util/blob/master/src/truncate.js "Source") | ||
@@ -352,0 +352,0 @@ |
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
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
43524
35
671