MCPcopy Create free account
hub / github.com/Semporia/Scripts / Env

Function Env

jd_redPacket.js:1566–1838  ·  view source on GitHub ↗
(t, e)

Source from the content-addressed store, hash-verified

1564}(this);
1565
1566function Env(t, e) {
1567 "undefined" != typeof process && JSON.stringify(process.env).indexOf("GITHUB") > -1 && process.exit(0);
1568
1569 class s {
1570 constructor(t) {
1571 this.env = t
1572 }
1573
1574 send(t, e = "GET") {
1575 t = "string" == typeof t ? {url: t} : t;
1576 let s = this.get;
1577 return "POST" === e && (s = this.post), new Promise((e, i) => {
1578 s.call(this, t, (t, s, r) => {
1579 t ? i(t) : e(s)
1580 })
1581 })
1582 }
1583
1584 get(t) {
1585 return this.send.call(this.env, t)
1586 }
1587
1588 post(t) {
1589 return this.send.call(this.env, t, "POST")
1590 }
1591 }
1592
1593 return new class {
1594 constructor(t, e) {
1595 this.name = t, this.http = new s(this), this.data = null, this.dataFile = "box.dat", this.logs = [], this.isMute = !1, this.isNeedRewrite = !1, this.logSeparator = "\n", this.startTime = (new Date).getTime(), Object.assign(this, e), this.log("", `🔔${this.name}, 开始!`)
1596 }
1597
1598 isNode() {
1599 return "undefined" != typeof module && !!module.exports
1600 }
1601
1602 isQuanX() {
1603 return "undefined" != typeof $task
1604 }
1605
1606 isSurge() {
1607 return "undefined" != typeof $httpClient && "undefined" == typeof $loon
1608 }
1609
1610 isLoon() {
1611 return "undefined" != typeof $loon
1612 }
1613
1614 toObj(t, e = null) {
1615 try {
1616 return JSON.parse(t)
1617 } catch {
1618 return e
1619 }
1620 }
1621
1622 toStr(t, e = null) {
1623 try {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected