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.1.2 to 1.1.3

54

build/vega-util.js

@@ -23,12 +23,46 @@ (function (global, factory) {

var splitAccessPath = function(p) {
return String(p)
.match(/\[(.*?)\]|[^.\[]+/g)
.map(path_trim);
var error = function(message) {
throw Error(message);
}
function path_trim(d) {
return d[0] !== '[' ? d
: d[1] !== "'" && d[1] !== '"' ? d.slice(1, -1)
: d.slice(2, -2).replace(/\\(["'])/g, '$1');
var splitAccessPath = function(p) {
var path = [],
q = null,
b = 0,
n = p.length,
s = '',
i, j, c;
p = p + '';
function push() {
path.push(s + p.substring(i, j));
s = '';
i = j + 1;
}
for (i=j=0; j<n; ++j) {
c = p[j];
if (c === '\\') s += p.substring(i, j), i = ++j;
else if (c === q) push(), q = null, b = -1;
else if (q) continue;
else if (i === b && c === '"') i = j + 1, q = c;
else if (i === b && c === "'") i = j + 1, q = c;
else if (c === '.' && !b) (j > i) ? push() : (i = j + 1);
else if (c === '[') {
if (j > i) push();
b = i = j + 1;
}
else if (c === ']') {
if (!b) error('Access path missing open bracket: ' + p);
if (b > 0) push();
b = 0;
i = j + 1;
}
}
if (b) error('Access path missing closing bracket: ' + p);
if (q) error('Access path missing closing quote: ' + p);
if (j > i) ++j, push();
return path;
}

@@ -149,6 +183,2 @@

var error = function(message) {
throw Error(message);
}
var extend = function(_) {

@@ -155,0 +185,0 @@ for (var x, k, i=1, len=arguments.length; i<len; ++i) {

@@ -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 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),r="return _["+e.map(u).join("][")+"];";return o(Function("_",r),[n=1===e.length?e[0]: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})});
!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 f(n)?"["+n.map(r)+"]":l(n)||s(n)?JSON.stringify(n).replace("\u2028","\\u2028").replace("\u2029","\\u2029"):n}function u(n,t,e){var r=[t].concat([].slice.call(e));console[n].apply(console,r)}var i=function(n,t,e){return n.fields=t||[],n.fname=e,n},o=function(n){throw Error(n)},c=function(n){function t(){i.push(s+n.substring(e,r)),s="",e=r+1}var e,r,u,i=[],c=null,f=0,l=n.length,s="";for(n+="",e=r=0;r<l;++r)if(u=n[r],"\\"===u)s+=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||o("Access path missing open bracket: "+n),f>0&&t(),f=0,e=r+1):r>e?t():e=r+1}return f&&o("Access path missing closing bracket: "+n),c&&o("Access path missing closing quote: "+n),r>e&&(++r,t()),i},f=Array.isArray,l=function(n){return n===Object(n)},s=function(n){return"string"==typeof n},a=function(n,t){var e=c(n),u="return _["+e.map(r).join("][")+"];";return i(Function("_",u),[n=1===e.length?e[0]:n],t||n)},p=[],v=a("id"),g=i(function(n){return n},p,"identity"),h=i(function(){return 0},p,"zero"),y=i(function(){return 1},p,"one"),d=i(function(){return!0},p,"true"),m=i(function(){return!1},p,"false"),b=0,j=1,A=2,k=3,O=function(n){var t=n||b;return{level:function(n){return arguments.length?(t=+n,this):t},warn:function(){return t>=j&&u("warn","WARN",arguments),this},info:function(){return t>=A&&u("log","INFO",arguments),this},debug:function(){return t>=k&&u("log","DEBUG",arguments),this}}},x=function(n){return null!=n?f(n)?n:[n]:[]},z=function(n,t){if(null==n)return null;n=x(n);var e,u,o,f,l,s,a,p=n.map(function(n){return c(n).map(r).join("][")}),v=x(t),g=p.length-1,h="var u,v;return ";for(e=0;e<=g;++e)u=p[e],o="(u=a["+u+"])",f="(v=b["+u+"])",l="((v=v instanceof Date?+v:v),(u=u instanceof Date?+u:u))",s="descending"!==v[e]?(a=1,-1):(a=-1,1),h+="("+o+"<"+f+"||u==null)&&v!=null?"+s+":(u>v||v==null)&&u!=null?"+a+":"+l+"!==u&&v===v?"+s+":v!==v&&u===u?"+a+(e<g?":":":0");return i(Function("a","b",h+";"),n)},F=function(n){return"function"==typeof n},N=function(n){return F(n)?n:function(){return n}},_=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},w=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]},D={},E=function(n){function t(n){return u.hasOwnProperty(n)&&u[n]!==D}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]===D&&--e.empty),u[n]=r,this},delete:function(n){return t(n)&&(--e.size,++e.empty,u[n]=D),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===D||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},M=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?x(n):n;var t=n&&n.length?Function("_","return ''+"+n.map(function(n){return"_["+c(n).map(r).join("][")+"]"}).join("+'|'+")+";"):function(){return""};return i(t,n,"key")},S=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},W=function(n,t){for(var e="";--t>=0;)e+=n;return e},q=function(n,t,e,r){var u=e||" ",i=n+"",o=t-i.length;return o<=0?i:"left"===r?W(u,o)+i:"center"===r?W(u,~~(o/2))+i+W(u,Math.ceil(o/2)):i+W(u,o)},B=function(n){return n[n.length-1]},G=function(n){for(var t={},e=0,r=n.length;e<r;++e)t[n[e]]=1;return t},J=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},R=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=i,n.accessorName=t,n.accessorFields=e,n.id=v,n.identity=g,n.zero=h,n.one=y,n.truthy=d,n.falsy=m,n.logger=O,n.None=b,n.Warn=j,n.Info=A,n.Debug=k,n.array=x,n.compare=z,n.constant=N,n.error=o,n.extend=_,n.extentIndex=w,n.fastmap=E,n.field=a,n.inherits=M,n.isArray=f,n.isFunction=F,n.isNumber=I,n.isObject=l,n.isString=s,n.key=P,n.merge=S,n.pad=q,n.peek=B,n.repeat=W,n.splitAccessPath=c,n.stringValue=r,n.toSet=G,n.truncate=J,n.visitArray=R,Object.defineProperty(n,"__esModule",{value:!0})});
{
"name": "vega-util",
"version": "1.1.2",
"version": "1.1.3",
"description": "JavaScript utilities for Vega.",

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

@@ -0,11 +1,43 @@

import error from './error';
export default function(p) {
return String(p)
.match(/\[(.*?)\]|[^.\[]+/g)
.map(path_trim);
}
var path = [],
q = null,
b = 0,
n = p.length,
s = '',
i, j, c;
function path_trim(d) {
return d[0] !== '[' ? d
: d[1] !== "'" && d[1] !== '"' ? d.slice(1, -1)
: d.slice(2, -2).replace(/\\(["'])/g, '$1');
p = p + '';
function push() {
path.push(s + p.substring(i, j));
s = '';
i = j + 1;
}
for (i=j=0; j<n; ++j) {
c = p[j];
if (c === '\\') s += p.substring(i, j), i = ++j;
else if (c === q) push(), q = null, b = -1;
else if (q) continue;
else if (i === b && c === '"') i = j + 1, q = c;
else if (i === b && c === "'") i = j + 1, q = c;
else if (c === '.' && !b) (j > i) ? push() : (i = j + 1);
else if (c === '[') {
if (j > i) push();
b = i = j + 1;
}
else if (c === ']') {
if (!b) error('Access path missing open bracket: ' + p);
if (b > 0) push();
b = 0;
i = j + 1;
}
}
if (b) error('Access path missing closing bracket: ' + p);
if (q) error('Access path missing closing quote: ' + p);
if (j > i) ++j, push();
return path;
}
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