UNPKG

dd-trace

Version:

Datadog APM tracing client for JavaScript

1 lines 4.21 kB
(()=>{"use strict";var e={"./shell-quote/parse.js"(e){for(var t="(?:\\|\\||\\&\\&|;;|\\|\\&|\\<\\(|\\<\\<\\<|>>|>\\&|<\\&|[&;()|<>])",r=RegExp("^"+t+"$"),n="|&;()<> \\t",o=/^#$/,i="",a=0;a<4;a++)i+=(0x100000000*Math.random()).toString(16);var l=RegExp("^"+i);function matchAll(e,t){for(var r,n=t.lastIndex,o=[];r=t.exec(e);)o[o.length]=r,t.lastIndex===r.index&&(t.lastIndex+=1);return t.lastIndex=n,o}function getVar(e,t,r){var n="function"==typeof e?e(r):e[r];return(void 0===n&&""!=r?n="":void 0===n&&(n="$"),"object"==typeof n)?t+i+JSON.stringify(n)+i:t+n}function parseInternal(e,i,a){a||(a={});var l=a.escape||"\\",s=!0===a.splitUnquoted?" \n":"string"==typeof a.splitUnquoted?a.splitUnquoted:"",u=matchAll(e,RegExp(["("+t+")","("+("(\\"+l+"['\""+n+"]|[^\\s'\""+n)+'])+|"((\\\\"|[^"])*?)"|\'([^\']*?)\')+'].join("|"),"g"));if(0===u.length)return[];i||(i={});var f=!1;return u.map(function(t){var n,a=t[0];if(a&&!f){if(r.test(a))return{op:a};var u=!1,p=!1,c="",h=[],g=!1,v=null,d=!1;for(n=0;n<a.length;n++){var m=a.charAt(n);if(s&&"$"!==m&&flushRun(),d=d||!u&&("*"===m||"?"===m),p)c+=m,p=!1;else if(u)m===u?u=!1:"'"==u?c+=m:m===l?(n+=1,'"'===(m=a.charAt(n))||m===l||"$"===m?c+=m:c+=l+m):"$"===m?c+=parseEnvVar():c+=m;else if('"'===m||"'"===m)u=m,g=!0;else if(r.test(m))return{op:a};else if(o.test(m)){f=!0;var x={comment:e.slice(t.index+n+1)};if(c.length)return[c,x];return[x]}else if(m===l)p=!0;else if("$"===m){var _=parseEnvVar();if(s)for(var $=0;$<_.length;$+=1){var y=_.charAt($);0>s.indexOf(y)?(flushRun(),c+=y):null===v?v=+(" "!==y&&" "!==y&&"\n"!==y):" "!==y&&" "!==y&&"\n"!==y&&(v+=1)}else c+=_}else c+=m}if(d)return{op:"glob",pattern:c};if(s){if(null!==v&&v>0){h[h.length]=c,c="";for(var E=1;E<v;E+=1)h[h.length]=""}return(""!==c||g&&0===h.length)&&(h[h.length]=c),h}return c}function parseEnvVar(){n+=1;var e,t,r=a.charAt(n);if("{"===r){if(n+=1,"}"===a.charAt(n))throw Error("Bad substitution: "+a.slice(n-2,n+1));var o=1;for(e=n;o>0&&e<a.length;)"{"===a.charAt(e)&&"$"===a.charAt(e-1)?o+=1:"}"===a.charAt(e)&&(o-=1),e+=1;if(0!==o)throw Error("Bad substitution: "+a.slice(n));e-=1,t=a.slice(n,e),n=e}else if(/[*@#?$!_-]/.test(r))t=r,n+=1;else{var l=a.slice(n);(e=l.match(/[^\w\d_]/))?(t=l.slice(0,e.index),n+=e.index-1):(t=l,n=a.length)}return getVar(i,"",t)}function flushRun(){if(null!==v){if(0===v)""!==c&&(h[h.length]=c,c="");else{h[h.length]=c,c="";for(var e=1;e<v;e+=1)h[h.length]=""}v=null}}}).reduce(function(e,t){return void 0===t||[].concat(t).forEach(function(t){e[e.length]=t}),e},[])}e.exports=function(e,t,r){var n=parseInternal(e,t,r);return"function"!=typeof t?n:n.reduce(function(e,t){if("object"==typeof t)return e[e.length]=t,e;var r=t.split(RegExp("("+i+".*?"+i+")","g"));return 1===r.length?e[e.length]=r[0]:r.filter(Boolean).forEach(function(t){e[e.length]=l.test(t)?JSON.parse(t.split(i)[1]):t}),e},[])}},"./shell-quote/quote.js"(e){var t=["||","&&",";;","|&","<(","<<<",">>",">&","<&","&",";","(",")","|","<",">"],r=/[\n\r\u2028\u2029]/,n=/[\s#!"$&'():;<=>@\\^`|]/g;e.exports=function(e){return e.map(function(e){if(""===e)return"''";if(e&&"object"==typeof e){if("op"in e&&"glob"===e.op){if("string"!=typeof e.pattern)throw TypeError("glob token requires a string `pattern`");if(r.test(e.pattern))throw TypeError("glob `pattern` must not contain line terminators");return e.pattern.replace(n,"\\$&")}if("op"in e&&"string"==typeof e.op){if(0>t.indexOf(e.op))throw TypeError("invalid `op` value: "+JSON.stringify(e.op));return e.op.replace(/[\s\S]/g,"\\$&")}if("comment"in e&&"string"==typeof e.comment){if(r.test(e.comment))throw TypeError("`comment` must not contain line terminators");return"#"+e.comment}throw TypeError("unrecognized object token shape")}return/["\s\\]/.test(e)&&!/'/.test(e)?"'"+e.replace(/(['])/g,"\\$1")+"'":/["'\s]/.test(e)?'"'+e.replace(/(["\\$`!])/g,"\\$1")+'"':String(e).replace(/([A-Za-z]:)?([#!"$&'()*,:;<=>?@[\\\]^`{|}~])/g,"$1\\$2")}).join(" ")}}},t={};function __webpack_require__(r){var n=t[r];if(void 0!==n)return n.exports;var o=t[r]={exports:{}};return e[r](o,o.exports,__webpack_require__),o.exports}var r={};r.quote=__webpack_require__("./shell-quote/quote.js"),r.parse=__webpack_require__("./shell-quote/parse.js"),module.exports=r})();