@modern-js/utils
Version:
A Progressive React Framework for modern web development.
1,255 lines (1,254 loc) • 67.7 kB
JavaScript
(()=>{
var e = {
305: (e, t, r)=>{
"use strict";
var n = r(837);
var i = r(589);
var s = function(e, t) {
if (!e || e.constructor !== String) {
t = e || {};
e = Error.name;
}
var r = function ErrorEXError(n) {
if (!this) return new ErrorEXError(n);
n = n instanceof Error ? n.message : n || this.message;
Error.call(this, n);
Error.captureStackTrace(this, r);
this.name = e;
Object.defineProperty(this, "message", {
configurable: true,
enumerable: false,
get: function() {
var e = n.split(/\r?\n/g);
for(var r in t)if (t.hasOwnProperty(r)) {
var s = t[r];
if ("message" in s) {
e = s.message(this[r], e) || e;
if (!i(e)) e = [
e
];
}
}
return e.join("\n");
},
set: function(e) {
n = e;
}
});
var s = null;
var o = Object.getOwnPropertyDescriptor(this, "stack");
var c = o.get;
var a = o.value;
delete o.value;
delete o.writable;
o.set = function(e) {
s = e;
};
o.get = function() {
var e = (s || (c ? c.call(this) : a)).split(/\r?\n+/g);
if (!s) e[0] = this.name + ": " + this.message;
var r = 1;
for(var n in t)if (t.hasOwnProperty(n)) {
var i = t[n];
if ("line" in i) {
var o = i.line(this[n]);
if (o) e.splice(r++, 0, " " + o);
}
if ("stack" in i) i.stack(this[n], e);
}
return e.join("\n");
};
Object.defineProperty(this, "stack", o);
};
if (Object.setPrototypeOf) {
Object.setPrototypeOf(r.prototype, Error.prototype);
Object.setPrototypeOf(r, Error);
} else n.inherits(r, Error);
return r;
};
s.append = function(e, t) {
return {
message: function(r, n) {
r = r || t;
if (r) n[0] += " " + e.replace("%s", r.toString());
return n;
}
};
};
s.line = function(e, t) {
return {
line: function(r) {
r = r || t;
if (r) return e.replace("%s", r.toString());
return null;
}
};
};
e.exports = s;
},
434: (e)=>{
"use strict";
var t = /[|\\{}()[\]^$+*?.]/g;
e.exports = function(e) {
if ("string" != typeof e) throw new TypeError("Expected a string");
return e.replace(t, "\\$&");
};
},
877: (e, t, r)=>{
"use strict";
const n = r(434);
const i = process.platform;
const s = {
tick: "✔",
cross: "✖",
star: "★",
square: "▇",
squareSmall: "◻",
squareSmallFilled: "◼",
play: "▶",
circle: "◯",
circleFilled: "◉",
circleDotted: "◌",
circleDouble: "◎",
circleCircle: "ⓞ",
circleCross: "ⓧ",
circlePipe: "Ⓘ",
circleQuestionMark: "?⃝",
bullet: "●",
dot: "․",
line: "─",
ellipsis: "…",
pointer: "❯",
pointerSmall: "›",
info: "ℹ",
warning: "⚠",
hamburger: "☰",
smiley: "㋡",
mustache: "෴",
heart: "♥",
arrowUp: "↑",
arrowDown: "↓",
arrowLeft: "←",
arrowRight: "→",
radioOn: "◉",
radioOff: "◯",
checkboxOn: "☒",
checkboxOff: "☐",
checkboxCircleOn: "ⓧ",
checkboxCircleOff: "Ⓘ",
questionMarkPrefix: "?⃝",
oneHalf: "½",
oneThird: "⅓",
oneQuarter: "¼",
oneFifth: "⅕",
oneSixth: "⅙",
oneSeventh: "⅐",
oneEighth: "⅛",
oneNinth: "⅑",
oneTenth: "⅒",
twoThirds: "⅔",
twoFifths: "⅖",
threeQuarters: "¾",
threeFifths: "⅗",
threeEighths: "⅜",
fourFifths: "⅘",
fiveSixths: "⅚",
fiveEighths: "⅝",
sevenEighths: "⅞"
};
const o = {
tick: "√",
cross: "×",
star: "*",
square: "█",
squareSmall: "[ ]",
squareSmallFilled: "[█]",
play: "►",
circle: "( )",
circleFilled: "(*)",
circleDotted: "( )",
circleDouble: "( )",
circleCircle: "(○)",
circleCross: "(×)",
circlePipe: "(│)",
circleQuestionMark: "(?)",
bullet: "*",
dot: ".",
line: "─",
ellipsis: "...",
pointer: ">",
pointerSmall: "»",
info: "i",
warning: "‼",
hamburger: "≡",
smiley: "☺",
mustache: "┌─┐",
heart: s.heart,
arrowUp: s.arrowUp,
arrowDown: s.arrowDown,
arrowLeft: s.arrowLeft,
arrowRight: s.arrowRight,
radioOn: "(*)",
radioOff: "( )",
checkboxOn: "[×]",
checkboxOff: "[ ]",
checkboxCircleOn: "(×)",
checkboxCircleOff: "( )",
questionMarkPrefix: "?",
oneHalf: "1/2",
oneThird: "1/3",
oneQuarter: "1/4",
oneFifth: "1/5",
oneSixth: "1/6",
oneSeventh: "1/7",
oneEighth: "1/8",
oneNinth: "1/9",
oneTenth: "1/10",
twoThirds: "2/3",
twoFifths: "2/5",
threeQuarters: "3/4",
threeFifths: "3/5",
threeEighths: "3/8",
fourFifths: "4/5",
fiveSixths: "5/6",
fiveEighths: "5/8",
sevenEighths: "7/8"
};
if ("linux" === i) s.questionMarkPrefix = "?";
const c = "win32" === i ? o : s;
const fn = (e)=>{
if (c === s) return e;
Object.keys(s).forEach((t)=>{
if (s[t] === c[t]) return;
e = e.replace(new RegExp(n(s[t]), "g"), c[t]);
});
return e;
};
e.exports = Object.assign(fn, c);
},
834: (e, t, r)=>{
"use strict";
const n = r(17);
const i = r(69);
e.exports = (e, t)=>{
t = t || {};
const r = n.resolve(t.cwd || "");
const s = n.parse(r).root;
const o = [].concat(e);
return new Promise((e)=>{
(function find(t) {
i(o, {
cwd: t
}).then((r)=>{
if (r) e(n.join(t, r));
else if (t === s) e(null);
else find(n.dirname(t));
});
})(r);
});
};
e.exports.sync = (e, t)=>{
t = t || {};
let r = n.resolve(t.cwd || "");
const s = n.parse(r).root;
const o = [].concat(e);
while(true){
const e = i.sync(o, {
cwd: r
});
if (e) return n.join(r, e);
if (r === s) return null;
r = n.dirname(r);
}
};
},
132: (e)=>{
"use strict";
e.exports = clone;
var t = Object.getPrototypeOf || function(e) {
return e.__proto__;
};
function clone(e) {
if (null === e || "object" != typeof e) return e;
if (e instanceof Object) var r = {
__proto__: t(e)
};
else var r = Object.create(null);
Object.getOwnPropertyNames(e).forEach(function(t) {
Object.defineProperty(r, t, Object.getOwnPropertyDescriptor(e, t));
});
return r;
}
},
127: (e, t, r)=>{
var n = r(147);
var i = r(738);
var s = r(876);
var o = r(132);
var c = r(837);
var a;
var l;
if ("function" == typeof Symbol && "function" == typeof Symbol.for) {
a = Symbol.for("graceful-fs.queue");
l = Symbol.for("graceful-fs.previous");
} else {
a = "___graceful-fs.queue";
l = "___graceful-fs.previous";
}
function noop() {}
function publishQueue(e, t) {
Object.defineProperty(e, a, {
get: function() {
return t;
}
});
}
var f = noop;
if (c.debuglog) f = c.debuglog("gfs4");
else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) f = function() {
var e = c.format.apply(c, arguments);
e = "GFS4: " + e.split(/\n/).join("\nGFS4: ");
console.error(e);
};
if (!n[a]) {
var u = global[a] || [];
publishQueue(n, u);
n.close = function(e) {
function close(t, r) {
return e.call(n, t, function(e) {
if (!e) resetQueue();
if ("function" == typeof r) r.apply(this, arguments);
});
}
Object.defineProperty(close, l, {
value: e
});
return close;
}(n.close);
n.closeSync = function(e) {
function closeSync(t) {
e.apply(n, arguments);
resetQueue();
}
Object.defineProperty(closeSync, l, {
value: e
});
return closeSync;
}(n.closeSync);
if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) process.on("exit", function() {
f(n[a]);
r(491).equal(n[a].length, 0);
});
}
if (!global[a]) publishQueue(global, n[a]);
e.exports = patch(o(n));
if (process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH && !n.__patched) {
e.exports = patch(n);
n.__patched = true;
}
function patch(e) {
i(e);
e.gracefulify = patch;
e.createReadStream = createReadStream;
e.createWriteStream = createWriteStream;
var t = e.readFile;
e.readFile = readFile;
function readFile(e, r, n) {
if ("function" == typeof r) n = r, r = null;
return go$readFile(e, r, n);
function go$readFile(e, r, n, i) {
return t(e, r, function(t) {
if (t && ("EMFILE" === t.code || "ENFILE" === t.code)) enqueue([
go$readFile,
[
e,
r,
n
],
t,
i || Date.now(),
Date.now()
]);
else if ("function" == typeof n) n.apply(this, arguments);
});
}
}
var r = e.writeFile;
e.writeFile = writeFile;
function writeFile(e, t, n, i) {
if ("function" == typeof n) i = n, n = null;
return go$writeFile(e, t, n, i);
function go$writeFile(e, t, n, i, s) {
return r(e, t, n, function(r) {
if (r && ("EMFILE" === r.code || "ENFILE" === r.code)) enqueue([
go$writeFile,
[
e,
t,
n,
i
],
r,
s || Date.now(),
Date.now()
]);
else if ("function" == typeof i) i.apply(this, arguments);
});
}
}
var n = e.appendFile;
if (n) e.appendFile = appendFile;
function appendFile(e, t, r, i) {
if ("function" == typeof r) i = r, r = null;
return go$appendFile(e, t, r, i);
function go$appendFile(e, t, r, i, s) {
return n(e, t, r, function(n) {
if (n && ("EMFILE" === n.code || "ENFILE" === n.code)) enqueue([
go$appendFile,
[
e,
t,
r,
i
],
n,
s || Date.now(),
Date.now()
]);
else if ("function" == typeof i) i.apply(this, arguments);
});
}
}
var o = e.copyFile;
if (o) e.copyFile = copyFile;
function copyFile(e, t, r, n) {
if ("function" == typeof r) {
n = r;
r = 0;
}
return go$copyFile(e, t, r, n);
function go$copyFile(e, t, r, n, i) {
return o(e, t, r, function(s) {
if (s && ("EMFILE" === s.code || "ENFILE" === s.code)) enqueue([
go$copyFile,
[
e,
t,
r,
n
],
s,
i || Date.now(),
Date.now()
]);
else if ("function" == typeof n) n.apply(this, arguments);
});
}
}
var c = e.readdir;
e.readdir = readdir;
var a = /^v[0-5]\./;
function readdir(e, t, r) {
if ("function" == typeof t) r = t, t = null;
var n = a.test(process.version) ? function(e, t, r, n) {
return c(e, fs$readdirCallback(e, t, r, n));
} : function(e, t, r, n) {
return c(e, t, fs$readdirCallback(e, t, r, n));
};
return n(e, t, r);
function fs$readdirCallback(e, t, r, i) {
return function(s, o) {
if (s && ("EMFILE" === s.code || "ENFILE" === s.code)) enqueue([
n,
[
e,
t,
r
],
s,
i || Date.now(),
Date.now()
]);
else {
if (o && o.sort) o.sort();
if ("function" == typeof r) r.call(this, s, o);
}
};
}
}
if ("v0.8" === process.version.substr(0, 4)) {
var l = s(e);
ReadStream = l.ReadStream;
WriteStream = l.WriteStream;
}
var f = e.ReadStream;
if (f) {
ReadStream.prototype = Object.create(f.prototype);
ReadStream.prototype.open = ReadStream$open;
}
var u = e.WriteStream;
if (u) {
WriteStream.prototype = Object.create(u.prototype);
WriteStream.prototype.open = WriteStream$open;
}
Object.defineProperty(e, "ReadStream", {
get: function() {
return ReadStream;
},
set: function(e) {
ReadStream = e;
},
enumerable: true,
configurable: true
});
Object.defineProperty(e, "WriteStream", {
get: function() {
return WriteStream;
},
set: function(e) {
WriteStream = e;
},
enumerable: true,
configurable: true
});
var h = ReadStream;
Object.defineProperty(e, "FileReadStream", {
get: function() {
return h;
},
set: function(e) {
h = e;
},
enumerable: true,
configurable: true
});
var p = WriteStream;
Object.defineProperty(e, "FileWriteStream", {
get: function() {
return p;
},
set: function(e) {
p = e;
},
enumerable: true,
configurable: true
});
function ReadStream(e, t) {
if (this instanceof ReadStream) return f.apply(this, arguments), this;
return ReadStream.apply(Object.create(ReadStream.prototype), arguments);
}
function ReadStream$open() {
var e = this;
open(e.path, e.flags, e.mode, function(t, r) {
if (t) {
if (e.autoClose) e.destroy();
e.emit("error", t);
} else {
e.fd = r;
e.emit("open", r);
e.read();
}
});
}
function WriteStream(e, t) {
if (this instanceof WriteStream) return u.apply(this, arguments), this;
return WriteStream.apply(Object.create(WriteStream.prototype), arguments);
}
function WriteStream$open() {
var e = this;
open(e.path, e.flags, e.mode, function(t, r) {
if (t) {
e.destroy();
e.emit("error", t);
} else {
e.fd = r;
e.emit("open", r);
}
});
}
function createReadStream(t, r) {
return new e.ReadStream(t, r);
}
function createWriteStream(t, r) {
return new e.WriteStream(t, r);
}
var d = e.open;
e.open = open;
function open(e, t, r, n) {
if ("function" == typeof r) n = r, r = null;
return go$open(e, t, r, n);
function go$open(e, t, r, n, i) {
return d(e, t, r, function(s, o) {
if (s && ("EMFILE" === s.code || "ENFILE" === s.code)) enqueue([
go$open,
[
e,
t,
r,
n
],
s,
i || Date.now(),
Date.now()
]);
else if ("function" == typeof n) n.apply(this, arguments);
});
}
}
return e;
}
function enqueue(e) {
f("ENQUEUE", e[0].name, e[1]);
n[a].push(e);
retry();
}
var h;
function resetQueue() {
var e = Date.now();
for(var t = 0; t < n[a].length; ++t)if (n[a][t].length > 2) {
n[a][t][3] = e;
n[a][t][4] = e;
}
retry();
}
function retry() {
clearTimeout(h);
h = void 0;
if (0 === n[a].length) return;
var e = n[a].shift();
var t = e[0];
var r = e[1];
var i = e[2];
var s = e[3];
var o = e[4];
if (void 0 === s) {
f("RETRY", t.name, r);
t.apply(null, r);
} else if (Date.now() - s >= 6e4) {
f("TIMEOUT", t.name, r);
var c = r.pop();
if ("function" == typeof c) c.call(null, i);
} else {
var l = Date.now() - o;
var u = Math.max(o - s, 1);
var p = Math.min(1.2 * u, 100);
if (l >= p) {
f("RETRY", t.name, r);
t.apply(null, r.concat([
s
]));
} else n[a].push(e);
}
if (void 0 === h) h = setTimeout(retry, 0);
}
},
876: (e, t, r)=>{
var n = r(781).Stream;
e.exports = legacy;
function legacy(e) {
return {
ReadStream: ReadStream,
WriteStream: WriteStream
};
function ReadStream(t, r) {
if (!(this instanceof ReadStream)) return new ReadStream(t, r);
n.call(this);
var i = this;
this.path = t;
this.fd = null;
this.readable = true;
this.paused = false;
this.flags = "r";
this.mode = 438;
this.bufferSize = 65536;
r = r || {};
var s = Object.keys(r);
for(var o = 0, c = s.length; o < c; o++){
var a = s[o];
this[a] = r[a];
}
if (this.encoding) this.setEncoding(this.encoding);
if (void 0 !== this.start) {
if ("number" != typeof this.start) throw TypeError("start must be a Number");
if (void 0 === this.end) this.end = 1 / 0;
else if ("number" != typeof this.end) throw TypeError("end must be a Number");
if (this.start > this.end) throw new Error("start must be <= end");
this.pos = this.start;
}
if (null !== this.fd) return void process.nextTick(function() {
i._read();
});
e.open(this.path, this.flags, this.mode, function(e, t) {
if (e) {
i.emit("error", e);
i.readable = false;
return;
}
i.fd = t;
i.emit("open", t);
i._read();
});
}
function WriteStream(t, r) {
if (!(this instanceof WriteStream)) return new WriteStream(t, r);
n.call(this);
this.path = t;
this.fd = null;
this.writable = true;
this.flags = "w";
this.encoding = "binary";
this.mode = 438;
this.bytesWritten = 0;
r = r || {};
var i = Object.keys(r);
for(var s = 0, o = i.length; s < o; s++){
var c = i[s];
this[c] = r[c];
}
if (void 0 !== this.start) {
if ("number" != typeof this.start) throw TypeError("start must be a Number");
if (this.start < 0) throw new Error("start must be >= zero");
this.pos = this.start;
}
this.busy = false;
this._queue = [];
if (null === this.fd) {
this._open = e.open;
this._queue.push([
this._open,
this.path,
this.flags,
this.mode,
void 0
]);
this.flush();
}
}
}
},
738: (e, t, r)=>{
var n = r(57);
var i = process.cwd;
var s = null;
var o = process.env.GRACEFUL_FS_PLATFORM || process.platform;
process.cwd = function() {
if (!s) s = i.call(process);
return s;
};
try {
process.cwd();
} catch (e) {}
if ("function" == typeof process.chdir) {
var c = process.chdir;
process.chdir = function(e) {
s = null;
c.call(process, e);
};
if (Object.setPrototypeOf) Object.setPrototypeOf(process.chdir, c);
}
e.exports = patch;
function patch(e) {
if (n.hasOwnProperty("O_SYMLINK") && process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)) patchLchmod(e);
if (!e.lutimes) patchLutimes(e);
e.chown = chownFix(e.chown);
e.fchown = chownFix(e.fchown);
e.lchown = chownFix(e.lchown);
e.chmod = chmodFix(e.chmod);
e.fchmod = chmodFix(e.fchmod);
e.lchmod = chmodFix(e.lchmod);
e.chownSync = chownFixSync(e.chownSync);
e.fchownSync = chownFixSync(e.fchownSync);
e.lchownSync = chownFixSync(e.lchownSync);
e.chmodSync = chmodFixSync(e.chmodSync);
e.fchmodSync = chmodFixSync(e.fchmodSync);
e.lchmodSync = chmodFixSync(e.lchmodSync);
e.stat = statFix(e.stat);
e.fstat = statFix(e.fstat);
e.lstat = statFix(e.lstat);
e.statSync = statFixSync(e.statSync);
e.fstatSync = statFixSync(e.fstatSync);
e.lstatSync = statFixSync(e.lstatSync);
if (e.chmod && !e.lchmod) {
e.lchmod = function(e, t, r) {
if (r) process.nextTick(r);
};
e.lchmodSync = function() {};
}
if (e.chown && !e.lchown) {
e.lchown = function(e, t, r, n) {
if (n) process.nextTick(n);
};
e.lchownSync = function() {};
}
if ("win32" === o) e.rename = "function" != typeof e.rename ? e.rename : function(t) {
function rename(r, n, i) {
var s = Date.now();
var o = 0;
t(r, n, function CB(c) {
if (c && ("EACCES" === c.code || "EPERM" === c.code) && Date.now() - s < 6e4) {
setTimeout(function() {
e.stat(n, function(e, s) {
if (e && "ENOENT" === e.code) t(r, n, CB);
else i(c);
});
}, o);
if (o < 100) o += 10;
return;
}
if (i) i(c);
});
}
if (Object.setPrototypeOf) Object.setPrototypeOf(rename, t);
return rename;
}(e.rename);
e.read = "function" != typeof e.read ? e.read : function(t) {
function read(r, n, i, s, o, c) {
var a;
if (c && "function" == typeof c) {
var l = 0;
a = function(f, u, h) {
if (f && "EAGAIN" === f.code && l < 10) {
l++;
return t.call(e, r, n, i, s, o, a);
}
c.apply(this, arguments);
};
}
return t.call(e, r, n, i, s, o, a);
}
if (Object.setPrototypeOf) Object.setPrototypeOf(read, t);
return read;
}(e.read);
e.readSync = "function" != typeof e.readSync ? e.readSync : function(t) {
return function(r, n, i, s, o) {
var c = 0;
while(true)try {
return t.call(e, r, n, i, s, o);
} catch (e) {
if ("EAGAIN" === e.code && c < 10) {
c++;
continue;
}
throw e;
}
};
}(e.readSync);
function patchLchmod(e) {
e.lchmod = function(t, r, i) {
e.open(t, n.O_WRONLY | n.O_SYMLINK, r, function(t, n) {
if (t) {
if (i) i(t);
return;
}
e.fchmod(n, r, function(t) {
e.close(n, function(e) {
if (i) i(t || e);
});
});
});
};
e.lchmodSync = function(t, r) {
var i = e.openSync(t, n.O_WRONLY | n.O_SYMLINK, r);
var s = true;
var o;
try {
o = e.fchmodSync(i, r);
s = false;
} finally{
if (s) try {
e.closeSync(i);
} catch (e) {}
else e.closeSync(i);
}
return o;
};
}
function patchLutimes(e) {
if (n.hasOwnProperty("O_SYMLINK") && e.futimes) {
e.lutimes = function(t, r, i, s) {
e.open(t, n.O_SYMLINK, function(t, n) {
if (t) {
if (s) s(t);
return;
}
e.futimes(n, r, i, function(t) {
e.close(n, function(e) {
if (s) s(t || e);
});
});
});
};
e.lutimesSync = function(t, r, i) {
var s = e.openSync(t, n.O_SYMLINK);
var o;
var c = true;
try {
o = e.futimesSync(s, r, i);
c = false;
} finally{
if (c) try {
e.closeSync(s);
} catch (e) {}
else e.closeSync(s);
}
return o;
};
} else if (e.futimes) {
e.lutimes = function(e, t, r, n) {
if (n) process.nextTick(n);
};
e.lutimesSync = function() {};
}
}
function chmodFix(t) {
if (!t) return t;
return function(r, n, i) {
return t.call(e, r, n, function(e) {
if (chownErOk(e)) e = null;
if (i) i.apply(this, arguments);
});
};
}
function chmodFixSync(t) {
if (!t) return t;
return function(r, n) {
try {
return t.call(e, r, n);
} catch (e) {
if (!chownErOk(e)) throw e;
}
};
}
function chownFix(t) {
if (!t) return t;
return function(r, n, i, s) {
return t.call(e, r, n, i, function(e) {
if (chownErOk(e)) e = null;
if (s) s.apply(this, arguments);
});
};
}
function chownFixSync(t) {
if (!t) return t;
return function(r, n, i) {
try {
return t.call(e, r, n, i);
} catch (e) {
if (!chownErOk(e)) throw e;
}
};
}
function statFix(t) {
if (!t) return t;
return function(r, n, i) {
if ("function" == typeof n) {
i = n;
n = null;
}
function callback(e, t) {
if (t) {
if (t.uid < 0) t.uid += 4294967296;
if (t.gid < 0) t.gid += 4294967296;
}
if (i) i.apply(this, arguments);
}
return n ? t.call(e, r, n, callback) : t.call(e, r, callback);
};
}
function statFixSync(t) {
if (!t) return t;
return function(r, n) {
var i = n ? t.call(e, r, n) : t.call(e, r);
if (i) {
if (i.uid < 0) i.uid += 4294967296;
if (i.gid < 0) i.gid += 4294967296;
}
return i;
};
}
function chownErOk(e) {
if (!e) return true;
if ("ENOSYS" === e.code) return true;
var t = !process.getuid || 0 !== process.getuid();
if (t) {
if ("EINVAL" === e.code || "EPERM" === e.code) return true;
}
return false;
}
}
},
589: (e)=>{
"use strict";
e.exports = function(e) {
if (!e) return false;
return e instanceof Array || Array.isArray(e) || e.length >= 0 && e.splice instanceof Function;
};
},
9: (e)=>{
"use strict";
e.exports = parseJson;
function parseJson(e, t, r) {
r = r || 20;
try {
return JSON.parse(e, t);
} catch (t) {
if ("string" != typeof e) {
const t = Array.isArray(e) && 0 === e.length;
const r = "Cannot parse " + (t ? "an empty array" : String(e));
throw new TypeError(r);
}
const n = t.message.match(/^Unexpected token.*position\s+(\d+)/i);
const i = n ? +n[1] : t.message.match(/^Unexpected end of JSON.*/i) ? e.length - 1 : null;
if (null != i) {
const n = i <= r ? 0 : i - r;
const s = i + r >= e.length ? e.length : i + r;
t.message += ` while parsing near '${0 === n ? "" : "..."}${e.slice(n, s)}${s === e.length ? "" : "..."}'`;
} else t.message += ` while parsing '${e.slice(0, 2 * r)}'`;
throw t;
}
}
},
324: (e, t, r)=>{
"use strict";
const n = r(17);
const i = r(127);
const s = r(308);
const o = r(264);
const c = r(119);
const parse = (e, t)=>o(s(e), n.relative(".", t));
e.exports = (e)=>c(i.readFile)(e, "utf8").then((t)=>parse(t, e));
e.exports.sync = (e)=>parse(i.readFileSync(e, "utf8"), e);
},
69: (e, t, r)=>{
"use strict";
const n = r(17);
const i = r(383);
const s = r(367);
e.exports = (e, t)=>{
t = Object.assign({
cwd: process.cwd()
}, t);
return s(e, (e)=>i(n.resolve(t.cwd, e)), t);
};
e.exports.sync = (e, t)=>{
t = Object.assign({
cwd: process.cwd()
}, t);
for (const r of e)if (i.sync(n.resolve(t.cwd, r))) return r;
};
},
273: (e, t, r)=>{
"use strict";
const n = r(965);
e.exports = (e)=>{
if (e < 1) throw new TypeError("Expected `concurrency` to be a number from 1 and up");
const t = [];
let r = 0;
const next = ()=>{
r--;
if (t.length > 0) t.shift()();
};
return (i)=>new Promise((s, o)=>{
const run = ()=>{
r++;
n(i).then((e)=>{
s(e);
next();
}, (e)=>{
o(e);
next();
});
};
if (r < e) run();
else t.push(run);
});
};
},
367: (e, t, r)=>{
"use strict";
const n = r(273);
class EndError extends Error {
constructor(e){
super();
this.value = e;
}
}
const finder = (e)=>Promise.all(e).then((e)=>true === e[1] && Promise.reject(new EndError(e[0])));
e.exports = (e, t, r)=>{
r = Object.assign({
concurrency: 1 / 0,
preserveOrder: true
}, r);
const i = n(r.concurrency);
const s = Array.from(e).map((e)=>[
e,
i(()=>Promise.resolve(e).then(t))
]);
const o = n(r.preserveOrder ? 1 : 1 / 0);
return Promise.all(s.map((e)=>o(()=>finder(e)))).then(()=>{}).catch((e)=>e instanceof EndError ? e.value : Promise.reject(e));
};
},
965: (e)=>{
"use strict";
e.exports = (e)=>new Promise((t)=>{
t(e());
});
},
264: (e, t, r)=>{
"use strict";
const n = r(305);
const i = r(9);
const s = n("JSONError", {
fileName: n.append("in %s")
});
e.exports = (e, t, r)=>{
if ("string" == typeof t) {
r = t;
t = null;
}
try {
try {
return JSON.parse(e, t);
} catch (r) {
i(e, t);
throw r;
}
} catch (e) {
e.message = e.message.replace(/\n/g, "");
const t = new s(e);
if (r) t.fileName = r;
throw t;
}
};
},
383: (e, t, r)=>{
"use strict";
const n = r(147);
e.exports = (e)=>new Promise((t)=>{
n.access(e, (e)=>{
t(!e);
});
});
e.exports.sync = (e)=>{
try {
n.accessSync(e);
return true;
} catch (e) {
return false;
}
};
},
119: (e)=>{
"use strict";
const processFn = (e, t)=>function() {
const r = t.promiseModule;
const n = new Array(arguments.length);
for(let e = 0; e < arguments.length; e++)n[e] = arguments[e];
return new r((r, i)=>{
if (t.errorFirst) n.push(function(e, n) {
if (t.multiArgs) {
const t = new Array(arguments.length - 1);
for(let e = 1; e < arguments.length; e++)t[e - 1] = arguments[e];
if (e) {
t.unshift(e);
i(t);
} else r(t);
} else if (e) i(e);
else r(n);
});
else n.push(function(e) {
if (t.multiArgs) {
const e = new Array(arguments.length - 1);
for(let t = 0; t < arguments.length; t++)e[t] = arguments[t];
r(e);
} else r(e);
});
e.apply(this, n);
});
};
e.exports = (e, t)=>{
t = Object.assign({
exclude: [
/.+(Sync|Stream)$/
],
errorFirst: true,
promiseModule: Promise
}, t);
const filter = (e)=>{
const match = (t)=>"string" == typeof t ? e === t : t.test(e);
return t.include ? t.include.some(match) : !t.exclude.some(match);
};
let r;
r = "function" == typeof e ? function() {
if (t.excludeMain) return e.apply(this, arguments);
return processFn(e, t).apply(this, arguments);
} : Object.create(Object.getPrototypeOf(e));
for(const n in e){
const i = e[n];
r[n] = "function" == typeof i && filter(n) ? processFn(i, t) : i;
}
return r;
};
},
817: (e, t, r)=>{
"use strict";
const n = r(17);
const i = r(834);
const s = r(324);
const o = new WeakMap;
const filepath = (e)=>o.get(e);
const findNextCwd = (e)=>n.resolve(n.dirname(e), "..");
const addFp = (e, t)=>{
o.set(e, t);
return e;
};
const pkgConf = (e, t)=>{
if (!e) return Promise.reject(new TypeError("Expected a namespace"));
t = t || {};
return i("package.json", t.cwd ? {
cwd: t.cwd
} : {}).then((r)=>{
if (!r) return addFp(Object.assign({}, t.defaults), r);
return s(r).then((n)=>{
if (t.skipOnFalse && false === n[e]) {
const n = Object.assign({}, t, {
cwd: findNextCwd(r)
});
return pkgConf(e, n);
}
return addFp(Object.assign({}, t.defaults, n[e]), r);
});
});
};
const sync = (e, t)=>{
if (!e) throw new TypeError("Expected a namespace");
t = t || {};
const r = i.sync("package.json", t.cwd ? {
cwd: t.cwd
} : {});
if (!r) return addFp(Object.assign({}, t.defaults), r);
const n = s.sync(r);
if (t.skipOnFalse && false === n[e]) {
const n = Object.assign({}, t, {
cwd: findNextCwd(r)
});
return sync(e, n);
}
return addFp(Object.assign({}, t.defaults, n[e]), r);
};
e.exports = pkgConf;
e.exports.filepath = filepath;
e.exports.sync = sync;
},
567: (e, t, r)=>{
"use strict";
const n = r(852);
e.exports = Object.assign(new n, {
Signale: n
});
},
852: (e, t, r)=>{
"use strict";
const n = r(837);
const i = r(17);
const s = r(521);