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

vega-util

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vega-util - npm Package Compare versions

Comparing version 1.4.1 to 1.5.0

43

build/vega-util.js

@@ -175,2 +175,6 @@ (function (global, factory) {

var isFunction = function(_) {
return typeof _ === 'function';
};
var compare = function(fields, orders) {

@@ -183,3 +187,4 @@ var idx = [],

idx.push(i);
return splitAccessPath(f).map($).join('][');
return isFunction(f) ? f
: splitAccessPath(f).map($).join('][');
}

@@ -190,3 +195,3 @@ }),

code = 'var u,v;return ',
i, j, f, u, v, d, lt, gt;
i, j, f, u, v, d, t, lt, gt;

@@ -198,5 +203,15 @@ if (n < 0) return null;

f = cmp[i];
u = '(u=a['+f+'])';
v = '(v=b['+f+'])';
if (isFunction(f)) {
d = 'f' + i;
u = '(u=this.' + d + '(a))';
v = '(v=this.' + d + '(b))';
(t = t || {})[d] = f;
} else {
u = '(u=a['+f+'])';
v = '(v=b['+f+'])';
}
d = '((v=v instanceof Date?+v:v),(u=u instanceof Date?+u:u))';
if (ord[i] !== 'descending') {

@@ -209,2 +224,3 @@ gt = 1;

}
code += '(' + u+'<'+v+'||u==null)&&v!=null?' + lt

@@ -217,10 +233,15 @@ + ':(u>v||v==null)&&u!=null?' + gt

return accessor(
Function('a', 'b', code + ';'),
fields.filter(function(_) { return _ != null; })
);
};
f = Function('a', 'b', code + ';');
if (t) f = f.bind(t);
var isFunction = function(_) {
return typeof _ === 'function';
fields = fields.reduce(function(map, field) {
if (isFunction(field)) {
(accessorFields(field) || []).forEach(function(_) { map[_] = 1; });
} else if (field != null) {
map[field + ''] = 1;
}
return map;
}, {});
return accessor(f, Object.keys(fields));
};

@@ -227,0 +248,0 @@

@@ -1,1 +0,1 @@

