UNPKG

@stdlib/esm

Version:

ES module distribution for Stdlib, a standard library for JavaScript and Node.js.

3 lines 1.63 kB
// This file is a part of stdlib. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 import r from"./../utils/define-nonenumerable-read-only-property.js";import i from"./../vendor/path.js";import t from"./../assert/is-string.js";import e from"./../assert/is-function.js";import n from"./../process/cwd.js";import o from"./exists.js";import s from"./../assert/is-plain-object.js";import a from"./../assert/has-own-property.js";var m=s,u=a,l=t.isPrimitive;function p(r,i){return m(i)?u(i,"dir")&&(r.dir=i.dir,!l(r.dir))?new TypeError("invalid option. `dir` option must be a primitive string. Option: `"+r.dir+"`."):null:new TypeError("invalid argument. Options argument must be an object. Value: `"+i+"`.")}var f=i.resolve,d=t.isPrimitive,v=e,g=n,c=o,w=p;function j(r,i,t){var e,n,o,s,a,m;if(!d(r))throw new TypeError("invalid argument. First argument must be a string primitive. Value: `"+r+"`.");if(o={},arguments.length>2){if(s=t,m=w(o,i))throw m}else s=i;if(!v(s))throw new TypeError("invalid argument. Callback argument must be a function. Value: `"+s+"`.");function u(i,t){return t?s(null,e):(n=a,a=f(a,".."),n===a?s(null,null):(e=f(a,r),void c(e,u)))}a=o.dir?f(g(),o.dir):g(),e=f(a,r),c(e,u)}var y=i.resolve,b=t.isPrimitive,h=n,E=o.sync,T=p;function V(r,i){var t,e,n,o,s;if(!b(r))throw new TypeError("invalid argument. First argument must be a string primitive. Value: `"+r+"`.");if(n={},arguments.length>1&&(s=T(n,i)))throw s;for(o=n.dir?y(h(),n.dir):h();e!==o;){if(t=y(o,r),E(t))return t;e=o,o=y(o,"..")}return null}var P=r,x=j,F=V;P(x,"sync",F);export default x; //# sourceMappingURL=resolve-parent-path.js.map