-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod.js
More file actions
4 lines (4 loc) · 8.15 KB
/
Copy pathmod.js
File metadata and controls
4 lines (4 loc) · 8.15 KB
1
2
3
4
// Copyright (c) 2026 The Stdlib Authors. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0
/// <reference types="./mod.d.ts" />
var r="function"==typeof Object.defineProperty?Object.defineProperty:null;var e=Object.defineProperty;function t(r){return"number"==typeof r}function n(r){var e,t="";for(e=0;e<r;e++)t+="0";return t}function i(r,e,t){var i=!1,a=e-r.length;return a<0||(function(r){return"-"===r[0]}(r)&&(i=!0,r=r.substr(1)),r=t?r+n(a):n(a)+r,i&&(r="-"+r)),r}var a=String.prototype.toLowerCase,o=String.prototype.toUpperCase;function c(r){var e,n,c;switch(r.specifier){case"b":e=2;break;case"o":e=8;break;case"x":case"X":e=16;break;default:e=10}if(n=r.arg,c=parseInt(n,10),!isFinite(c)){if(!t(n))throw new Error("invalid integer. Value: "+n);c=0}return c<0&&("u"===r.specifier||10!==e)&&(c=4294967295+c+1),c<0?(n=(-c).toString(e),r.precision&&(n=i(n,r.precision,r.padRight)),n="-"+n):(n=c.toString(e),c||r.precision?r.precision&&(n=i(n,r.precision,r.padRight)):n="",r.sign&&(n=r.sign+n)),16===e&&(r.alternate&&(n="0x"+n),n=r.specifier===o.call(r.specifier)?o.call(n):a.call(n)),8===e&&r.alternate&&"0"!==n.charAt(0)&&(n="0"+n),n}var s=Math.abs,l=String.prototype.toLowerCase,p=String.prototype.toUpperCase,u=String.prototype.replace,f=/e\+(\d)$/,g=/e-(\d)$/,h=/^(\d+)$/,d=/^(\d+)e/,b=/\.0$/,v=/\.0*e/,y=/(\..*[^0])0*e/;function w(r,e){var t,n;switch(e.specifier){case"e":case"E":n=r.toExponential(e.precision);break;case"f":case"F":n=r.toFixed(e.precision);break;case"g":case"G":s(r)<1e-4?((t=e.precision)>0&&(t-=1),n=r.toExponential(t)):n=r.toPrecision(e.precision),e.alternate||(n=u.call(n,y,"$1e"),n=u.call(n,v,"e"),n=u.call(n,b,""));break;default:throw new Error("invalid double notation. Value: "+e.specifier)}return n=u.call(n,f,"e+0$1"),n=u.call(n,g,"e-0$1"),e.alternate&&(n=u.call(n,h,"$1."),n=u.call(n,d,"$1.e")),r>=0&&e.sign&&(n=e.sign+n),n=e.specifier===p.call(e.specifier)?p.call(n):l.call(n)}function m(r){var e,t="";for(e=0;e<r;e++)t+=" ";return t}var _=String.fromCharCode,S=Array.isArray;function E(r){return r!=r}function j(r){var e={};return e.specifier=r.specifier,e.precision=void 0===r.precision?1:r.precision,e.width=r.width,e.flags=r.flags||"",e.mapping=r.mapping,e}function O(r){var e,n,a,o,s,l,p,u,f,g,h,d,b,v;if(!S(r))throw new TypeError("invalid argument. First argument must be an array. Value: `"+r+"`.");for(l="",p=1,f=0;f<r.length;f++)if(a=r[f],"string"==typeof a)l+=a;else{if(e=void 0!==a.precision,!(a=j(a)).specifier)throw new TypeError("invalid argument. Token is missing `specifier` property. Index: `"+f+"`. Value: `"+a+"`.");for(a.mapping&&(p=a.mapping),n=a.flags,g=0;g<n.length;g++)switch(o=n.charAt(g)){case" ":a.sign=" ";break;case"+":a.sign="+";break;case"-":a.padRight=!0,a.padZeros=!1;break;case"0":a.padZeros=n.indexOf("-")<0;break;case"#":a.alternate=!0;break;default:throw new Error("invalid flag: "+o)}if("*"===a.width){if(a.width=parseInt(arguments[p],10),p+=1,E(a.width))throw new TypeError("the argument for * width at position "+p+" is not a number. Value: `"+a.width+"`.");a.width<0&&(a.padRight=!0,a.width=-a.width)}if(e&&"*"===a.precision){if(a.precision=parseInt(arguments[p],10),p+=1,E(a.precision))throw new TypeError("the argument for * precision at position "+p+" is not a number. Value: `"+a.precision+"`.");a.precision<0&&(a.precision=1,e=!1)}switch(a.arg=arguments[p],a.specifier){case"b":case"o":case"x":case"X":case"d":case"i":case"u":e&&(a.padZeros=!1),a.arg=c(a);break;case"s":a.maxWidth=e?a.precision:-1,a.arg=String(a.arg);break;case"c":if(!E(a.arg)){if((s=parseInt(a.arg,10))<0||s>127)throw new Error("invalid character code. Value: "+a.arg);a.arg=E(s)?String(a.arg):_(s)}break;case"e":case"E":case"f":case"F":case"g":case"G":if(e||(a.precision=6),u=parseFloat(a.arg),!isFinite(u)){if(!t(a.arg))throw new Error("invalid floating-point number. Value: "+l);u=a.arg,a.padZeros=!1}a.arg=w(u,a);break;default:throw new Error("invalid specifier: "+a.specifier)}a.maxWidth>=0&&a.arg.length>a.maxWidth&&(a.arg=a.arg.substring(0,a.maxWidth)),a.padZeros?a.arg=i(a.arg,a.width||a.precision,a.padRight):a.width&&(a.arg=(h=a.arg,d=a.width,b=a.padRight,v=void 0,(v=d-h.length)<0?h:h=b?h+m(v):m(v)+h)),l+=a.arg||"",p+=1}return l}var k=/%(?:([1-9]\d*)\$)?([0 +\-#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([%A-Za-z])/g;function x(r){var e={mapping:r[1]?parseInt(r[1],10):void 0,flags:r[2],width:r[3],precision:r[5],specifier:r[6]};return"."===r[4]&&void 0===r[5]&&(e.precision="1"),e}function I(r){var e,t,n,i;for(t=[],i=0,n=k.exec(r);n;)(e=r.slice(i,k.lastIndex-n[0].length)).length&&t.push(e),"%"===n[6]?t.push("%"):t.push(x(n)),i=k.lastIndex,n=k.exec(r);return(e=r.slice(i)).length&&t.push(e),t}function T(r){var e,t;if("string"!=typeof r)throw new TypeError(T("invalid argument. First argument must be a string. Value: `%s`.",r));for(e=[I(r)],t=1;t<arguments.length;t++)e.push(arguments[t]);return O.apply(null,e)}var V=Object.prototype,A=V.toString,F=V.__defineGetter__,C=V.__defineSetter__,P=V.__lookupGetter__,Z=V.__lookupSetter__;var $=function(){try{return r({},"x",{}),!0}catch(r){return!1}}()?e:function(r,e,t){var n,i,a,o;if("object"!=typeof r||null===r||"[object Array]"===A.call(r))throw new TypeError(T("invalid argument. First argument must be an object. Value: `%s`.",r));if("object"!=typeof t||null===t||"[object Array]"===A.call(t))throw new TypeError(T("invalid argument. Property descriptor must be an object. Value: `%s`.",t));if((i="value"in t)&&(P.call(r,e)||Z.call(r,e)?(n=r.__proto__,r.__proto__=V,delete r[e],r[e]=t.value,r.__proto__=n):r[e]=t.value),a="get"in t,o="set"in t,i&&(a||o))throw new Error("invalid argument. Cannot specify one or more accessors and a value or writable attribute in the property descriptor.");return a&&F&&F.call(r,e,t.get),o&&C&&C.call(r,e,t.set),r};function N(r,e,t){$(r,e,{configurable:!1,enumerable:!1,writable:!1,value:t})}function R(r){return"boolean"==typeof r}var G="function"==typeof Symbol&&"symbol"==typeof Symbol("foo");function L(){return G&&"symbol"==typeof Symbol.toStringTag}var W=Object.prototype.toString;var B=Object.prototype.hasOwnProperty;var U="function"==typeof Symbol?Symbol:void 0,M="function"==typeof U?U.toStringTag:"";var X=L()?function(r){var e,t,n,i,a;if(null==r)return W.call(r);t=r[M],a=M,e=null!=(i=r)&&B.call(i,a);try{r[M]=void 0}catch(e){return W.call(r)}return n=W.call(r),e?r[M]=t:delete r[M],n}:function(r){return W.call(r)},Y=Boolean,z=Boolean.prototype.toString;var q=L();function D(r){return"object"==typeof r&&(r instanceof Y||(q?function(r){try{return z.call(r),!0}catch(r){return!1}}(r):"[object Boolean]"===X(r)))}function H(r){return R(r)||D(r)}function J(r){return"string"==typeof r}N(H,"isPrimitive",R),N(H,"isObject",D);var K=String.prototype.valueOf;var Q=L();function rr(r){return"object"==typeof r&&(r instanceof String||(Q?function(r){try{return K.call(r),!0}catch(r){return!1}}(r):"[object String]"===X(r)))}function er(r){return J(r)||rr(r)}function tr(r){return"number"==typeof r}N(er,"isPrimitive",J),N(er,"isObject",rr);var nr=Number,ir=nr.prototype.toString;var ar=L();function or(r){return"object"==typeof r&&(r instanceof nr||(ar?function(r){try{return ir.call(r),!0}catch(r){return!1}}(r):"[object Number]"===X(r)))}function cr(r){return tr(r)||or(r)}N(cr,"isPrimitive",tr),N(cr,"isObject",or);var sr=Number.POSITIVE_INFINITY,lr=nr.NEGATIVE_INFINITY,pr=Math.floor;function ur(r){return r<sr&&r>lr&&pr(e=r)===e;var e}function fr(r){return tr(r)&&ur(r)}function gr(r){return or(r)&&ur(r.valueOf())}function hr(r){return fr(r)||gr(r)}function dr(){var r,e=arguments,t="https://stdlib.io/e/"+e[0]+"?";for(r=1;r<e.length;r++)t+="&arg[]="+encodeURIComponent(e[r]);return t}N(hr,"isPrimitive",fr),N(hr,"isObject",gr);var br=65536,vr=1024,yr=55296,wr=56319,mr=56320,_r=57343;function Sr(r,e,t){var n;if(!J(r))throw new TypeError(dr("1OZ3F",r));if(!fr(e))throw new TypeError(dr("1OZ7f",e));if(e<0&&(e+=r.length),e<0||e>=r.length)throw new RangeError(dr("1OZE4",e));if(arguments.length>2){if(!R(t))throw new TypeError(dr("1OZAL",t));n=t}else n=!1;return function(r,e,t){var n,i,a;return e<0&&(e+=r.length),(n=r.charCodeAt(e))>=yr&&n<=wr&&e<r.length-1?(a=n,i=r.charCodeAt(e+1),mr<=i&&i<=_r?(a-yr)*vr+(i-mr)+br:a):t&&n>=mr&&n<=_r&&e>=1?(a=r.charCodeAt(e-1),i=n,yr<=a&&a<=wr?(a-yr)*vr+(i-mr)+br:i):n}(r,e,n)}export{Sr as default};
//# sourceMappingURL=mod.js.map