!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 c(n)?"["+n.map(t)+"]":l(n)||f(n)?JSON.stringify(n).replace("\u2028","\\u2028").replace("\u2029","\\u2029"):n}function e(n,t,e){var r=[t].concat([].slice.call(e));console[n].apply(console,r)}function r(n){return x(n)?n:O(n)?n:Date.parse(n)}var u=function(n,t,e){return n.fields=t||[],n.fname=e,n},o=function(n){throw Error(n)},i=function(n){function t(){i.push(a+n.substring(e,r)),a="",e=r+1}var e,r,u,i=[],c=null,l=0,f=n.length,a="";for(n+="",e=r=0;r<f;++r)if("\\"===(u=n[r]))a+=n.substring(e,r),e=++r;else if(u===c)t(),c=null,l=-1;else{if(c)continue;e===l&&'"'===u?(e=r+1,c=u):e===l&&"'"===u?(e=r+1,c=u):"."!==u||l?"["===u?(r>e&&t(),l=e=r+1):"]"===u&&(l||o("Access path missing open bracket: "+n),l>0&&t(),l=0,e=r+1):r>e?t():e=r+1}return l&&o("Access path missing closing bracket: "+n),c&&o("Access path missing closing quote: "+n),r>e&&(r++,t()),i},c=Array.isArray,l=function(n){return n===Object(n)},f=function(n){return"string"==typeof n},a=function(n,e){var r=i(n),o="return _["+r.map(t).join("][")+"];";return u(Function("_",o),[n=1===r.length?r[0]:n],e||n)},s=[],p=a("id"),g=u(function(n){return n},s,"identity"),h=u(function(){return 0},s,"zero"),v=u(function(){return 1},s,"one"),y=u(function(){return!0},s,"true"),b=u(function(){return!1},s,"false"),m=function(n){return null!=n?c(n)?n:[n]:[]},d=function(n){return"function"==typeof n},j={},O=function(n){return"[object Date]"===Object.prototype.toString.call(n)},x=function(n){return"number"==typeof n},A=function(n,t){for(var e="";--t>=0;)e+=n;return e};n.accessor=u,n.accessorName=function(n){return null==n?null:n.fname},n.accessorFields=function(n){return null==n?null:n.fields},n.id=p,n.identity=g,n.zero=h,n.one=v,n.truthy=y,n.falsy=b,n.logger=function(n){var t=n||0;return{level:function(n){return arguments.length?(t=+n,this):t},error:function(){return t>=1&&e("error","ERROR",arguments),this},warn:function(){return t>=2&&e("warn","WARN",arguments),this},info:function(){return t>=3&&e("log","INFO",arguments),this},debug:function(){return t>=4&&e("log","DEBUG",arguments),this}}},n.None=0,n.Error=1,n.Warn=2,n.Info=3,n.Debug=4,n.array=m,n.compare=function(n,e){var r,o,c,l,f,a,s,p,g=[],h=(n=m(n)).map(function(n,e){return null==n?null:(g.push(e),i(n).map(t).join("]["))}),v=g.length-1,y=m(e),b="var u,v;return ";if(v<0)return null;for(o=0;o<=v;++o)l="(u=a["+(c=h[r=g[o]])+"])",f="(v=b["+c+"])",a="((v=v instanceof Date?+v:v),(u=u instanceof Date?+u:u))","descending"!==y[r]?(p=1,s=-1):(p=-1,s=1),b+="("+l+"<"+f+"||u==null)&&v!=null?"+s+":(u>v||v==null)&&u!=null?"+p+":"+a+"!==u&&v===v?"+s+":v!==v&&u===u?"+p+(r<v?":":":0");return u(Function("a","b",b+";"),n.filter(function(n){return null!=n}))},n.constant=function(n){return d(n)?n:function(){return n}},n.debounce=function(n,t){function e(){t(u),r=u=null}var r,u;return function(t){u=t,r&&clearTimeout(r),r=setTimeout(e,n)}},n.error=o,n.extend=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},n.extentIndex=function(n,t){var e,r,u,o,i,c=-1,l=n.length;if(null==t){for(;++c<l;)if(null!=(r=n[c])&&r>=r){e=u=r;break}for(o=i=c;++c<l;)null!=(r=n[c])&&(e>r&&(e=r,o=c),u<r&&(u=r,i=c))}else{for(;++c<l;)if(null!=(r=t(n[c],c,n))&&r>=r){e=u=r;break}for(o=i=c;++c<l;)null!=(r=t(n[c],c,n))&&(e>r&&(e=r,o=c),u<r&&(u=r,i=c))}return[o,i]},n.fastmap=function(n){function t(n){return u.hasOwnProperty(n)&&u[n]!==j}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]===j&&--e.empty),u[n]=r,this},delete:function(n){return t(n)&&(--e.size,++e.empty,u[n]=j),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,o={},i=0;for(n in u)(t=u[n])===j||r&&r(t)||(o[n]=t,++i);e.size=i,e.empty=0,e.object=u=o}},n&&Object.keys(n).forEach(function(t){e.set(t,n[t])}),e},n.field=a,n.inherits=function(n,t){var e=n.prototype=Object.create(t.prototype);return e.constructor=n,e},n.isArray=c,n.isBoolean=function(n){return"boolean"==typeof n},n.isDate=O,n.isFunction=d,n.isNumber=x,n.isObject=l,n.isRegExp=function(n){return"[object RegExp]"===Object.prototype.toString.call(n)},n.isString=f,n.key=function(n){var e=(n=n?m(n):n)&&n.length?Function("_","return ''+"+n.map(function(n){return"_["+i(n).map(t).join("][")+"]"}).join("+'|'+")+";"):function(){return""};return u(e,n,"key")},n.merge=function(n,t,e,r){var u=t.length,o=e.length;if(!o)return t;if(!u)return e;for(var i=r||new t.constructor(u+o),c=0,l=0,f=0;c<u&&l<o;++f)i[f]=n(t[c],e[l])>0?e[l++]:t[c++];for(;c<u;++c,++f)i[f]=t[c];for(;l<o;++l,++f)i[f]=e[l];return i},n.pad=function(n,t,e,r){var u=e||" ",o=n+"",i=t-o.length;return i<=0?o:"left"===r?A(u,i)+o:"center"===r?A(u,~~(i/2))+o+A(u,Math.ceil(i/2)):o+A(u,i)},n.peek=function(n){return n[n.length-1]},n.repeat=A,n.splitAccessPath=i,n.stringValue=t,n.toBoolean=function(n){return null==n||""===n?null:!(!n||"false"===n||"0"===n||!n)},n.toDate=function(n,t){return t=t||r,null==n||""===n?null:t(n)},n.toNumber=function(n){return null==n||""===n?null:+n},n.toString=function(n){return null==n||""===n?null:n+""},n.toSet=function(n){for(var t={},e=0,r=n.length;e<r;++e)t[n[e]]=1;return t},n.truncate=function(n,t,e,r){var u=null!=r?r:"…",o=n+"",i=o.length,c=Math.max(0,t-u.length);return i<=t?o:"left"===e?u+o.slice(i-c):"center"===e?o.slice(0,Math.ceil(c/2))+u+o.slice(i-~~(c/2)):o.slice(0,c)+u},n.visitArray=function(n,t,e){if(n){var r,u=0,o=n.length;if(t)for(;u<o;++u)(r=t(n[u]))&&e(r,u,n);else n.forEach(e)}},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.fields}function e(n){return f(n)?"["+n.map(e)+"]":l(n)||a(n)?JSON.stringify(n).replace("\u2028","\\u2028").replace("\u2029","\\u2029"):n}function r(n,t,e){var r=[t].concat([].slice.call(e));console[n].apply(console,r)}function u(n){return x(n)?n:k(n)?n:Date.parse(n)}var o=function(n,t,e){return n.fields=t||[],n.fname=e,n},i=function(n){throw Error(n)},c=function(n){function t(){o.push(a+n.substring(e,r)),a="",e=r+1}var e,r,u,o=[],c=null,f=0,l=n.length,a="";for(n+="",e=r=0;r<l;++r)if("\\"===(u=n[r]))a+=n.substring(e,r),e=++r;else if(u===c)t(),c=null,f=-1;else{if(c)continue;e===f&&'"'===u?(e=r+1,c=u):e===f&&"'"===u?(e=r+1,c=u):"."!==u||f?"["===u?(r>e&&t(),f=e=r+1):"]"===u&&(f||i("Access path missing open bracket: "+n),f>0&&t(),f=0,e=r+1):r>e?t():e=r+1}return f&&i("Access path missing closing bracket: "+n),c&&i("Access path missing closing quote: "+n),r>e&&(r++,t()),o},f=Array.isArray,l=function(n){return n===Object(n)},a=function(n){return"string"==typeof n},s=function(n,t){var r=c(n),u="return _["+r.map(e).join("][")+"];";return o(Function("_",u),[n=1===r.length?r[0]:n],t||n)},p=[],g=s("id"),h=o(function(n){return n},p,"identity"),v=o(function(){return 0},p,"zero"),y=o(function(){return 1},p,"one"),b=o(function(){return!0},p,"true"),d=o(function(){return!1},p,"false"),m=function(n){return null!=n?f(n)?n:[n]:[]},j=function(n){return"function"==typeof n},O={},k=function(n){return"[object Date]"===Object.prototype.toString.call(n)},x=function(n){return"number"==typeof n},A=function(n,t){for(var e="";--t>=0;)e+=n;return e};n.accessor=o,n.accessorName=function(n){return null==n?null:n.fname},n.accessorFields=t,n.id=g,n.identity=h,n.zero=v,n.one=y,n.truthy=b,n.falsy=d,n.logger=function(n){var t=n||0;return{level:function(n){return arguments.length?(t=+n,this):t},error:function(){return t>=1&&r("error","ERROR",arguments),this},warn:function(){return t>=2&&r("warn","WARN",arguments),this},info:function(){return t>=3&&r("log","INFO",arguments),this},debug:function(){return t>=4&&r("log","DEBUG",arguments),this}}},n.None=0,n.Error=1,n.Warn=2,n.Info=3,n.Debug=4,n.array=m,n.compare=function(n,r){var u,i,f,l,a,s,p,g,h,v=[],y=(n=m(n)).map(function(n,t){return null==n?null:(v.push(t),j(n)?n:c(n).map(e).join("]["))}),b=v.length-1,d=m(r),O="var u,v;return ";if(b<0)return null;for(i=0;i<=b;++i)f=y[u=v[i]],j(f)?(l="(u=this."+(s="f"+u)+"(a))",a="(v=this."+s+"(b))",(p=p||{})[s]=f):(l="(u=a["+f+"])",a="(v=b["+f+"])"),s="((v=v instanceof Date?+v:v),(u=u instanceof Date?+u:u))","descending"!==d[u]?(h=1,g=-1):(h=-1,g=1),O+="("+l+"<"+a+"||u==null)&&v!=null?"+g+":(u>v||v==null)&&u!=null?"+h+":"+s+"!==u&&v===v?"+g+":v!==v&&u===u?"+h+(u<b?":":":0");return f=Function("a","b",O+";"),p&&(f=f.bind(p)),n=n.reduce(function(n,e){return j(e)?(t(e)||[]).forEach(function(t){n[t]=1}):null!=e&&(n[e+""]=1),n},{}),o(f,Object.keys(n))},n.constant=function(n){return j(n)?n:function(){return n}},n.debounce=function(n,t){function e(){t(u),r=u=null}var r,u;return function(t){u=t,r&&clearTimeout(r),r=setTimeout(e,n)}},n.error=i,n.extend=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},n.extentIndex=function(n,t){var e,r,u,o,i,c=-1,f=n.length;if(null==t){for(;++c<f;)if(null!=(r=n[c])&&r>=r){e=u=r;break}for(o=i=c;++c<f;)null!=(r=n[c])&&(e>r&&(e=r,o=c),u<r&&(u=r,i=c))}else{for(;++c<f;)if(null!=(r=t(n[c],c,n))&&r>=r){e=u=r;break}for(o=i=c;++c<f;)null!=(r=t(n[c],c,n))&&(e>r&&(e=r,o=c),u<r&&(u=r,i=c))}return[o,i]},n.fastmap=function(n){function t(n){return u.hasOwnProperty(n)&&u[n]!==O}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]===O&&--e.empty),u[n]=r,this},delete:function(n){return t(n)&&(--e.size,++e.empty,u[n]=O),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,o={},i=0;for(n in u)(t=u[n])===O||r&&r(t)||(o[n]=t,++i);e.size=i,e.empty=0,e.object=u=o}},n&&Object.keys(n).forEach(function(t){e.set(t,n[t])}),e},n.field=s,n.inherits=function(n,t){var e=n.prototype=Object.create(t.prototype);return e.constructor=n,e},n.isArray=f,n.isBoolean=function(n){return"boolean"==typeof n},n.isDate=k,n.isFunction=j,n.isNumber=x,n.isObject=l,n.isRegExp=function(n){return"[object RegExp]"===Object.prototype.toString.call(n)},n.isString=a,n.key=function(n){var t=(n=n?m(n):n)&&n.length?Function("_","return ''+"+n.map(function(n){return"_["+c(n).map(e).join("][")+"]"}).join("+'|'+")+";"):function(){return""};return o(t,n,"key")},n.merge=function(n,t,e,r){var u=t.length,o=e.length;if(!o)return t;if(!u)return e;for(var i=r||new t.constructor(u+o),c=0,f=0,l=0;c<u&&f<o;++l)i[l]=n(t[c],e[f])>0?e[f++]:t[c++];for(;c<u;++c,++l)i[l]=t[c];for(;f<o;++f,++l)i[l]=e[f];return i},n.pad=function(n,t,e,r){var u=e||" ",o=n+"",i=t-o.length;return i<=0?o:"left"===r?A(u,i)+o:"center"===r?A(u,~~(i/2))+o+A(u,Math.ceil(i/2)):o+A(u,i)},n.peek=function(n){return n[n.length-1]},n.repeat=A,n.splitAccessPath=c,n.stringValue=e,n.toBoolean=function(n){return null==n||""===n?null:!(!n||"false"===n||"0"===n||!n)},n.toDate=function(n,t){return t=t||u,null==n||""===n?null:t(n)},n.toNumber=function(n){return null==n||""===n?null:+n},n.toString=function(n){return null==n||""===n?null:n+""},n.toSet=function(n){for(var t={},e=0,r=n.length;e<r;++e)t[n[e]]=1;return t},n.truncate=function(n,t,e,r){var u=null!=r?r:"…",o=n+"",i=o.length,c=Math.max(0,t-u.length);return i<=t?o:"left"===e?u+o.slice(i-c):"center"===e?o.slice(0,Math.ceil(c/2))+u+o.slice(i-~~(c/2)):o.slice(0,c)+u},n.visitArray=function(n,t,e){if(n){var r,u=0,o=n.length;if(t)for(;u<o;++u)(r=t(n[u]))&&e(r,u,n);else n.forEach(e)}},Object.defineProperty(n,"__esModule",{value:!0})});
{
"name": "vega-util",
"version": "1.4.1",
"version": "1.5.0",
"description": "JavaScript utilities for Vega.",

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

@@ -59,11 +59,11 @@ # vega-util

set of *fields* and optional sort *orders*. The *fields* argument must be
either a string or an array of strings, indicating the name of object
properties to sort by, in precedence order. Field strings may include
nested properties (e.g., `foo.bar.baz`). The *orders* argument must be
either a string or an array of strings; the valid string values are
`'ascending'` (for ascending sort order of the corresponding field) or
`'descending'` (for descending sort order of the corresponding field).
If the *orders* argument is omitted, is shorter than the *fields* array,
or includes values other than `'ascending'` or `'descending'`,
corresponding fields will default to ascending order.
either a string, an accessor function, or an array of either. Strings
indicate the name of object properties to sort by, in precedence order.
Field strings may include nested properties (e.g., `foo.bar.baz`). The
*orders* argument must be either a string or an array of strings; the valid
string values are `'ascending'` (for ascending sort order of the
corresponding field) or `'descending'` (for descending sort order of the
corresponding field). If the *orders* argument is omitted, is shorter than
the *fields* array, or includes values other than `'ascending'` or
`'descending'`, corresponding fields will default to ascending order.

@@ -70,0 +70,0 @@ <a name="constant" href="#constant">#</a>

@@ -1,3 +0,4 @@

import accessor from './accessor';
import {default as accessor, accessorFields} from './accessor';
import array from './array';
import isFunction from './isFunction';
import splitAccessPath from './splitAccessPath';

@@ -13,3 +14,4 @@ import stringValue from './stringValue';

idx.push(i);
return splitAccessPath(f).map(stringValue).join('][');
return isFunction(f) ? f
: splitAccessPath(f).map(stringValue).join('][');
}

