UNPKG

@forbespro/lead-agent

Version:
2 lines (1 loc) 2.13 kB
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c={basename:u,dirname:g,extname:h,join:P,sep:"/"};function u(t,n){if(n!==void 0&&typeof n!="string")throw new TypeError('"ext" argument must be a string');s(t);let e=0,l=-1,i=t.length,f;if(n===void 0||n.length===0||n.length>t.length){for(;i--;)if(t.codePointAt(i)===47){if(f){e=i+1;break}}else l<0&&(f=!0,l=i+1);return l<0?"":t.slice(e,l)}if(n===t)return"";let o=-1,r=n.length-1;for(;i--;)if(t.codePointAt(i)===47){if(f){e=i+1;break}}else o<0&&(f=!0,o=i+1),r>-1&&(t.codePointAt(i)===n.codePointAt(r--)?r<0&&(l=i):(r=-1,l=o));return e===l?l=o:l<0&&(l=t.length),t.slice(e,l)}function g(t){if(s(t),t.length===0)return".";let n=-1,e=t.length,l;for(;--e;)if(t.codePointAt(e)===47){if(l){n=e;break}}else l||(l=!0);return n<0?t.codePointAt(0)===47?"/":".":n===1&&t.codePointAt(0)===47?"//":t.slice(0,n)}function h(t){s(t);let n=t.length,e=-1,l=0,i=-1,f=0,o;for(;n--;){const r=t.codePointAt(n);if(r===47){if(o){l=n+1;break}continue}e<0&&(o=!0,e=n+1),r===46?i<0?i=n:f!==1&&(f=1):i>-1&&(f=-1)}return i<0||e<0||f===0||f===1&&i===e-1&&i===l+1?"":t.slice(i,e)}function P(...t){let n=-1,e;for(;++n<t.length;)s(t[n]),t[n]&&(e=e===void 0?t[n]:e+"/"+t[n]);return e===void 0?".":A(e)}function A(t){s(t);const n=t.codePointAt(0)===47;let e=S(t,!n);return e.length===0&&!n&&(e="."),e.length>0&&t.codePointAt(t.length-1)===47&&(e+="/"),n?"/"+e:e}function S(t,n){let e="",l=0,i=-1,f=0,o=-1,r,d;for(;++o<=t.length;){if(o<t.length)r=t.codePointAt(o);else{if(r===47)break;r=47}if(r===47){if(!(i===o-1||f===1))if(i!==o-1&&f===2){if(e.length<2||l!==2||e.codePointAt(e.length-1)!==46||e.codePointAt(e.length-2)!==46){if(e.length>2){if(d=e.lastIndexOf("/"),d!==e.length-1){d<0?(e="",l=0):(e=e.slice(0,d),l=e.length-1-e.lastIndexOf("/")),i=o,f=0;continue}}else if(e.length>0){e="",l=0,i=o,f=0;continue}}n&&(e=e.length>0?e+"/..":"..",l=2)}else e.length>0?e+="/"+t.slice(i+1,o):e=t.slice(i+1,o),l=o-i-1;i=o,f=0}else r===46&&f>-1?f++:f=-1}return e}function s(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}exports.minpath=c;