gremlin-client
Advanced tools
Comparing version 0.1.2 to 0.2.0
!function(e){if("object"==typeof exports)module.exports=e();else if("function"==typeof define&&define.amd)define(e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.gremlin=e()}}(function(){return function e(t,n,r){function i(s,a){if(!n[s]){if(!t[s]){var u="function"==typeof require&&require;if(!a&&u)return u(s,!0);if(o)return o(s,!0);throw new Error("Cannot find module '"+s+"'")}var f=n[s]={exports:{}};t[s][0].call(f.exports,function(e){var n=t[s][1][e];return i(n?n:e)},f,f.exports,e,t,n,r)}return n[s].exports}for(var o="function"==typeof require&&require,s=0;s<r.length;s++)i(r[s]);return i}({1:[function(e,t){var n=e("./src/gremlinclient");t.exports.createClient=function(e,t,r){return"object"==typeof e&&(r=e,e=void 0),"object"==typeof t&&(r=t,t=void 0),new n(e,t,r)}},{"./src/gremlinclient":26}],2:[function(e,t){!function(){function e(e){for(var t="",n=0;e>n;n++)t+=(65536*(1+Math.random())|0).toString(16).substring(1);return t}function n(e){if(!e)throw new TypeError("Invalid argument; `value` has no value.");this.value=n.EMPTY,e&&e instanceof n?this.value=e.toString():e&&"[object String]"===Object.prototype.toString.call(e)&&n.isGuid(e)&&(this.value=e),this.equals=function(e){return n.isGuid(e)&&this.value==e},this.isEmpty=function(){return this.value===n.EMPTY},this.toString=function(){return this.value},this.toJSON=function(){return this.value}}var r=new RegExp("^[a-z0-9]{8}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{4}-[a-z0-9]{12}$","i");n.EMPTY="00000000-0000-0000-0000-000000000000",n.isGuid=function(e){return e&&(e instanceof n||r.test(e.toString()))},n.create=function(){return new n([e(2),e(1),e(1),e(1),e(3)].join("-"))},n.raw=function(){return[e(2),e(1),e(1),e(1),e(3)].join("-")},"undefined"!=typeof t&&t.exports?t.exports=n:"undefined"!=typeof window&&(window.Guid=n)}()},{}],3:[function(e,t,n){function r(e,t,n){if(!(this instanceof r))return new r(e,t,n);var i=typeof e;if("base64"===t&&"string"===i)for(e=x(e);e.length%4!==0;)e+="=";var o;if("number"===i)o=M(e);else if("string"===i)o=r.byteLength(e,t);else{if("object"!==i)throw new Error("First argument needs to be a number, array or string.");o=M(e.length)}var s;r._useTypedArrays?s=r._augment(new Uint8Array(o)):(s=this,s.length=o,s._isBuffer=!0);var a;if(r._useTypedArrays&&"number"==typeof e.byteLength)s._set(e);else if(C(e))for(a=0;o>a;a++)s[a]=r.isBuffer(e)?e.readUInt8(a):e[a];else if("string"===i)s.write(e,0,t);else if("number"===i&&!r._useTypedArrays&&!n)for(a=0;o>a;a++)s[a]=0;return s}function i(e,t,n,i){n=Number(n)||0;var o=e.length-n;i?(i=Number(i),i>o&&(i=o)):i=o;var s=t.length;q(s%2===0,"Invalid hex string"),i>s/2&&(i=s/2);for(var a=0;i>a;a++){var u=parseInt(t.substr(2*a,2),16);q(!isNaN(u),"Invalid hex string"),e[n+a]=u}return r._charsWritten=2*a,a}function o(e,t,n,i){var o=r._charsWritten=N(T(t),e,n,i);return o}function s(e,t,n,i){var o=r._charsWritten=N(O(t),e,n,i);return o}function a(e,t,n,r){return s(e,t,n,r)}function u(e,t,n,i){var o=r._charsWritten=N(D(t),e,n,i);return o}function f(e,t,n,i){var o=r._charsWritten=N(R(t),e,n,i);return o}function c(e,t,n){return J.fromByteArray(0===t&&n===e.length?e:e.slice(t,n))}function l(e,t,n){var r="",i="";n=Math.min(e.length,n);for(var o=t;n>o;o++)e[o]<=127?(r+=z(i)+String.fromCharCode(e[o]),i=""):i+="%"+e[o].toString(16);return r+z(i)}function h(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;n>i;i++)r+=String.fromCharCode(e[i]);return r}function d(e,t,n){return h(e,t,n)}function p(e,t,n){var r=e.length;(!t||0>t)&&(t=0),(!n||0>n||n>r)&&(n=r);for(var i="",o=t;n>o;o++)i+=U(e[o]);return i}function g(e,t,n){for(var r=e.slice(t,n),i="",o=0;o<r.length;o+=2)i+=String.fromCharCode(r[o]+256*r[o+1]);return i}function v(e,t,n,r){r||(q("boolean"==typeof n,"missing or invalid endian"),q(void 0!==t&&null!==t,"missing offset"),q(t+1<e.length,"Trying to read beyond buffer length"));var i=e.length;if(!(t>=i)){var o;return n?(o=e[t],i>t+1&&(o|=e[t+1]<<8)):(o=e[t]<<8,i>t+1&&(o|=e[t+1])),o}}function y(e,t,n,r){r||(q("boolean"==typeof n,"missing or invalid endian"),q(void 0!==t&&null!==t,"missing offset"),q(t+3<e.length,"Trying to read beyond buffer length"));var i=e.length;if(!(t>=i)){var o;return n?(i>t+2&&(o=e[t+2]<<16),i>t+1&&(o|=e[t+1]<<8),o|=e[t],i>t+3&&(o+=e[t+3]<<24>>>0)):(i>t+1&&(o=e[t+1]<<16),i>t+2&&(o|=e[t+2]<<8),i>t+3&&(o|=e[t+3]),o+=e[t]<<24>>>0),o}}function b(e,t,n,r){r||(q("boolean"==typeof n,"missing or invalid endian"),q(void 0!==t&&null!==t,"missing offset"),q(t+1<e.length,"Trying to read beyond buffer length"));var i=e.length;if(!(t>=i)){var o=v(e,t,n,!0),s=32768&o;return s?-1*(65535-o+1):o}}function m(e,t,n,r){r||(q("boolean"==typeof n,"missing or invalid endian"),q(void 0!==t&&null!==t,"missing offset"),q(t+3<e.length,"Trying to read beyond buffer length"));var i=e.length;if(!(t>=i)){var o=y(e,t,n,!0),s=2147483648&o;return s?-1*(4294967295-o+1):o}}function w(e,t,n,r){return r||(q("boolean"==typeof n,"missing or invalid endian"),q(t+3<e.length,"Trying to read beyond buffer length")),H.read(e,t,n,23,4)}function E(e,t,n,r){return r||(q("boolean"==typeof n,"missing or invalid endian"),q(t+7<e.length,"Trying to read beyond buffer length")),H.read(e,t,n,52,8)}function _(e,t,n,r,i){i||(q(void 0!==t&&null!==t,"missing value"),q("boolean"==typeof r,"missing or invalid endian"),q(void 0!==n&&null!==n,"missing offset"),q(n+1<e.length,"trying to write beyond buffer length"),W(t,65535));var o=e.length;if(!(n>=o))for(var s=0,a=Math.min(o-n,2);a>s;s++)e[n+s]=(t&255<<8*(r?s:1-s))>>>8*(r?s:1-s)}function S(e,t,n,r,i){i||(q(void 0!==t&&null!==t,"missing value"),q("boolean"==typeof r,"missing or invalid endian"),q(void 0!==n&&null!==n,"missing offset"),q(n+3<e.length,"trying to write beyond buffer length"),W(t,4294967295));var o=e.length;if(!(n>=o))for(var s=0,a=Math.min(o-n,4);a>s;s++)e[n+s]=t>>>8*(r?s:3-s)&255}function L(e,t,n,r,i){i||(q(void 0!==t&&null!==t,"missing value"),q("boolean"==typeof r,"missing or invalid endian"),q(void 0!==n&&null!==n,"missing offset"),q(n+1<e.length,"Trying to write beyond buffer length"),F(t,32767,-32768));var o=e.length;n>=o||(t>=0?_(e,t,n,r,i):_(e,65535+t+1,n,r,i))}function I(e,t,n,r,i){i||(q(void 0!==t&&null!==t,"missing value"),q("boolean"==typeof r,"missing or invalid endian"),q(void 0!==n&&null!==n,"missing offset"),q(n+3<e.length,"Trying to write beyond buffer length"),F(t,2147483647,-2147483648));var o=e.length;n>=o||(t>=0?S(e,t,n,r,i):S(e,4294967295+t+1,n,r,i))}function j(e,t,n,r,i){i||(q(void 0!==t&&null!==t,"missing value"),q("boolean"==typeof r,"missing or invalid endian"),q(void 0!==n&&null!==n,"missing offset"),q(n+3<e.length,"Trying to write beyond buffer length"),P(t,3.4028234663852886e38,-3.4028234663852886e38));var o=e.length;n>=o||H.write(e,t,n,r,23,4)}function k(e,t,n,r,i){i||(q(void 0!==t&&null!==t,"missing value"),q("boolean"==typeof r,"missing or invalid endian"),q(void 0!==n&&null!==n,"missing offset"),q(n+7<e.length,"Trying to write beyond buffer length"),P(t,1.7976931348623157e308,-1.7976931348623157e308));var o=e.length;n>=o||H.write(e,t,n,r,52,8)}function x(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function B(e,t,n){return"number"!=typeof e?n:(e=~~e,e>=t?t:e>=0?e:(e+=t,e>=0?e:0))}function M(e){return e=~~Math.ceil(+e),0>e?0:e}function A(e){return(Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)})(e)}function C(e){return A(e)||r.isBuffer(e)||e&&"object"==typeof e&&"number"==typeof e.length}function U(e){return 16>e?"0"+e.toString(16):e.toString(16)}function T(e){for(var t=[],n=0;n<e.length;n++){var r=e.charCodeAt(n);if(127>=r)t.push(e.charCodeAt(n));else{var i=n;r>=55296&&57343>=r&&n++;for(var o=encodeURIComponent(e.slice(i,n+1)).substr(1).split("%"),s=0;s<o.length;s++)t.push(parseInt(o[s],16))}}return t}function O(e){for(var t=[],n=0;n<e.length;n++)t.push(255&e.charCodeAt(n));return t}function R(e){for(var t,n,r,i=[],o=0;o<e.length;o++)t=e.charCodeAt(o),n=t>>8,r=t%256,i.push(r),i.push(n);return i}function D(e){return J.toByteArray(e)}function N(e,t,n,r){for(var i=0;r>i&&!(i+n>=t.length||i>=e.length);i++)t[i+n]=e[i];return i}function z(e){try{return decodeURIComponent(e)}catch(t){return String.fromCharCode(65533)}}function W(e,t){q("number"==typeof e,"cannot write a non-number as a number"),q(e>=0,"specified a negative value for writing an unsigned value"),q(t>=e,"value is larger than maximum value for type"),q(Math.floor(e)===e,"value has a fractional component")}function F(e,t,n){q("number"==typeof e,"cannot write a non-number as a number"),q(t>=e,"value larger than maximum allowed value"),q(e>=n,"value smaller than minimum allowed value"),q(Math.floor(e)===e,"value has a fractional component")}function P(e,t,n){q("number"==typeof e,"cannot write a non-number as a number"),q(t>=e,"value larger than maximum allowed value"),q(e>=n,"value smaller than minimum allowed value")}function q(e,t){if(!e)throw new Error(t||"Failed assertion")}var J=e("base64-js"),H=e("ieee754");n.Buffer=r,n.SlowBuffer=r,n.INSPECT_MAX_BYTES=50,r.poolSize=8192,r._useTypedArrays=function(){try{var e=new ArrayBuffer(0),t=new Uint8Array(e);return t.foo=function(){return 42},42===t.foo()&&"function"==typeof t.subarray}catch(n){return!1}}(),r.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"raw":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},r.isBuffer=function(e){return!(null===e||void 0===e||!e._isBuffer)},r.byteLength=function(e,t){var n;switch(e+="",t||"utf8"){case"hex":n=e.length/2;break;case"utf8":case"utf-8":n=T(e).length;break;case"ascii":case"binary":case"raw":n=e.length;break;case"base64":n=D(e).length;break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":n=2*e.length;break;default:throw new Error("Unknown encoding")}return n},r.concat=function(e,t){if(q(A(e),"Usage: Buffer.concat(list, [totalLength])\nlist should be an Array."),0===e.length)return new r(0);if(1===e.length)return e[0];var n;if("number"!=typeof t)for(t=0,n=0;n<e.length;n++)t+=e[n].length;var i=new r(t),o=0;for(n=0;n<e.length;n++){var s=e[n];s.copy(i,o),o+=s.length}return i},r.prototype.write=function(e,t,n,r){if(isFinite(t))isFinite(n)||(r=n,n=void 0);else{var c=r;r=t,t=n,n=c}t=Number(t)||0;var l=this.length-t;n?(n=Number(n),n>l&&(n=l)):n=l,r=String(r||"utf8").toLowerCase();var h;switch(r){case"hex":h=i(this,e,t,n);break;case"utf8":case"utf-8":h=o(this,e,t,n);break;case"ascii":h=s(this,e,t,n);break;case"binary":h=a(this,e,t,n);break;case"base64":h=u(this,e,t,n);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":h=f(this,e,t,n);break;default:throw new Error("Unknown encoding")}return h},r.prototype.toString=function(e,t,n){var r=this;if(e=String(e||"utf8").toLowerCase(),t=Number(t)||0,n=void 0!==n?Number(n):n=r.length,n===t)return"";var i;switch(e){case"hex":i=p(r,t,n);break;case"utf8":case"utf-8":i=l(r,t,n);break;case"ascii":i=h(r,t,n);break;case"binary":i=d(r,t,n);break;case"base64":i=c(r,t,n);break;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":i=g(r,t,n);break;default:throw new Error("Unknown encoding")}return i},r.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},r.prototype.copy=function(e,t,n,i){var o=this;if(n||(n=0),i||0===i||(i=this.length),t||(t=0),i!==n&&0!==e.length&&0!==o.length){q(i>=n,"sourceEnd < sourceStart"),q(t>=0&&t<e.length,"targetStart out of bounds"),q(n>=0&&n<o.length,"sourceStart out of bounds"),q(i>=0&&i<=o.length,"sourceEnd out of bounds"),i>this.length&&(i=this.length),e.length-t<i-n&&(i=e.length-t+n);var s=i-n;if(100>s||!r._useTypedArrays)for(var a=0;s>a;a++)e[a+t]=this[a+n];else e._set(this.subarray(n,n+s),t)}},r.prototype.slice=function(e,t){var n=this.length;if(e=B(e,n,0),t=B(t,n,n),r._useTypedArrays)return r._augment(this.subarray(e,t));for(var i=t-e,o=new r(i,void 0,!0),s=0;i>s;s++)o[s]=this[s+e];return o},r.prototype.get=function(e){return console.log(".get() is deprecated. Access using array indexes instead."),this.readUInt8(e)},r.prototype.set=function(e,t){return console.log(".set() is deprecated. Access using array indexes instead."),this.writeUInt8(e,t)},r.prototype.readUInt8=function(e,t){return t||(q(void 0!==e&&null!==e,"missing offset"),q(e<this.length,"Trying to read beyond buffer length")),e>=this.length?void 0:this[e]},r.prototype.readUInt16LE=function(e,t){return v(this,e,!0,t)},r.prototype.readUInt16BE=function(e,t){return v(this,e,!1,t)},r.prototype.readUInt32LE=function(e,t){return y(this,e,!0,t)},r.prototype.readUInt32BE=function(e,t){return y(this,e,!1,t)},r.prototype.readInt8=function(e,t){if(t||(q(void 0!==e&&null!==e,"missing offset"),q(e<this.length,"Trying to read beyond buffer length")),!(e>=this.length)){var n=128&this[e];return n?-1*(255-this[e]+1):this[e]}},r.prototype.readInt16LE=function(e,t){return b(this,e,!0,t)},r.prototype.readInt16BE=function(e,t){return b(this,e,!1,t)},r.prototype.readInt32LE=function(e,t){return m(this,e,!0,t)},r.prototype.readInt32BE=function(e,t){return m(this,e,!1,t)},r.prototype.readFloatLE=function(e,t){return w(this,e,!0,t)},r.prototype.readFloatBE=function(e,t){return w(this,e,!1,t)},r.prototype.readDoubleLE=function(e,t){return E(this,e,!0,t)},r.prototype.readDoubleBE=function(e,t){return E(this,e,!1,t)},r.prototype.writeUInt8=function(e,t,n){n||(q(void 0!==e&&null!==e,"missing value"),q(void 0!==t&&null!==t,"missing offset"),q(t<this.length,"trying to write beyond buffer length"),W(e,255)),t>=this.length||(this[t]=e)},r.prototype.writeUInt16LE=function(e,t,n){_(this,e,t,!0,n)},r.prototype.writeUInt16BE=function(e,t,n){_(this,e,t,!1,n)},r.prototype.writeUInt32LE=function(e,t,n){S(this,e,t,!0,n)},r.prototype.writeUInt32BE=function(e,t,n){S(this,e,t,!1,n)},r.prototype.writeInt8=function(e,t,n){n||(q(void 0!==e&&null!==e,"missing value"),q(void 0!==t&&null!==t,"missing offset"),q(t<this.length,"Trying to write beyond buffer length"),F(e,127,-128)),t>=this.length||(e>=0?this.writeUInt8(e,t,n):this.writeUInt8(255+e+1,t,n))},r.prototype.writeInt16LE=function(e,t,n){L(this,e,t,!0,n)},r.prototype.writeInt16BE=function(e,t,n){L(this,e,t,!1,n)},r.prototype.writeInt32LE=function(e,t,n){I(this,e,t,!0,n)},r.prototype.writeInt32BE=function(e,t,n){I(this,e,t,!1,n)},r.prototype.writeFloatLE=function(e,t,n){j(this,e,t,!0,n)},r.prototype.writeFloatBE=function(e,t,n){j(this,e,t,!1,n)},r.prototype.writeDoubleLE=function(e,t,n){k(this,e,t,!0,n)},r.prototype.writeDoubleBE=function(e,t,n){k(this,e,t,!1,n)},r.prototype.fill=function(e,t,n){if(e||(e=0),t||(t=0),n||(n=this.length),"string"==typeof e&&(e=e.charCodeAt(0)),q("number"==typeof e&&!isNaN(e),"value is not a number"),q(n>=t,"end < start"),n!==t&&0!==this.length){q(t>=0&&t<this.length,"start out of bounds"),q(n>=0&&n<=this.length,"end out of bounds");for(var r=t;n>r;r++)this[r]=e}},r.prototype.inspect=function(){for(var e=[],t=this.length,r=0;t>r;r++)if(e[r]=U(this[r]),r===n.INSPECT_MAX_BYTES){e[r+1]="...";break}return"<Buffer "+e.join(" ")+">"},r.prototype.toArrayBuffer=function(){if("undefined"!=typeof Uint8Array){if(r._useTypedArrays)return new r(this).buffer;for(var e=new Uint8Array(this.length),t=0,n=e.length;n>t;t+=1)e[t]=this[t];return e.buffer}throw new Error("Buffer.toArrayBuffer not supported in this browser")};var $=r.prototype;r._augment=function(e){return e._isBuffer=!0,e._get=e.get,e._set=e.set,e.get=$.get,e.set=$.set,e.write=$.write,e.toString=$.toString,e.toLocaleString=$.toString,e.toJSON=$.toJSON,e.copy=$.copy,e.slice=$.slice,e.readUInt8=$.readUInt8,e.readUInt16LE=$.readUInt16LE,e.readUInt16BE=$.readUInt16BE,e.readUInt32LE=$.readUInt32LE,e.readUInt32BE=$.readUInt32BE,e.readInt8=$.readInt8,e.readInt16LE=$.readInt16LE,e.readInt16BE=$.readInt16BE,e.readInt32LE=$.readInt32LE,e.readInt32BE=$.readInt32BE,e.readFloatLE=$.readFloatLE,e.readFloatBE=$.readFloatBE,e.readDoubleLE=$.readDoubleLE,e.readDoubleBE=$.readDoubleBE,e.writeUInt8=$.writeUInt8,e.writeUInt16LE=$.writeUInt16LE,e.writeUInt16BE=$.writeUInt16BE,e.writeUInt32LE=$.writeUInt32LE,e.writeUInt32BE=$.writeUInt32BE,e.writeInt8=$.writeInt8,e.writeInt16LE=$.writeInt16LE,e.writeInt16BE=$.writeInt16BE,e.writeInt32LE=$.writeInt32LE,e.writeInt32BE=$.writeInt32BE,e.writeFloatLE=$.writeFloatLE,e.writeFloatBE=$.writeFloatBE,e.writeDoubleLE=$.writeDoubleLE,e.writeDoubleBE=$.writeDoubleBE,e.fill=$.fill,e.inspect=$.inspect,e.toArrayBuffer=$.toArrayBuffer,e}},{"base64-js":4,ieee754:5}],4:[function(e,t,n){var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";!function(e){"use strict";function t(e){var t=e.charCodeAt(0);return t===s?62:t===a?63:u>t?-1:u+10>t?t-u+26+26:c+26>t?t-c:f+26>t?t-f+26:void 0}function n(e){function n(e){f[l++]=e}var r,i,s,a,u,f;if(e.length%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var c=e.length;u="="===e.charAt(c-2)?2:"="===e.charAt(c-1)?1:0,f=new o(3*e.length/4-u),s=u>0?e.length-4:e.length;var l=0;for(r=0,i=0;s>r;r+=4,i+=3)a=t(e.charAt(r))<<18|t(e.charAt(r+1))<<12|t(e.charAt(r+2))<<6|t(e.charAt(r+3)),n((16711680&a)>>16),n((65280&a)>>8),n(255&a);return 2===u?(a=t(e.charAt(r))<<2|t(e.charAt(r+1))>>4,n(255&a)):1===u&&(a=t(e.charAt(r))<<10|t(e.charAt(r+1))<<4|t(e.charAt(r+2))>>2,n(a>>8&255),n(255&a)),f}function i(e){function t(e){return r.charAt(e)}function n(e){return t(e>>18&63)+t(e>>12&63)+t(e>>6&63)+t(63&e)}var i,o,s,a=e.length%3,u="";for(i=0,s=e.length-a;s>i;i+=3)o=(e[i]<<16)+(e[i+1]<<8)+e[i+2],u+=n(o);switch(a){case 1:o=e[e.length-1],u+=t(o>>2),u+=t(o<<4&63),u+="==";break;case 2:o=(e[e.length-2]<<8)+e[e.length-1],u+=t(o>>10),u+=t(o>>4&63),u+=t(o<<2&63),u+="="}return u}var o="undefined"!=typeof Uint8Array?Uint8Array:Array,s="+".charCodeAt(0),a="/".charCodeAt(0),u="0".charCodeAt(0),f="a".charCodeAt(0),c="A".charCodeAt(0);e.toByteArray=n,e.fromByteArray=i}("undefined"==typeof n?this.base64js={}:n)},{}],5:[function(e,t,n){n.read=function(e,t,n,r,i){var o,s,a=8*i-r-1,u=(1<<a)-1,f=u>>1,c=-7,l=n?i-1:0,h=n?-1:1,d=e[t+l];for(l+=h,o=d&(1<<-c)-1,d>>=-c,c+=a;c>0;o=256*o+e[t+l],l+=h,c-=8);for(s=o&(1<<-c)-1,o>>=-c,c+=r;c>0;s=256*s+e[t+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===u)return s?0/0:1/0*(d?-1:1);s+=Math.pow(2,r),o-=f}return(d?-1:1)*s*Math.pow(2,o-r)},n.write=function(e,t,n,r,i,o){var s,a,u,f=8*o-i-1,c=(1<<f)-1,l=c>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:o-1,p=r?1:-1,g=0>t||0===t&&0>1/t?1:0;for(t=Math.abs(t),isNaN(t)||1/0===t?(a=isNaN(t)?1:0,s=c):(s=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-s))<1&&(s--,u*=2),t+=s+l>=1?h/u:h*Math.pow(2,1-l),t*u>=2&&(s++,u/=2),s+l>=c?(a=0,s=c):s+l>=1?(a=(t*u-1)*Math.pow(2,i),s+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),s=0));i>=8;e[n+d]=255&a,d+=p,a/=256,i-=8);for(s=s<<i|a,f+=i;f>0;e[n+d]=255&s,d+=p,s/=256,f-=8);e[n+d-p]|=128*g}},{}],6:[function(e,t){function n(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}function r(e){return"function"==typeof e}function i(e){return"number"==typeof e}function o(e){return"object"==typeof e&&null!==e}function s(e){return void 0===e}t.exports=n,n.EventEmitter=n,n.prototype._events=void 0,n.prototype._maxListeners=void 0,n.defaultMaxListeners=10,n.prototype.setMaxListeners=function(e){if(!i(e)||0>e||isNaN(e))throw TypeError("n must be a positive number");return this._maxListeners=e,this},n.prototype.emit=function(e){var t,n,i,a,u,f;if(this._events||(this._events={}),"error"===e&&(!this._events.error||o(this._events.error)&&!this._events.error.length))throw t=arguments[1],t instanceof Error?t:TypeError('Uncaught, unspecified "error" event.');if(n=this._events[e],s(n))return!1;if(r(n))switch(arguments.length){case 1:n.call(this);break;case 2:n.call(this,arguments[1]);break;case 3:n.call(this,arguments[1],arguments[2]);break;default:for(i=arguments.length,a=new Array(i-1),u=1;i>u;u++)a[u-1]=arguments[u];n.apply(this,a)}else if(o(n)){for(i=arguments.length,a=new Array(i-1),u=1;i>u;u++)a[u-1]=arguments[u];for(f=n.slice(),i=f.length,u=0;i>u;u++)f[u].apply(this,a)}return!0},n.prototype.addListener=function(e,t){var i;if(!r(t))throw TypeError("listener must be a function");if(this._events||(this._events={}),this._events.newListener&&this.emit("newListener",e,r(t.listener)?t.listener:t),this._events[e]?o(this._events[e])?this._events[e].push(t):this._events[e]=[this._events[e],t]:this._events[e]=t,o(this._events[e])&&!this._events[e].warned){var i;i=s(this._maxListeners)?n.defaultMaxListeners:this._maxListeners,i&&i>0&&this._events[e].length>i&&(this._events[e].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[e].length),"function"==typeof console.trace&&console.trace())}return this},n.prototype.on=n.prototype.addListener,n.prototype.once=function(e,t){function n(){this.removeListener(e,n),i||(i=!0,t.apply(this,arguments))}if(!r(t))throw TypeError("listener must be a function");var i=!1;return n.listener=t,this.on(e,n),this},n.prototype.removeListener=function(e,t){var n,i,s,a;if(!r(t))throw TypeError("listener must be a function");if(!this._events||!this._events[e])return this;if(n=this._events[e],s=n.length,i=-1,n===t||r(n.listener)&&n.listener===t)delete this._events[e],this._events.removeListener&&this.emit("removeListener",e,t);else if(o(n)){for(a=s;a-->0;)if(n[a]===t||n[a].listener&&n[a].listener===t){i=a;break}if(0>i)return this;1===n.length?(n.length=0,delete this._events[e]):n.splice(i,1),this._events.removeListener&&this.emit("removeListener",e,t)}return this},n.prototype.removeAllListeners=function(e){var t,n;if(!this._events)return this;if(!this._events.removeListener)return 0===arguments.length?this._events={}:this._events[e]&&delete this._events[e],this;if(0===arguments.length){for(t in this._events)"removeListener"!==t&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events={},this}if(n=this._events[e],r(n))this.removeListener(e,n);else for(;n.length;)this.removeListener(e,n[n.length-1]);return delete this._events[e],this},n.prototype.listeners=function(e){var t;return t=this._events&&this._events[e]?r(this._events[e])?[this._events[e]]:this._events[e].slice():[]},n.listenerCount=function(e,t){var n;return n=e._events&&e._events[t]?r(e._events[t])?1:e._events[t].length:0}},{}],7:[function(e,t){t.exports="function"==typeof Object.create?function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},{}],8:[function(e,t){function n(){}var r=t.exports={};r.nextTick=function(){var e="undefined"!=typeof window&&window.setImmediate,t="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(e)return function(e){return window.setImmediate(e)};if(t){var n=[];return window.addEventListener("message",function(e){var t=e.source;if((t===window||null===t)&&"process-tick"===e.data&&(e.stopPropagation(),n.length>0)){var r=n.shift();r()}},!0),function(e){n.push(e),window.postMessage("process-tick","*")}}return function(e){setTimeout(e,0)}}(),r.title="browser",r.browser=!0,r.env={},r.argv=[],r.on=n,r.addListener=n,r.once=n,r.off=n,r.removeListener=n,r.removeAllListeners=n,r.emit=n,r.binding=function(){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(){throw new Error("process.chdir is not supported")}},{}],9:[function(e,t){function n(e){return this instanceof n?(s.call(this,e),a.call(this,e),e&&e.readable===!1&&(this.readable=!1),e&&e.writable===!1&&(this.writable=!1),this.allowHalfOpen=!0,e&&e.allowHalfOpen===!1&&(this.allowHalfOpen=!1),void this.once("end",r)):new n(e)}function r(){if(!this.allowHalfOpen&&!this._writableState.ended){var e=this;o(function(){e.end()})}}t.exports=n;var i=e("inherits"),o=e("process/browser.js").nextTick,s=e("./readable.js"),a=e("./writable.js");i(n,s),n.prototype.write=a.prototype.write,n.prototype.end=a.prototype.end,n.prototype._write=a.prototype._write},{"./readable.js":13,"./writable.js":15,inherits:7,"process/browser.js":11}],10:[function(e,t){function n(){r.call(this)}t.exports=n;var r=e("events").EventEmitter,i=e("inherits");i(n,r),n.Readable=e("./readable.js"),n.Writable=e("./writable.js"),n.Duplex=e("./duplex.js"),n.Transform=e("./transform.js"),n.PassThrough=e("./passthrough.js"),n.Stream=n,n.prototype.pipe=function(e,t){function n(t){e.writable&&!1===e.write(t)&&f.pause&&f.pause()}function i(){f.readable&&f.resume&&f.resume()}function o(){c||(c=!0,e.end())}function s(){c||(c=!0,"function"==typeof e.destroy&&e.destroy())}function a(e){if(u(),0===r.listenerCount(this,"error"))throw e}function u(){f.removeListener("data",n),e.removeListener("drain",i),f.removeListener("end",o),f.removeListener("close",s),f.removeListener("error",a),e.removeListener("error",a),f.removeListener("end",u),f.removeListener("close",u),e.removeListener("close",u)}var f=this;f.on("data",n),e.on("drain",i),e._isStdio||t&&t.end===!1||(f.on("end",o),f.on("close",s));var c=!1;return f.on("error",a),e.on("error",a),f.on("end",u),f.on("close",u),e.on("close",u),e.emit("pipe",f),e}},{"./duplex.js":9,"./passthrough.js":12,"./readable.js":13,"./transform.js":14,"./writable.js":15,events:6,inherits:7}],11:[function(e,t){var n=t.exports={};n.nextTick=function(){var e="undefined"!=typeof window&&window.setImmediate,t="undefined"!=typeof window&&window.postMessage&&window.addEventListener;if(e)return function(e){return window.setImmediate(e)};if(t){var n=[];return window.addEventListener("message",function(e){var t=e.source;if((t===window||null===t)&&"process-tick"===e.data&&(e.stopPropagation(),n.length>0)){var r=n.shift();r()}},!0),function(e){n.push(e),window.postMessage("process-tick","*")}}return function(e){setTimeout(e,0)}}(),n.title="browser",n.browser=!0,n.env={},n.argv=[],n.binding=function(){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(){throw new Error("process.chdir is not supported")}},{}],12:[function(e,t){function n(e){return this instanceof n?void r.call(this,e):new n(e)}t.exports=n;var r=e("./transform.js"),i=e("inherits");i(n,r),n.prototype._transform=function(e,t,n){n(null,e)}},{"./transform.js":14,inherits:7}],13:[function(e,t){(function(n){function r(t){t=t||{};var n=t.highWaterMark;this.highWaterMark=n||0===n?n:16384,this.highWaterMark=~~this.highWaterMark,this.buffer=[],this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=!1,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.calledRead=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.objectMode=!!t.objectMode,this.defaultEncoding=t.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(S||(S=e("string_decoder").StringDecoder),this.decoder=new S(t.encoding),this.encoding=t.encoding)}function i(e){return this instanceof i?(this._readableState=new r(e,this),this.readable=!0,void I.call(this)):new i(e)}function o(e,t,n,r,i){var o=f(t,n);if(o)e.emit("error",o);else if(null===n||void 0===n)t.reading=!1,t.ended||c(e,t);else if(t.objectMode||n&&n.length>0)if(t.ended&&!i){var a=new Error("stream.push() after EOF");e.emit("error",a)}else if(t.endEmitted&&i){var a=new Error("stream.unshift() after end event");e.emit("error",a)}else!t.decoder||i||r||(n=t.decoder.write(n)),t.length+=t.objectMode?1:n.length,i?t.buffer.unshift(n):(t.reading=!1,t.buffer.push(n)),t.needReadable&&l(e),d(e,t);else i||(t.reading=!1);return s(t)}function s(e){return!e.ended&&(e.needReadable||e.length<e.highWaterMark||0===e.length)}function a(e){if(e>=B)e=B;else{e--;for(var t=1;32>t;t<<=1)e|=e>>t;e++}return e}function u(e,t){return 0===t.length&&t.ended?0:t.objectMode?0===e?0:1:isNaN(e)||null===e?t.flowing&&t.buffer.length?t.buffer[0].length:t.length:0>=e?0:(e>t.highWaterMark&&(t.highWaterMark=a(e)),e>t.length?t.ended?t.length:(t.needReadable=!0,0):e)}function f(e,t){var n=null;return j.isBuffer(t)||"string"==typeof t||null===t||void 0===t||e.objectMode||n||(n=new TypeError("Invalid non-string/buffer chunk")),n}function c(e,t){if(t.decoder&&!t.ended){var n=t.decoder.end();n&&n.length&&(t.buffer.push(n),t.length+=t.objectMode?1:n.length)}t.ended=!0,t.length>0?l(e):w(e)}function l(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,t.sync?k(function(){h(e)}):h(e))}function h(e){e.emit("readable")}function d(e,t){t.readingMore||(t.readingMore=!0,k(function(){p(e,t)}))}function p(e,t){for(var n=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length<t.highWaterMark&&(e.read(0),n!==t.length);)n=t.length;t.readingMore=!1}function g(e){return function(){var t=e._readableState;t.awaitDrain--,0===t.awaitDrain&&v(e)}}function v(e){function t(e){var t=e.write(n);!1===t&&r.awaitDrain++}var n,r=e._readableState;for(r.awaitDrain=0;r.pipesCount&&null!==(n=e.read());)if(1===r.pipesCount?t(r.pipes,0,null):E(r.pipes,t),e.emit("data",n),r.awaitDrain>0)return;return 0===r.pipesCount?(r.flowing=!1,void(L.listenerCount(e,"data")>0&&b(e))):void(r.ranOut=!0)}function y(){this._readableState.ranOut&&(this._readableState.ranOut=!1,v(this))}function b(e,t){var n=e._readableState;if(n.flowing)throw new Error("Cannot switch to old mode now.");var r=t||!1,i=!1;e.readable=!0,e.pipe=I.prototype.pipe,e.on=e.addListener=I.prototype.on,e.on("readable",function(){i=!0;for(var t;!r&&null!==(t=e.read());)e.emit("data",t);null===t&&(i=!1,e._readableState.needReadable=!0)}),e.pause=function(){r=!0,this.emit("pause")},e.resume=function(){r=!1,i?k(function(){e.emit("readable")}):this.read(0),this.emit("resume")},e.emit("readable")}function m(e,t){var n,r=t.buffer,i=t.length,o=!!t.decoder,s=!!t.objectMode;if(0===r.length)return null;if(0===i)n=null;else if(s)n=r.shift();else if(!e||e>=i)n=o?r.join(""):j.concat(r,i),r.length=0;else if(e<r[0].length){var a=r[0];n=a.slice(0,e),r[0]=a.slice(e)}else if(e===r[0].length)n=r.shift();else{n=o?"":new j(e);for(var u=0,f=0,c=r.length;c>f&&e>u;f++){var a=r[0],l=Math.min(e-u,a.length);o?n+=a.slice(0,l):a.copy(n,u,0,l),l<a.length?r[0]=a.slice(l):r.shift(),u+=l}}return n}function w(e){var t=e._readableState;if(t.length>0)throw new Error("endReadable called on non-empty stream");!t.endEmitted&&t.calledRead&&(t.ended=!0,k(function(){t.endEmitted||0!==t.length||(t.endEmitted=!0,e.readable=!1,e.emit("end"))}))}function E(e,t){for(var n=0,r=e.length;r>n;n++)t(e[n],n)}function _(e,t){for(var n=0,r=e.length;r>n;n++)if(e[n]===t)return n;return-1}t.exports=i,i.ReadableState=r;var S,L=e("events").EventEmitter,I=e("./index.js"),j=e("buffer").Buffer,k=e("process/browser.js").nextTick,x=e("inherits");x(i,I),i.prototype.push=function(e,t){var n=this._readableState;return"string"!=typeof e||n.objectMode||(t=t||n.defaultEncoding,t!==n.encoding&&(e=new j(e,t),t="")),o(this,n,e,t,!1)},i.prototype.unshift=function(e){var t=this._readableState;return o(this,t,e,"",!0)},i.prototype.setEncoding=function(t){S||(S=e("string_decoder").StringDecoder),this._readableState.decoder=new S(t),this._readableState.encoding=t};var B=8388608;i.prototype.read=function(e){var t=this._readableState;t.calledRead=!0;var n=e;if(("number"!=typeof e||e>0)&&(t.emittedReadable=!1),0===e&&t.needReadable&&(t.length>=t.highWaterMark||t.ended))return l(this),null;if(e=u(e,t),0===e&&t.ended)return 0===t.length&&w(this),null;var r=t.needReadable;t.length-e<=t.highWaterMark&&(r=!0),(t.ended||t.reading)&&(r=!1),r&&(t.reading=!0,t.sync=!0,0===t.length&&(t.needReadable=!0),this._read(t.highWaterMark),t.sync=!1),r&&!t.reading&&(e=u(n,t));var i;return i=e>0?m(e,t):null,null===i&&(t.needReadable=!0,e=0),t.length-=e,0!==t.length||t.ended||(t.needReadable=!0),t.ended&&!t.endEmitted&&0===t.length&&w(this),i},i.prototype._read=function(){this.emit("error",new Error("not implemented"))},i.prototype.pipe=function(e,t){function r(e){e===c&&o()}function i(){e.end()}function o(){e.removeListener("close",a),e.removeListener("finish",u),e.removeListener("drain",p),e.removeListener("error",s),e.removeListener("unpipe",r),c.removeListener("end",i),c.removeListener("end",o),(!e._writableState||e._writableState.needDrain)&&p() | ||
}function s(t){f(),0===b&&0===L.listenerCount(e,"error")&&e.emit("error",t)}function a(){e.removeListener("finish",u),f()}function u(){e.removeListener("close",a),f()}function f(){c.unpipe(e)}var c=this,l=this._readableState;switch(l.pipesCount){case 0:l.pipes=e;break;case 1:l.pipes=[l.pipes,e];break;default:l.pipes.push(e)}l.pipesCount+=1;var h=(!t||t.end!==!1)&&e!==n.stdout&&e!==n.stderr,d=h?i:o;l.endEmitted?k(d):c.once("end",d),e.on("unpipe",r);var p=g(c);e.on("drain",p);var b=L.listenerCount(e,"error");return e.once("error",s),e.once("close",a),e.once("finish",u),e.emit("pipe",c),l.flowing||(this.on("readable",y),l.flowing=!0,k(function(){v(c)})),e},i.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,this.removeListener("readable",y),t.flowing=!1,e&&e.emit("unpipe",this),this);if(!e){var n=t.pipes,r=t.pipesCount;t.pipes=null,t.pipesCount=0,this.removeListener("readable",y),t.flowing=!1;for(var i=0;r>i;i++)n[i].emit("unpipe",this);return this}var i=_(t.pipes,e);return-1===i?this:(t.pipes.splice(i,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this),this)},i.prototype.on=function(e,t){var n=I.prototype.on.call(this,e,t);if("data"!==e||this._readableState.flowing||b(this),"readable"===e&&this.readable){var r=this._readableState;r.readableListening||(r.readableListening=!0,r.emittedReadable=!1,r.needReadable=!0,r.reading?r.length&&l(this,r):this.read(0))}return n},i.prototype.addListener=i.prototype.on,i.prototype.resume=function(){b(this),this.read(0),this.emit("resume")},i.prototype.pause=function(){b(this,!0),this.emit("pause")},i.prototype.wrap=function(e){var t=this._readableState,n=!1,r=this;e.on("end",function(){if(t.decoder&&!t.ended){var e=t.decoder.end();e&&e.length&&r.push(e)}r.push(null)}),e.on("data",function(i){if(t.decoder&&(i=t.decoder.write(i)),i&&(t.objectMode||i.length)){var o=r.push(i);o||(n=!0,e.pause())}});for(var i in e)"function"==typeof e[i]&&"undefined"==typeof this[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));var o=["error","close","destroy","pause","resume"];return E(o,function(t){e.on(t,function(e){return r.emit.apply(r,t,e)})}),r._read=function(){n&&(n=!1,e.resume())},r},i._fromList=m}).call(this,e("IrXUsu"))},{"./index.js":10,IrXUsu:8,buffer:3,events:6,inherits:7,"process/browser.js":11,string_decoder:16}],14:[function(e,t){function n(e,t){this.afterTransform=function(e,n){return r(t,e,n)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null}function r(e,t,n){var r=e._transformState;r.transforming=!1;var i=r.writecb;if(!i)return e.emit("error",new Error("no writecb in Transform class"));r.writechunk=null,r.writecb=null,null!==n&&void 0!==n&&e.push(n),i&&i(t);var o=e._readableState;o.reading=!1,(o.needReadable||o.length<o.highWaterMark)&&e._read(o.highWaterMark)}function i(e){if(!(this instanceof i))return new i(e);s.call(this,e);var t=(this._transformState=new n(e,this),this);this._readableState.needReadable=!0,this._readableState.sync=!1,this.once("finish",function(){"function"==typeof this._flush?this._flush(function(e){o(t,e)}):o(t)})}function o(e,t){if(t)return e.emit("error",t);var n=e._writableState,r=(e._readableState,e._transformState);if(n.length)throw new Error("calling transform done when ws.length != 0");if(r.transforming)throw new Error("calling transform done when still transforming");return e.push(null)}t.exports=i;var s=e("./duplex.js"),a=e("inherits");a(i,s),i.prototype.push=function(e,t){return this._transformState.needTransform=!1,s.prototype.push.call(this,e,t)},i.prototype._transform=function(){throw new Error("not implemented")},i.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},i.prototype._read=function(){var e=this._transformState;e.writechunk&&e.writecb&&!e.transforming?(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform)):e.needTransform=!0}},{"./duplex.js":9,inherits:7}],15:[function(e,t){function n(e,t,n){this.chunk=e,this.encoding=t,this.callback=n}function r(e,t){e=e||{};var n=e.highWaterMark;this.highWaterMark=n||0===n?n:16384,this.objectMode=!!e.objectMode,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var r=e.decodeStrings===!1;this.decodeStrings=!r,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){h(t,e)},this.writecb=null,this.writelen=0,this.buffer=[]}function i(e){return this instanceof i||this instanceof _.Duplex?(this._writableState=new r(e,this),this.writable=!0,void _.call(this)):new i(e)}function o(e,t,n){var r=new Error("write after end");e.emit("error",r),S(function(){n(r)})}function s(e,t,n,r){var i=!0;if(!L.isBuffer(n)&&"string"!=typeof n&&null!==n&&void 0!==n&&!t.objectMode){var o=new TypeError("Invalid non-string/buffer chunk");e.emit("error",o),S(function(){r(o)}),i=!1}return i}function a(e,t,n){return e.objectMode||e.decodeStrings===!1||"string"!=typeof t||(t=new L(t,n)),t}function u(e,t,r,i,o){r=a(t,r,i);var s=t.objectMode?1:r.length;t.length+=s;var u=t.length<t.highWaterMark;return t.needDrain=!u,t.writing?t.buffer.push(new n(r,i,o)):f(e,t,s,r,i,o),u}function f(e,t,n,r,i,o){t.writelen=n,t.writecb=o,t.writing=!0,t.sync=!0,e._write(r,i,t.onwrite),t.sync=!1}function c(e,t,n,r,i){n?S(function(){i(r)}):i(r),e.emit("error",r)}function l(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function h(e,t){var n=e._writableState,r=n.sync,i=n.writecb;if(l(n),t)c(e,n,r,t,i);else{var o=v(e,n);o||n.bufferProcessing||!n.buffer.length||g(e,n),r?S(function(){d(e,n,o,i)}):d(e,n,o,i)}}function d(e,t,n,r){n||p(e,t),r(),n&&y(e,t)}function p(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function g(e,t){t.bufferProcessing=!0;for(var n=0;n<t.buffer.length;n++){var r=t.buffer[n],i=r.chunk,o=r.encoding,s=r.callback,a=t.objectMode?1:i.length;if(f(e,t,a,i,o,s),t.writing){n++;break}}t.bufferProcessing=!1,n<t.buffer.length?t.buffer=t.buffer.slice(n):t.buffer.length=0}function v(e,t){return t.ending&&0===t.length&&!t.finished&&!t.writing}function y(e,t){var n=v(e,t);return n&&(t.finished=!0,e.emit("finish")),n}function b(e,t,n){t.ending=!0,y(e,t),n&&(t.finished?S(n):e.once("finish",n)),t.ended=!0}t.exports=i,i.WritableState=r;var m="undefined"!=typeof Uint8Array?function(e){return e instanceof Uint8Array}:function(e){return e&&e.constructor&&"Uint8Array"===e.constructor.name},w="undefined"!=typeof ArrayBuffer?function(e){return e instanceof ArrayBuffer}:function(e){return e&&e.constructor&&"ArrayBuffer"===e.constructor.name},E=e("inherits"),_=e("./index.js"),S=e("process/browser.js").nextTick,L=e("buffer").Buffer;E(i,_),i.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))},i.prototype.write=function(e,t,n){var r=this._writableState,i=!1;return"function"==typeof t&&(n=t,t=null),!L.isBuffer(e)&&m(e)&&(e=new L(e)),w(e)&&"undefined"!=typeof Uint8Array&&(e=new L(new Uint8Array(e))),L.isBuffer(e)?t="buffer":t||(t=r.defaultEncoding),"function"!=typeof n&&(n=function(){}),r.ended?o(this,r,n):s(this,r,e,n)&&(i=u(this,r,e,t,n)),i},i.prototype._write=function(e,t,n){n(new Error("not implemented"))},i.prototype.end=function(e,t,n){var r=this._writableState;"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),"undefined"!=typeof e&&null!==e&&this.write(e,t),r.ending||r.finished||b(this,r,n)}},{"./index.js":10,buffer:3,inherits:7,"process/browser.js":11}],16:[function(e,t,n){function r(e){if(e&&!a.isEncoding(e))throw new Error("Unknown encoding: "+e)}function i(e){return e.toString(this.encoding)}function o(e){var t=this.charReceived=e.length%2;return this.charLength=t?2:0,t}function s(e){var t=this.charReceived=e.length%3;return this.charLength=t?3:0,t}var a=e("buffer").Buffer,u=n.StringDecoder=function(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),r(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=o;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=s;break;default:return void(this.write=i)}this.charBuffer=new a(6),this.charReceived=0,this.charLength=0};u.prototype.write=function(e){for(var t="",n=0;this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,n,r),this.charReceived+=r-n,n=r,this.charReceived<this.charLength)return"";t=this.charBuffer.slice(0,this.charLength).toString(this.encoding);var i=t.charCodeAt(t.length-1);if(!(i>=55296&&56319>=i)){if(this.charReceived=this.charLength=0,r==e.length)return t;e=e.slice(r,e.length);break}this.charLength+=this.surrogateSize,t=""}var o=this.detectIncompleteChar(e),s=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-o,s),this.charReceived=o,s-=o),t+=e.toString(this.encoding,0,s);var s=t.length-1,i=t.charCodeAt(s);if(i>=55296&&56319>=i){var a=this.surrogateSize;return this.charLength+=a,this.charReceived+=a,this.charBuffer.copy(this.charBuffer,a,0,a),this.charBuffer.write(t.charAt(t.length-1),this.encoding),t.substring(0,s)}return t},u.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var n=e[e.length-t];if(1==t&&n>>5==6){this.charLength=2;break}if(2>=t&&n>>4==14){this.charLength=3;break}if(3>=t&&n>>3==30){this.charLength=4;break}}return t},u.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var n=this.charReceived,r=this.charBuffer,i=this.encoding;t+=r.slice(0,n).toString(i)}return t}},{buffer:3}],17:[function(e,t){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],18:[function(e,t,n){(function(t,r){function i(e,t){var r={seen:[],stylize:s};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),g(t)?r.showHidden=t:t&&n._extend(r,t),E(r.showHidden)&&(r.showHidden=!1),E(r.depth)&&(r.depth=2),E(r.colors)&&(r.colors=!1),E(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=o),u(r,e,r.depth)}function o(e,t){var n=i.styles[t];return n?"["+i.colors[n][0]+"m"+e+"["+i.colors[n][1]+"m":e}function s(e){return e}function a(e){var t={};return e.forEach(function(e){t[e]=!0}),t}function u(e,t,r){if(e.customInspect&&t&&j(t.inspect)&&t.inspect!==n.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(r,e);return m(i)||(i=u(e,i,r)),i}var o=f(e,t);if(o)return o;var s=Object.keys(t),g=a(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(t)),I(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return c(t);if(0===s.length){if(j(t)){var v=t.name?": "+t.name:"";return e.stylize("[Function"+v+"]","special")}if(_(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(L(t))return e.stylize(Date.prototype.toString.call(t),"date");if(I(t))return c(t)}var y="",b=!1,w=["{","}"];if(p(t)&&(b=!0,w=["[","]"]),j(t)){var E=t.name?": "+t.name:"";y=" [Function"+E+"]"}if(_(t)&&(y=" "+RegExp.prototype.toString.call(t)),L(t)&&(y=" "+Date.prototype.toUTCString.call(t)),I(t)&&(y=" "+c(t)),0===s.length&&(!b||0==t.length))return w[0]+y+w[1];if(0>r)return _(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var S;return S=b?l(e,t,r,g,s):s.map(function(n){return h(e,t,r,g,n,b)}),e.seen.pop(),d(S,y,w)}function f(e,t){if(E(t))return e.stylize("undefined","undefined");if(m(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return b(t)?e.stylize(""+t,"number"):g(t)?e.stylize(""+t,"boolean"):v(t)?e.stylize("null","null"):void 0}function c(e){return"["+Error.prototype.toString.call(e)+"]"}function l(e,t,n,r,i){for(var o=[],s=0,a=t.length;a>s;++s)o.push(A(t,String(s))?h(e,t,n,r,String(s),!0):"");return i.forEach(function(i){i.match(/^\d+$/)||o.push(h(e,t,n,r,i,!0))}),o}function h(e,t,n,r,i,o){var s,a,f;if(f=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]},f.get?a=f.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):f.set&&(a=e.stylize("[Setter]","special")),A(r,i)||(s="["+i+"]"),a||(e.seen.indexOf(f.value)<0?(a=v(n)?u(e,f.value,null):u(e,f.value,n-1),a.indexOf("\n")>-1&&(a=o?a.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+a.split("\n").map(function(e){return" "+e}).join("\n"))):a=e.stylize("[Circular]","special")),E(s)){if(o&&i.match(/^\d+$/))return a;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function d(e,t,n){var r=0,i=e.reduce(function(e,t){return r++,t.indexOf("\n")>=0&&r++,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}function p(e){return Array.isArray(e)}function g(e){return"boolean"==typeof e}function v(e){return null===e}function y(e){return null==e}function b(e){return"number"==typeof e}function m(e){return"string"==typeof e}function w(e){return"symbol"==typeof e}function E(e){return void 0===e}function _(e){return S(e)&&"[object RegExp]"===x(e)}function S(e){return"object"==typeof e&&null!==e}function L(e){return S(e)&&"[object Date]"===x(e)}function I(e){return S(e)&&("[object Error]"===x(e)||e instanceof Error)}function j(e){return"function"==typeof e}function k(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function x(e){return Object.prototype.toString.call(e)}function B(e){return 10>e?"0"+e.toString(10):e.toString(10)}function M(){var e=new Date,t=[B(e.getHours()),B(e.getMinutes()),B(e.getSeconds())].join(":");return[e.getDate(),O[e.getMonth()],t].join(" ")}function A(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var C=/%[sdj%]/g;n.format=function(e){if(!m(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(i(arguments[n]));return t.join(" ")}for(var n=1,r=arguments,o=r.length,s=String(e).replace(C,function(e){if("%%"===e)return"%";if(n>=o)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(t){return"[Circular]"}default:return e}}),a=r[n];o>n;a=r[++n])s+=v(a)||!S(a)?" "+a:" "+i(a);return s},n.deprecate=function(e,i){function o(){if(!s){if(t.throwDeprecation)throw new Error(i);t.traceDeprecation?console.trace(i):console.error(i),s=!0}return e.apply(this,arguments)}if(E(r.process))return function(){return n.deprecate(e,i).apply(this,arguments)};if(t.noDeprecation===!0)return e;var s=!1;return o};var U,T={};n.debuglog=function(e){if(E(U)&&(U=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!T[e])if(new RegExp("\\b"+e+"\\b","i").test(U)){var r=t.pid;T[e]=function(){var t=n.format.apply(n,arguments);console.error("%s %d: %s",e,r,t)}}else T[e]=function(){};return T[e]},n.inspect=i,i.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},i.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},n.isArray=p,n.isBoolean=g,n.isNull=v,n.isNullOrUndefined=y,n.isNumber=b,n.isString=m,n.isSymbol=w,n.isUndefined=E,n.isRegExp=_,n.isObject=S,n.isDate=L,n.isError=I,n.isFunction=j,n.isPrimitive=k,n.isBuffer=e("./support/isBuffer");var O=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];n.log=function(){console.log("%s - %s",M(),n.format.apply(n,arguments))},n.inherits=e("inherits"),n._extend=function(e,t){if(!t||!S(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}}).call(this,e("IrXUsu"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":17,IrXUsu:8,inherits:7}],19:[function(e,t){var n=e("lodash.keys"),r=e("lodash._objecttypes"),i=function(e,t,i){var o,s=e,a=s;if(!s)return a;for(var u=arguments,f=0,c="number"==typeof i?2:u.length;++f<c;)if(s=u[f],s&&r[typeof s])for(var l=-1,h=r[typeof s]&&n(s),d=h?h.length:0;++l<d;)o=h[l],"undefined"==typeof a[o]&&(a[o]=s[o]);return a};t.exports=i},{"lodash._objecttypes":20,"lodash.keys":21}],20:[function(e,t){var n={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1};t.exports=n},{}],21:[function(e,t){var n=e("lodash._isnative"),r=e("lodash.isobject"),i=e("lodash._shimkeys"),o=n(o=Object.keys)&&o,s=o?function(e){return r(e)?o(e):[]}:i;t.exports=s},{"lodash._isnative":22,"lodash._shimkeys":23,"lodash.isobject":24}],22:[function(e,t){function n(e){return"function"==typeof e&&o.test(e)}var r=Object.prototype,i=r.toString,o=RegExp("^"+String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$");t.exports=n},{}],23:[function(e,t){var n=e("lodash._objecttypes"),r=Object.prototype,i=r.hasOwnProperty,o=function(e){var t,r=e,o=[];if(!r)return o;if(!n[typeof e])return o;for(t in r)i.call(r,t)&&o.push(t);return o};t.exports=o},{"lodash._objecttypes":20}],24:[function(e,t){function n(e){return!(!e||!r[typeof e])}var r=e("lodash._objecttypes");t.exports=n},{"lodash._objecttypes":20}],25:[function(e,t){function n(e,t){var n;return n=t?new i(e,t):new i(e)}var r=function(){return this}(),i=r.WebSocket||r.MozWebSocket;t.exports=i?n:null,i&&(n.prototype=i.prototype)},{}],26:[function(e,t){"use strict";function n(e,t,n){this.port=e||8182,this.host=t||"localhost",this.options=u.defaults(n||{},{language:"gremlin-groovy",session:!1}),this.useSession=this.options.session,this.useSession&&(this.sessionId=a.create().value),this.connected=!1,this.queue=[],this.commands={},this.ws=new s("ws://"+this.host+":"+this.port),this.ws.onopen=this.onConnectionOpen.bind(this),this.ws.onerror=function(e){console.log("Error:",e)},this.ws.onmessage=this.handleMessage.bind(this),this.ws.onclose=this.handleDisconnection.bind(this)}var r=e("events").EventEmitter,i=e("util").inherits,o=e("stream").Stream,s=e("ws"),a=e("guid"),u={defaults:e("lodash.defaults")};i(n,r),n.prototype.handleMessage=function(e){var t=JSON.parse(e.data||e),n=this.commands[t.requestId];switch(t.code){case 200:n.onData(t);break;case 299:t.result=n.result,delete this.commands[t.requestId],n.onEnd(t)}},n.prototype.onConnectionOpen=function(){this.connected=!0,this.emit("connect"),this.executeQueue()},n.prototype.handleDisconnection=function(e){this.cancelPendingCommands({message:"WebSocket closed",details:e})},n.prototype.executeQueue=function(){for(var e;this.queue.length>0;)e=this.queue.shift(),this.sendMessage(e)},n.prototype.cancelPendingCommands=function(e){var t,n=this.commands,r=new Error(e.message);r.details=e.details,this.queue.length=0,this.commands={},Object.keys(n).forEach(function(e){t=n[e],t.terminate(r)})},n.prototype.buildCommand=function(e,t,n){var r=a.create().value;t=t||{};var i={message:{requestId:r,processor:"",op:"eval",args:{gremlin:e,bindings:t,accept:"application/json",language:this.options.language}},onData:n.onData,onEnd:n.onEnd,terminate:n.terminate,result:[]};return this.useSession&&(i.message.processor="session",i.message.args.session=this.sessionId),i},n.prototype.sendMessage=function(e){this.ws.send(JSON.stringify(e.message))},n.prototype.extractFunctionBody=function(e){var t=e.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}"))},n.prototype.execute=function(e,t,n){"function"==typeof e&&(e=this.extractFunctionBody(e)),"function"==typeof t&&(n=t);var r=this.buildCommand(e,t,{onData:function(e){this.result=this.result.concat(e.result)},onEnd:function(e){return n(null,e)},terminate:function(e){return n(e)}});this.sendCommand(r)},n.prototype.stream=function(e,t){"function"==typeof e&&(e=this.extractFunctionBody(e));var n=new o,r=this.buildCommand(e,t,{onData:function(e){n.emit("data",e),n.emit("result",e.result,e)},onEnd:function(e){n.emit("end",e)},terminate:function(e){n.emit("error",e)}});return this.sendCommand(r),n},n.prototype.sendCommand=function(e){this.commands[e.message.requestId]=e,this.connected?this.sendMessage(e):this.queue.push(e)},t.exports=n},{events:6,guid:2,"lodash.defaults":19,stream:10,util:18,ws:25}]},{},[1])(1)}); | ||
}function s(t){f(),0===b&&0===L.listenerCount(e,"error")&&e.emit("error",t)}function a(){e.removeListener("finish",u),f()}function u(){e.removeListener("close",a),f()}function f(){c.unpipe(e)}var c=this,l=this._readableState;switch(l.pipesCount){case 0:l.pipes=e;break;case 1:l.pipes=[l.pipes,e];break;default:l.pipes.push(e)}l.pipesCount+=1;var h=(!t||t.end!==!1)&&e!==n.stdout&&e!==n.stderr,d=h?i:o;l.endEmitted?k(d):c.once("end",d),e.on("unpipe",r);var p=g(c);e.on("drain",p);var b=L.listenerCount(e,"error");return e.once("error",s),e.once("close",a),e.once("finish",u),e.emit("pipe",c),l.flowing||(this.on("readable",y),l.flowing=!0,k(function(){v(c)})),e},i.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,this.removeListener("readable",y),t.flowing=!1,e&&e.emit("unpipe",this),this);if(!e){var n=t.pipes,r=t.pipesCount;t.pipes=null,t.pipesCount=0,this.removeListener("readable",y),t.flowing=!1;for(var i=0;r>i;i++)n[i].emit("unpipe",this);return this}var i=_(t.pipes,e);return-1===i?this:(t.pipes.splice(i,1),t.pipesCount-=1,1===t.pipesCount&&(t.pipes=t.pipes[0]),e.emit("unpipe",this),this)},i.prototype.on=function(e,t){var n=I.prototype.on.call(this,e,t);if("data"!==e||this._readableState.flowing||b(this),"readable"===e&&this.readable){var r=this._readableState;r.readableListening||(r.readableListening=!0,r.emittedReadable=!1,r.needReadable=!0,r.reading?r.length&&l(this,r):this.read(0))}return n},i.prototype.addListener=i.prototype.on,i.prototype.resume=function(){b(this),this.read(0),this.emit("resume")},i.prototype.pause=function(){b(this,!0),this.emit("pause")},i.prototype.wrap=function(e){var t=this._readableState,n=!1,r=this;e.on("end",function(){if(t.decoder&&!t.ended){var e=t.decoder.end();e&&e.length&&r.push(e)}r.push(null)}),e.on("data",function(i){if(t.decoder&&(i=t.decoder.write(i)),i&&(t.objectMode||i.length)){var o=r.push(i);o||(n=!0,e.pause())}});for(var i in e)"function"==typeof e[i]&&"undefined"==typeof this[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));var o=["error","close","destroy","pause","resume"];return E(o,function(t){e.on(t,function(e){return r.emit.apply(r,t,e)})}),r._read=function(){n&&(n=!1,e.resume())},r},i._fromList=m}).call(this,e("IrXUsu"))},{"./index.js":10,IrXUsu:8,buffer:3,events:6,inherits:7,"process/browser.js":11,string_decoder:16}],14:[function(e,t){function n(e,t){this.afterTransform=function(e,n){return r(t,e,n)},this.needTransform=!1,this.transforming=!1,this.writecb=null,this.writechunk=null}function r(e,t,n){var r=e._transformState;r.transforming=!1;var i=r.writecb;if(!i)return e.emit("error",new Error("no writecb in Transform class"));r.writechunk=null,r.writecb=null,null!==n&&void 0!==n&&e.push(n),i&&i(t);var o=e._readableState;o.reading=!1,(o.needReadable||o.length<o.highWaterMark)&&e._read(o.highWaterMark)}function i(e){if(!(this instanceof i))return new i(e);s.call(this,e);var t=(this._transformState=new n(e,this),this);this._readableState.needReadable=!0,this._readableState.sync=!1,this.once("finish",function(){"function"==typeof this._flush?this._flush(function(e){o(t,e)}):o(t)})}function o(e,t){if(t)return e.emit("error",t);var n=e._writableState,r=(e._readableState,e._transformState);if(n.length)throw new Error("calling transform done when ws.length != 0");if(r.transforming)throw new Error("calling transform done when still transforming");return e.push(null)}t.exports=i;var s=e("./duplex.js"),a=e("inherits");a(i,s),i.prototype.push=function(e,t){return this._transformState.needTransform=!1,s.prototype.push.call(this,e,t)},i.prototype._transform=function(){throw new Error("not implemented")},i.prototype._write=function(e,t,n){var r=this._transformState;if(r.writecb=n,r.writechunk=e,r.writeencoding=t,!r.transforming){var i=this._readableState;(r.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},i.prototype._read=function(){var e=this._transformState;e.writechunk&&e.writecb&&!e.transforming?(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform)):e.needTransform=!0}},{"./duplex.js":9,inherits:7}],15:[function(e,t){function n(e,t,n){this.chunk=e,this.encoding=t,this.callback=n}function r(e,t){e=e||{};var n=e.highWaterMark;this.highWaterMark=n||0===n?n:16384,this.objectMode=!!e.objectMode,this.highWaterMark=~~this.highWaterMark,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1;var r=e.decodeStrings===!1;this.decodeStrings=!r,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){h(t,e)},this.writecb=null,this.writelen=0,this.buffer=[]}function i(e){return this instanceof i||this instanceof _.Duplex?(this._writableState=new r(e,this),this.writable=!0,void _.call(this)):new i(e)}function o(e,t,n){var r=new Error("write after end");e.emit("error",r),S(function(){n(r)})}function s(e,t,n,r){var i=!0;if(!L.isBuffer(n)&&"string"!=typeof n&&null!==n&&void 0!==n&&!t.objectMode){var o=new TypeError("Invalid non-string/buffer chunk");e.emit("error",o),S(function(){r(o)}),i=!1}return i}function a(e,t,n){return e.objectMode||e.decodeStrings===!1||"string"!=typeof t||(t=new L(t,n)),t}function u(e,t,r,i,o){r=a(t,r,i);var s=t.objectMode?1:r.length;t.length+=s;var u=t.length<t.highWaterMark;return t.needDrain=!u,t.writing?t.buffer.push(new n(r,i,o)):f(e,t,s,r,i,o),u}function f(e,t,n,r,i,o){t.writelen=n,t.writecb=o,t.writing=!0,t.sync=!0,e._write(r,i,t.onwrite),t.sync=!1}function c(e,t,n,r,i){n?S(function(){i(r)}):i(r),e.emit("error",r)}function l(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}function h(e,t){var n=e._writableState,r=n.sync,i=n.writecb;if(l(n),t)c(e,n,r,t,i);else{var o=v(e,n);o||n.bufferProcessing||!n.buffer.length||g(e,n),r?S(function(){d(e,n,o,i)}):d(e,n,o,i)}}function d(e,t,n,r){n||p(e,t),r(),n&&y(e,t)}function p(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}function g(e,t){t.bufferProcessing=!0;for(var n=0;n<t.buffer.length;n++){var r=t.buffer[n],i=r.chunk,o=r.encoding,s=r.callback,a=t.objectMode?1:i.length;if(f(e,t,a,i,o,s),t.writing){n++;break}}t.bufferProcessing=!1,n<t.buffer.length?t.buffer=t.buffer.slice(n):t.buffer.length=0}function v(e,t){return t.ending&&0===t.length&&!t.finished&&!t.writing}function y(e,t){var n=v(e,t);return n&&(t.finished=!0,e.emit("finish")),n}function b(e,t,n){t.ending=!0,y(e,t),n&&(t.finished?S(n):e.once("finish",n)),t.ended=!0}t.exports=i,i.WritableState=r;var m="undefined"!=typeof Uint8Array?function(e){return e instanceof Uint8Array}:function(e){return e&&e.constructor&&"Uint8Array"===e.constructor.name},w="undefined"!=typeof ArrayBuffer?function(e){return e instanceof ArrayBuffer}:function(e){return e&&e.constructor&&"ArrayBuffer"===e.constructor.name},E=e("inherits"),_=e("./index.js"),S=e("process/browser.js").nextTick,L=e("buffer").Buffer;E(i,_),i.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe. Not readable."))},i.prototype.write=function(e,t,n){var r=this._writableState,i=!1;return"function"==typeof t&&(n=t,t=null),!L.isBuffer(e)&&m(e)&&(e=new L(e)),w(e)&&"undefined"!=typeof Uint8Array&&(e=new L(new Uint8Array(e))),L.isBuffer(e)?t="buffer":t||(t=r.defaultEncoding),"function"!=typeof n&&(n=function(){}),r.ended?o(this,r,n):s(this,r,e,n)&&(i=u(this,r,e,t,n)),i},i.prototype._write=function(e,t,n){n(new Error("not implemented"))},i.prototype.end=function(e,t,n){var r=this._writableState;"function"==typeof e?(n=e,e=null,t=null):"function"==typeof t&&(n=t,t=null),"undefined"!=typeof e&&null!==e&&this.write(e,t),r.ending||r.finished||b(this,r,n)}},{"./index.js":10,buffer:3,inherits:7,"process/browser.js":11}],16:[function(e,t,n){function r(e){if(e&&!a.isEncoding(e))throw new Error("Unknown encoding: "+e)}function i(e){return e.toString(this.encoding)}function o(e){var t=this.charReceived=e.length%2;return this.charLength=t?2:0,t}function s(e){var t=this.charReceived=e.length%3;return this.charLength=t?3:0,t}var a=e("buffer").Buffer,u=n.StringDecoder=function(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),r(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=o;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=s;break;default:return void(this.write=i)}this.charBuffer=new a(6),this.charReceived=0,this.charLength=0};u.prototype.write=function(e){for(var t="",n=0;this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,n,r),this.charReceived+=r-n,n=r,this.charReceived<this.charLength)return"";t=this.charBuffer.slice(0,this.charLength).toString(this.encoding);var i=t.charCodeAt(t.length-1);if(!(i>=55296&&56319>=i)){if(this.charReceived=this.charLength=0,r==e.length)return t;e=e.slice(r,e.length);break}this.charLength+=this.surrogateSize,t=""}var o=this.detectIncompleteChar(e),s=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-o,s),this.charReceived=o,s-=o),t+=e.toString(this.encoding,0,s);var s=t.length-1,i=t.charCodeAt(s);if(i>=55296&&56319>=i){var a=this.surrogateSize;return this.charLength+=a,this.charReceived+=a,this.charBuffer.copy(this.charBuffer,a,0,a),this.charBuffer.write(t.charAt(t.length-1),this.encoding),t.substring(0,s)}return t},u.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var n=e[e.length-t];if(1==t&&n>>5==6){this.charLength=2;break}if(2>=t&&n>>4==14){this.charLength=3;break}if(3>=t&&n>>3==30){this.charLength=4;break}}return t},u.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var n=this.charReceived,r=this.charBuffer,i=this.encoding;t+=r.slice(0,n).toString(i)}return t}},{buffer:3}],17:[function(e,t){t.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},{}],18:[function(e,t,n){(function(t,r){function i(e,t){var r={seen:[],stylize:s};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),g(t)?r.showHidden=t:t&&n._extend(r,t),E(r.showHidden)&&(r.showHidden=!1),E(r.depth)&&(r.depth=2),E(r.colors)&&(r.colors=!1),E(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=o),u(r,e,r.depth)}function o(e,t){var n=i.styles[t];return n?"["+i.colors[n][0]+"m"+e+"["+i.colors[n][1]+"m":e}function s(e){return e}function a(e){var t={};return e.forEach(function(e){t[e]=!0}),t}function u(e,t,r){if(e.customInspect&&t&&j(t.inspect)&&t.inspect!==n.inspect&&(!t.constructor||t.constructor.prototype!==t)){var i=t.inspect(r,e);return m(i)||(i=u(e,i,r)),i}var o=f(e,t);if(o)return o;var s=Object.keys(t),g=a(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(t)),I(t)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return c(t);if(0===s.length){if(j(t)){var v=t.name?": "+t.name:"";return e.stylize("[Function"+v+"]","special")}if(_(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(L(t))return e.stylize(Date.prototype.toString.call(t),"date");if(I(t))return c(t)}var y="",b=!1,w=["{","}"];if(p(t)&&(b=!0,w=["[","]"]),j(t)){var E=t.name?": "+t.name:"";y=" [Function"+E+"]"}if(_(t)&&(y=" "+RegExp.prototype.toString.call(t)),L(t)&&(y=" "+Date.prototype.toUTCString.call(t)),I(t)&&(y=" "+c(t)),0===s.length&&(!b||0==t.length))return w[0]+y+w[1];if(0>r)return _(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special");e.seen.push(t);var S;return S=b?l(e,t,r,g,s):s.map(function(n){return h(e,t,r,g,n,b)}),e.seen.pop(),d(S,y,w)}function f(e,t){if(E(t))return e.stylize("undefined","undefined");if(m(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return b(t)?e.stylize(""+t,"number"):g(t)?e.stylize(""+t,"boolean"):v(t)?e.stylize("null","null"):void 0}function c(e){return"["+Error.prototype.toString.call(e)+"]"}function l(e,t,n,r,i){for(var o=[],s=0,a=t.length;a>s;++s)o.push(A(t,String(s))?h(e,t,n,r,String(s),!0):"");return i.forEach(function(i){i.match(/^\d+$/)||o.push(h(e,t,n,r,i,!0))}),o}function h(e,t,n,r,i,o){var s,a,f;if(f=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]},f.get?a=f.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):f.set&&(a=e.stylize("[Setter]","special")),A(r,i)||(s="["+i+"]"),a||(e.seen.indexOf(f.value)<0?(a=v(n)?u(e,f.value,null):u(e,f.value,n-1),a.indexOf("\n")>-1&&(a=o?a.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+a.split("\n").map(function(e){return" "+e}).join("\n"))):a=e.stylize("[Circular]","special")),E(s)){if(o&&i.match(/^\d+$/))return a;s=JSON.stringify(""+i),s.match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function d(e,t,n){var r=0,i=e.reduce(function(e,t){return r++,t.indexOf("\n")>=0&&r++,e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0);return i>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}function p(e){return Array.isArray(e)}function g(e){return"boolean"==typeof e}function v(e){return null===e}function y(e){return null==e}function b(e){return"number"==typeof e}function m(e){return"string"==typeof e}function w(e){return"symbol"==typeof e}function E(e){return void 0===e}function _(e){return S(e)&&"[object RegExp]"===x(e)}function S(e){return"object"==typeof e&&null!==e}function L(e){return S(e)&&"[object Date]"===x(e)}function I(e){return S(e)&&("[object Error]"===x(e)||e instanceof Error)}function j(e){return"function"==typeof e}function k(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||"undefined"==typeof e}function x(e){return Object.prototype.toString.call(e)}function B(e){return 10>e?"0"+e.toString(10):e.toString(10)}function M(){var e=new Date,t=[B(e.getHours()),B(e.getMinutes()),B(e.getSeconds())].join(":");return[e.getDate(),O[e.getMonth()],t].join(" ")}function A(e,t){return Object.prototype.hasOwnProperty.call(e,t)}var C=/%[sdj%]/g;n.format=function(e){if(!m(e)){for(var t=[],n=0;n<arguments.length;n++)t.push(i(arguments[n]));return t.join(" ")}for(var n=1,r=arguments,o=r.length,s=String(e).replace(C,function(e){if("%%"===e)return"%";if(n>=o)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(t){return"[Circular]"}default:return e}}),a=r[n];o>n;a=r[++n])s+=v(a)||!S(a)?" "+a:" "+i(a);return s},n.deprecate=function(e,i){function o(){if(!s){if(t.throwDeprecation)throw new Error(i);t.traceDeprecation?console.trace(i):console.error(i),s=!0}return e.apply(this,arguments)}if(E(r.process))return function(){return n.deprecate(e,i).apply(this,arguments)};if(t.noDeprecation===!0)return e;var s=!1;return o};var U,T={};n.debuglog=function(e){if(E(U)&&(U=t.env.NODE_DEBUG||""),e=e.toUpperCase(),!T[e])if(new RegExp("\\b"+e+"\\b","i").test(U)){var r=t.pid;T[e]=function(){var t=n.format.apply(n,arguments);console.error("%s %d: %s",e,r,t)}}else T[e]=function(){};return T[e]},n.inspect=i,i.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},i.styles={special:"cyan",number:"yellow","boolean":"yellow",undefined:"grey","null":"bold",string:"green",date:"magenta",regexp:"red"},n.isArray=p,n.isBoolean=g,n.isNull=v,n.isNullOrUndefined=y,n.isNumber=b,n.isString=m,n.isSymbol=w,n.isUndefined=E,n.isRegExp=_,n.isObject=S,n.isDate=L,n.isError=I,n.isFunction=j,n.isPrimitive=k,n.isBuffer=e("./support/isBuffer");var O=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];n.log=function(){console.log("%s - %s",M(),n.format.apply(n,arguments))},n.inherits=e("inherits"),n._extend=function(e,t){if(!t||!S(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}}).call(this,e("IrXUsu"),"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./support/isBuffer":17,IrXUsu:8,inherits:7}],19:[function(e,t){var n=e("lodash.keys"),r=e("lodash._objecttypes"),i=function(e,t,i){var o,s=e,a=s;if(!s)return a;for(var u=arguments,f=0,c="number"==typeof i?2:u.length;++f<c;)if(s=u[f],s&&r[typeof s])for(var l=-1,h=r[typeof s]&&n(s),d=h?h.length:0;++l<d;)o=h[l],"undefined"==typeof a[o]&&(a[o]=s[o]);return a};t.exports=i},{"lodash._objecttypes":20,"lodash.keys":21}],20:[function(e,t){var n={"boolean":!1,"function":!0,object:!0,number:!1,string:!1,undefined:!1};t.exports=n},{}],21:[function(e,t){var n=e("lodash._isnative"),r=e("lodash.isobject"),i=e("lodash._shimkeys"),o=n(o=Object.keys)&&o,s=o?function(e){return r(e)?o(e):[]}:i;t.exports=s},{"lodash._isnative":22,"lodash._shimkeys":23,"lodash.isobject":24}],22:[function(e,t){function n(e){return"function"==typeof e&&o.test(e)}var r=Object.prototype,i=r.toString,o=RegExp("^"+String(i).replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/toString| for [^\]]+/g,".*?")+"$");t.exports=n},{}],23:[function(e,t){var n=e("lodash._objecttypes"),r=Object.prototype,i=r.hasOwnProperty,o=function(e){var t,r=e,o=[];if(!r)return o;if(!n[typeof e])return o;for(t in r)i.call(r,t)&&o.push(t);return o};t.exports=o},{"lodash._objecttypes":20}],24:[function(e,t){function n(e){return!(!e||!r[typeof e])}var r=e("lodash._objecttypes");t.exports=n},{"lodash._objecttypes":20}],25:[function(e,t){function n(e,t){var n;return n=t?new i(e,t):new i(e)}var r=function(){return this}(),i=r.WebSocket||r.MozWebSocket;t.exports=i?n:null,i&&(n.prototype=i.prototype)},{}],26:[function(e,t){"use strict";function n(e,t,n){this.port=e||8182,this.host=t||"localhost",this.options=u.defaults(n||{},{language:"gremlin-groovy",session:!1,op:"eval",processor:"",accept:"application/json"}),this.useSession=this.options.session,this.useSession&&(this.sessionId=a.create().value),this.connected=!1,this.queue=[],this.commands={},this.ws=new s("ws://"+this.host+":"+this.port),this.ws.onopen=this.onConnectionOpen.bind(this),this.ws.onerror=function(e){console.log("Error:",e)},this.ws.onmessage=this.handleMessage.bind(this),this.ws.onclose=this.handleDisconnection.bind(this)}var r=e("events").EventEmitter,i=e("util").inherits,o=e("stream").Stream,s=e("ws"),a=e("guid"),u={defaults:e("lodash.defaults")};i(n,r),n.prototype.handleMessage=function(e){var t=JSON.parse(e.data||e),n=this.commands[t.requestId];switch(t.code){case 200:n.onData(t);break;case 299:t.result=n.result,delete this.commands[t.requestId],n.onEnd(t.result,t)}},n.prototype.onConnectionOpen=function(){this.connected=!0,this.emit("connect"),this.executeQueue()},n.prototype.handleDisconnection=function(e){this.cancelPendingCommands({message:"WebSocket closed",details:e})},n.prototype.executeQueue=function(){for(var e;this.queue.length>0;)e=this.queue.shift(),this.sendMessage(e)},n.prototype.cancelPendingCommands=function(e){var t,n=this.commands,r=new Error(e.message);r.details=e.details,this.queue.length=0,this.commands={},Object.keys(n).forEach(function(e){t=n[e],t.terminate(r)})},n.prototype.buildCommand=function(e,t,n,r){var i=a.create().value;t=t||{};var o=u.defaults(n&&n.args||{},{gremlin:e,bindings:t,accept:this.options.accept,language:this.options.language});n=u.defaults(n||{},{requestId:i,processor:this.options.processor,op:this.options.op,args:o});var s={message:n,onData:r.onData,onEnd:r.onEnd,terminate:r.terminate,result:[]};return this.useSession&&(s.message.processor="session",s.message.args.session=this.sessionId),s},n.prototype.sendMessage=function(e){this.ws.send(JSON.stringify(e.message))},n.prototype.extractFunctionBody=function(e){var t=e.toString();return t=t.substring(t.indexOf("{")+1,t.lastIndexOf("}"))},n.prototype.execute=function(e,t,n,r){"function"==typeof e&&(e=this.extractFunctionBody(e)),"function"==typeof t&&(r=t,t={}),"function"==typeof n&&(r=n,n={});var i=this.buildCommand(e,t,n,{onData:function(e){this.result=this.result.concat(e.result)},onEnd:function(e,t){return r(null,e,t,this)},terminate:function(e){return r(e)}});this.sendCommand(i)},n.prototype.stream=function(e,t,n){"function"==typeof e&&(e=this.extractFunctionBody(e)),"function"==typeof n&&(n={});var r=new o,i=this.buildCommand(e,t,n,{onData:function(e){r.emit("data",e.result,e)},onEnd:function(e,t){r.emit("end",t)},terminate:function(e){r.emit("error",e)}});return this.sendCommand(i),r},n.prototype.sendCommand=function(e){this.commands[e.message.requestId]=e,this.connected?this.sendMessage(e):this.queue.push(e)},t.exports=n},{events:6,guid:2,"lodash.defaults":19,stream:10,util:18,ws:25}]},{},[1])(1)}); |
{ | ||
"name": "gremlin-client", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"description": "JavaScript client for TinkerPop3 Gremlin Server", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
106
README.md
@@ -24,3 +24,3 @@ gremlin-client | ||
### Set-up client | ||
### Creating a new client | ||
@@ -31,3 +31,3 @@ ```javascript | ||
``` | ||
same as: | ||
This is a shorthand for: | ||
```javascript | ||
@@ -37,3 +37,3 @@ var client = gremlin.createClient(8182, 'localhost'); | ||
If you want to use Gremlin-Server sessions, you can set the `session` argument as true in the `options` object: | ||
If you want to use Gremlin Server sessions, you can set the `session` argument as true in the `options` object: | ||
```javascript | ||
@@ -43,9 +43,17 @@ var client = gremlin.createClient(8182, 'localhost', { session: true }); | ||
The `options` object currently allows you to set two options: | ||
* `session`: whether to use sessions or not (default: `false`) | ||
* `language`: the script engine to use on the server, see your gremlin-server.yaml file (default: `"gremlin-groovy"`) | ||
* `op` (advanced usage): The name of the "operation" to execute based on the available OpProcessor (default: `"eval"`) | ||
* `processor` (advanced usage): The name of the OpProcessor to utilize (default: `""`) | ||
* `accept`: (default: `"application/json"`) | ||
### Sending scripts to Gremlin Server for execution | ||
The client supports two modes: streaming results, or traditional callback mode. | ||
### Stream mode: client.stream(script) | ||
#### Stream mode: client.stream(script) | ||
Return a Node.js stream which emits a `data` event with the raw data returned by Gremlin Server every time it receives a message. The stream simultaneously also emits a higher level `result` event. | ||
Return a Node.js stream which emits a `data` event with the raw data returned by Gremlin Server every time it receives a message (ie. the raw message returned by Gremlin Server). The stream simultaneously also emits a higher level `result` event, with `message.result` as a payload. | ||
The stream emits an `end` event when receiving the last, `type: 0` message. | ||
The stream emits an `end` event when the client receives the last `statusCode: 299` message. | ||
@@ -55,21 +63,69 @@ ```javascript | ||
query.on('result', function(result) { | ||
query.on('data', function(result, message) { | ||
console.log(result); | ||
}); | ||
// Alternatively: | ||
// query.on('data', function(message) { | ||
// console.log(message.result); | ||
// }); | ||
query.on('end', function(message) { | ||
console.log("All results fetched", message); | ||
}); | ||
query.on('end', function(msg) { | ||
console.log("All results fetched", msg); | ||
``` | ||
#### Callback mode: client.execute(script, callback) | ||
Will execute the provided callback when all results are actually returned from the server. | ||
```javascript | ||
var client = gremlin.createClient(); | ||
client.execute('g.V()', function(err, result, lastMessage, command) { | ||
if (!err) { | ||
console.log(result) | ||
} | ||
}); | ||
``` | ||
The client will internally concatenate all partial results returned over different messages (possibly, depending on the total number of results and the value of `resultIterationBatchSize` set in your .yaml file). | ||
When the client receives the final `statusCode: 299` message, the callback will be executed. | ||
### Adding bound parameters to your scripts | ||
For better performance and security concerns, you may wish to send bound parameters to your scripts. | ||
```javascript | ||
var client = gremlin.createClient(); | ||
client.execute('g.v(id)', { id: 1 }, function(err, result) { | ||
// Handle result | ||
}); | ||
``` | ||
### Callback mode: client.execute(script, callback) | ||
### Overriding low level settings on a per request basis | ||
Will execute the provided callback when all results are actually returned from the server. Until it receives the final `type: 0` message, the client will internally concatenate all partial results returned over different messages. | ||
For advanced usage, for example if you wish to set the `op` or `processor` values for a given request only, you may wish to override the client level settings in the raw message sent to Gremlin Server: | ||
```javascript | ||
client.execute('g.v(1)', null, { args: { language: 'nashorn' }}, function(err, result) { | ||
// Handle result | ||
}); | ||
``` | ||
Because we're not sending any bound parameters, notice how the second argument **must** be set to `null` so the low level message object is not mistaken with bound arguments. | ||
If you wish to also send bound parameters while overriding the low level message, you can do the following: | ||
```javascript | ||
client.execute('g.v(id)', { id: 1 }, { args: { language: 'nashorn' }}, function(err, result) { | ||
// Handle result | ||
}); | ||
``` | ||
The same method signature also applies to `client.stream()`: | ||
```javascript | ||
var s = client.stream(script, bindings, message); | ||
``` | ||
### Using Gremlin-JavaScript syntax with Nashorn | ||
@@ -82,7 +138,7 @@ | ||
gremlin-groovy: { | ||
imports: [java.lang.Math, org.apache.commons.math3.util.FastMath], | ||
imports: [java.lang.Math], | ||
staticImports: [java.lang.Math.PI], | ||
scripts: [scripts/generate-classic.groovy]}, | ||
nashorn: { | ||
imports: [java.lang.Math, org.apache.commons.math3.util.FastMath], | ||
imports: [java.lang.Math], | ||
staticImports: [java.lang.Math.PI]}} | ||
@@ -105,4 +161,4 @@ ``` | ||
// Send that script function body to Gremlin Server for execution in Nashorn engine | ||
client.execute(script, function(err, response) { | ||
// Handle response.results | ||
client.execute(script, function(err, result) { | ||
// Handle result | ||
}); | ||
@@ -113,14 +169,4 @@ ``` | ||
### Bound parameters | ||
Passing bound parameters and/or low level message will also work when using nashorn script engine. | ||
The following example shows how to send a Gremlin-Javascript formatted script to Gremlin Server with bound parameters using the stream API: | ||
```javascript | ||
var s = client.stream(function() { g.v(id); }, { id: 1 }); | ||
s.on('data', function(result) { | ||
// handle result | ||
}); | ||
``` | ||
## Running the Examples | ||
@@ -127,0 +173,0 @@ |
@@ -19,4 +19,7 @@ /*jslint -W079 */ | ||
this.options = _.defaults(options || {}, { | ||
language: "gremlin-groovy", | ||
session: false | ||
language: 'gremlin-groovy', | ||
session: false, | ||
op: 'eval', | ||
processor: '', | ||
accept: 'application/json' | ||
}); | ||
@@ -41,3 +44,3 @@ | ||
this.ws.onerror = function(e) { | ||
console.log("Error:", e); | ||
console.log('Error:', e); | ||
}; | ||
@@ -68,3 +71,3 @@ | ||
delete this.commands[message.requestId]; // TODO: optimize performance | ||
command.onEnd(message); | ||
command.onEnd(message.result, message); | ||
break; | ||
@@ -130,19 +133,28 @@ } | ||
* object to be sent to Gremlin Server. | ||
* | ||
* @param {String} script | ||
* @param {Object} bindings | ||
* @param {Object} message | ||
* @param {Object} handlers | ||
*/ | ||
GremlinClient.prototype.buildCommand = function(script, bindings, handlers) { | ||
GremlinClient.prototype.buildCommand = function(script, bindings, message, handlers) { | ||
var guid = Guid.create().value; | ||
bindings = bindings || {}; | ||
var args = _.defaults(message && message.args || {}, { | ||
gremlin: script, | ||
bindings: bindings, | ||
accept: this.options.accept, | ||
language: this.options.language, | ||
}); | ||
message = _.defaults(message || {}, { | ||
requestId: guid, | ||
processor: this.options.processor, | ||
op: this.options.op, | ||
args: args | ||
}); | ||
var command = { | ||
message: { | ||
requestId: guid, | ||
processor: "", | ||
op: "eval", | ||
args: { | ||
gremlin: script, | ||
bindings: bindings, | ||
accept: "application/json", | ||
language: this.options.language, | ||
} | ||
}, | ||
message: message, | ||
onData: handlers.onData, | ||
@@ -155,3 +167,3 @@ onEnd: handlers.onEnd, | ||
if (this.useSession) { | ||
command.message.processor = "session"; | ||
command.message.processor = 'session'; | ||
command.message.args.session = this.sessionId; | ||
@@ -175,3 +187,3 @@ } | ||
var body = fn.toString(); | ||
body = body.substring(body.indexOf("{") + 1, body.lastIndexOf("}")); | ||
body = body.substring(body.indexOf('{') + 1, body.lastIndexOf('}')); | ||
@@ -181,3 +193,3 @@ return body; | ||
GremlinClient.prototype.execute = function(script, bindings, callback) { | ||
GremlinClient.prototype.execute = function(script, bindings, message, callback) { | ||
if (typeof script === 'function') { | ||
@@ -187,12 +199,20 @@ script = this.extractFunctionBody(script); | ||
// Signature: script, callback | ||
if (typeof bindings === 'function') { | ||
callback = bindings; | ||
bindings = {}; | ||
} | ||
var command = this.buildCommand(script, bindings, { | ||
// Signature: script, bindings, callback | ||
if (typeof message === 'function') { | ||
callback = message; | ||
message = {}; | ||
} | ||
var command = this.buildCommand(script, bindings, message, { | ||
onData: function(message) { | ||
this.result = this.result.concat(message.result); | ||
}, | ||
onEnd: function(data) { | ||
return callback(null, data); | ||
onEnd: function(result, message) { | ||
return callback(null, result, message, this); | ||
}, | ||
@@ -207,3 +227,3 @@ terminate: function(error) { | ||
GremlinClient.prototype.stream = function(script, bindings) { | ||
GremlinClient.prototype.stream = function(script, bindings, message) { | ||
if (typeof script === 'function') { | ||
@@ -213,11 +233,14 @@ script = this.extractFunctionBody(script); | ||
if (typeof message === 'function') { | ||
message = {}; | ||
} | ||
var stream = new Stream(); | ||
var command = this.buildCommand(script, bindings, { | ||
var command = this.buildCommand(script, bindings, message, { | ||
onData: function(data) { | ||
stream.emit('data', data); | ||
stream.emit('result', data.result, data); | ||
stream.emit('data', data.result, data); | ||
}, | ||
onEnd: function(data) { | ||
stream.emit('end', data); | ||
onEnd: function(result, message) { | ||
stream.emit('end', message); | ||
}, | ||
@@ -224,0 +247,0 @@ terminate: function(error) { |
@@ -11,3 +11,6 @@ var gremlin = require('../'); | ||
language: 'gremlin-groovy', | ||
session: false | ||
session: false, | ||
op: 'eval', | ||
processor: '', | ||
accept: 'application/json' | ||
}); | ||
@@ -31,2 +34,36 @@ }); | ||
}); | ||
it('should allow setting the `op` option', function() { | ||
var client = gremlin.createClient({ op: 'test' }); | ||
client.port.should.equal(8182); | ||
client.host.should.equal('localhost'); | ||
client.options.op.should.equal('test'); | ||
}); | ||
it('should allow setting the `accept` option', function() { | ||
var client = gremlin.createClient({ accept: 'application/xml' }); | ||
client.port.should.equal(8182); | ||
client.host.should.equal('localhost'); | ||
client.options.accept.should.equal('application/xml'); | ||
}); | ||
it('should override a set `processor` option on a per request basis', function(done) { | ||
var client = gremlin.createClient({ op: 'foo' }); | ||
client.port.should.equal(8182); | ||
client.host.should.equal('localhost'); | ||
client.options.op.should.equal('foo'); | ||
var s = client.stream('g.v(1)', null, { op: 'eval' }); | ||
s.on('data', function(result) { | ||
result.length.should.equal(1); | ||
}); | ||
s.on('end', function() { | ||
done(); | ||
}); | ||
}); | ||
}); |
@@ -5,5 +5,17 @@ /*jshint -W030 */ | ||
describe('.exec()', function() { | ||
it('should queue command before the client is connecte', function(done) { | ||
it('should return a result and a response', function(done) { | ||
var client = gremlin.createClient(); | ||
client.execute('g.V()', function(err, result, response, command) { | ||
(err === null).should.be.true; | ||
result.length.should.equal(6); | ||
response.should.exist; | ||
response.code.should.equal(299); | ||
done(); | ||
}); | ||
}); | ||
it('should queue command before the client is connected', function(done) { | ||
var client = gremlin.createClient(); | ||
client.execute('g.V()', function() { }); | ||
@@ -18,5 +30,5 @@ client.queue.length.should.equal(1); | ||
client.on('connect', function() { | ||
client.execute('g.V()', function(err, response) { | ||
client.execute('g.V()', function(err, result) { | ||
(err === null).should.be.true; | ||
response.result.length.should.equal(6); | ||
result.length.should.equal(6); | ||
done(); | ||
@@ -26,2 +38,32 @@ }); | ||
}); | ||
it('should handle bound parameters', function(done) { | ||
var client = gremlin.createClient(); | ||
client.execute('g.v(id)', { id: 1 }, function(err, result) { | ||
(err === null).should.be.true; | ||
result.length.should.equal(1); | ||
done(); | ||
}); | ||
}); | ||
it('should handle optional args', function(done) { | ||
var client = gremlin.createClient(); | ||
client.execute('g.v(1)', null, { args: { language: 'nashorn' }}, function(err, result) { | ||
(err === null).should.be.true; | ||
result.length.should.equal(1); | ||
done(); | ||
}); | ||
}); | ||
it('should handle bindings and optional args', function(done) { | ||
var client = gremlin.createClient(); | ||
client.execute('g.v(id)', { id : 1 }, { args: { language: 'nashorn' }}, function(err, result) { | ||
(err === null).should.be.true; | ||
result.length.should.equal(1); | ||
done(); | ||
}); | ||
}); | ||
}); |
@@ -8,4 +8,5 @@ /*jshint -W030 */ | ||
client.execute('g.V().filter(function(it) { return it.get().value("name") !== "gremlin" });', function(err, response) { | ||
client.execute('g.V().filter(function(it) { return it.get().value("name") !== "gremlin" });', function(err, result) { | ||
(err === null).should.be.true; | ||
result.length.should.equal(6); | ||
done(); | ||
@@ -22,5 +23,5 @@ }); | ||
client.execute(script, function(err, response) { | ||
client.execute(script, function(err, result) { | ||
(err === null).should.be.true; | ||
response.result.length.should.equal(6); | ||
result.length.should.equal(6); | ||
done(); | ||
@@ -33,22 +34,8 @@ }); | ||
client.execute(function() { g.V(); }, function(err, response) { | ||
client.execute(function() { g.V(); }, function(err, result) { | ||
(err === null).should.be.true; | ||
response.result.length.should.equal(6); | ||
result.length.should.equal(6); | ||
done(); | ||
}); | ||
}); | ||
it('should handle bound parameters', function(done) { | ||
var client = gremlin.createClient({ language: 'nashorn' }); | ||
var script = function() { g.v(id); }; | ||
client.execute(script, { id: 1 }, function(err, response) { | ||
(err === null).should.be.true; | ||
response.result.length.should.equal(1); | ||
var vertex = response.result[0]; | ||
vertex.id.should.equal(1); | ||
vertex.properties.name.should.equal('marko'); | ||
done(); | ||
}); | ||
}); | ||
}); |
@@ -13,8 +13,8 @@ /*jshint -W030 */ | ||
client.execute(script, function(err, response) { | ||
client.execute(script, function(err, result) { | ||
(err === null).should.be.true; | ||
response.result[0].properties.name.should.equal('josh'); | ||
response.result[5].properties.name.should.equal('vadas'); | ||
result[0].properties.name.should.equal('josh'); | ||
result[5].properties.name.should.equal('vadas'); | ||
}); | ||
}); | ||
}); |
@@ -5,3 +5,3 @@ var gremlin = require('../'); | ||
describe('.stream()', function() { | ||
it('should emit `result` events', function(done) { | ||
it('should emit `data` events with a chunk of results and the raw response', function(done) { | ||
var client = gremlin.createClient({ language: 'nashorn' }); | ||
@@ -12,11 +12,60 @@ var count = 0; | ||
s.on('data', function(data) { | ||
count++; | ||
s.on('data', function(result, response) { | ||
result.should.exist; | ||
response.should.exist; | ||
response.code.should.equal(200); | ||
count += 1; | ||
}); | ||
s.on('end', function() { | ||
count.should.not.equal(0); | ||
count.should.equal(6); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
it('should handle bound parameters', function(done) { | ||
var client = gremlin.createClient(); | ||
var s = client.stream('g.v(id)', { id: 1 }); | ||
s.on('data', function(result, response) { | ||
result.length.should.equal(1); | ||
response.code.should.equal(200); | ||
}); | ||
s.on('end', function() { | ||
done(); | ||
}); | ||
}); | ||
it('should handle optional args', function(done) { | ||
var client = gremlin.createClient(); | ||
var s = client.stream('g.v(1)', null, { args: { language: 'nashorn' }}); | ||
s.on('data', function(result, response) { | ||
result.length.should.equal(1); | ||
response.code.should.equal(200); | ||
}); | ||
s.on('end', function() { | ||
done(); | ||
}); | ||
}); | ||
it('should handle bindings and optional args', function(done) { | ||
var client = gremlin.createClient(); | ||
var s = client.stream('g.v(id)', { id : 1 }, { args: { language: 'nashorn' }}); | ||
s.on('data', function(result, response) { | ||
result.length.should.equal(1); | ||
response.code.should.equal(200); | ||
}); | ||
s.on('end', function() { | ||
done(); | ||
}); | ||
}); | ||
}); |
Sorry, the diff of this file is too big to display
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
448694
21
5771
195