@@ -20,3 +22,3 @@ }),

code = 'var u,v;return ',
i, j, f, u, v, d, lt, gt;
i, j, f, u, v, d, t, lt, gt;

@@ -28,5 +30,15 @@ if (n < 0) return null;

f = cmp[i];
u = '(u=a['+f+'])';
v = '(v=b['+f+'])';
if (isFunction(f)) {
d = 'f' + i;
u = '(u=this.' + d + '(a))';
v = '(v=this.' + d + '(b))';
(t = t || {})[d] = f;
} else {
u = '(u=a['+f+'])';
v = '(v=b['+f+'])';
}
d = '((v=v instanceof Date?+v:v),(u=u instanceof Date?+u:u))';
if (ord[i] !== 'descending') {

@@ -39,2 +51,3 @@ gt = 1;

}
code += '(' + u+'<'+v+'||u==null)&&v!=null?' + lt

@@ -47,6 +60,15 @@ + ':(u>v||v==null)&&u!=null?' + gt

return accessor(
Function('a', 'b', code + ';'),
fields.filter(function(_) { return _ != null; })
);
f = Function('a', 'b', code + ';');
if (t) f = f.bind(t);
fields = fields.reduce(function(map, field) {
if (isFunction(field)) {
(accessorFields(field) || []).forEach(function(_) { map[_] = 1; });
} else if (field != null) {
map[field + ''] = 1;
}
return map;
}, {});
return accessor(f, Object.keys(fields));
}
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