/* This Source Code Form is subject to the terms of the Mozilla Public การแปล - /* This Source Code Form is subject to the terms of the Mozilla Public ไทย วิธีการพูด

/* This Source Code Form is subject

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

"use strict";

/* General utilities used throughout devtools. */

// hasChrome is provided as a global by the loader. It is true if we are running
// on the main thread, and false if we are running on a worker thread.
var { Ci, Cu } = require("chrome");
var Services = require("Services");
var { setTimeout } = require("Timer");

/**
* Turn the error |aError| into a string, without fail.
*/
exports.safeErrorString = function safeErrorString(aError) {
try {
let errorString = aError.toString();
if (typeof errorString == "string") {
// Attempt to attach a stack to |errorString|. If it throws an error, or
// isn't a string, don't use it.
try {
if (aError.stack) {
let stack = aError.stack.toString();
if (typeof stack == "string") {
errorString += "
Stack: " + stack;
}
}
} catch (ee) { }

// Append additional line and column number information to the output,
// since it might not be part of the stringified error.
if (typeof aError.lineNumber == "number" && typeof aError.columnNumber == "number") {
errorString += "Line: " + aError.lineNumber + ", column: " + aError.columnNumber;
}

return errorString;
}
} catch (ee) { }

return "";
}

/**
* Report that |aWho| threw an exception, |aException|.
*/
exports.reportException = function reportException(aWho, aException) {
let msg = aWho + " threw an exception: " + exports.safeErrorString(aException);

dump(msg + "
");

if (Cu.reportError) {
/*
* Note that the xpcshell test harness registers an observer for
* console messages, so when we're running tests, this will cause
* the test to quit.
*/
Cu.reportError(msg);
}
}

/**
* Given a handler function that may throw, return an infallible handler
* function that calls the fallible handler, and logs any exceptions it
* throws.
*
* @param aHandler function
* A handler function, which may throw.
* @param aName string
* A name for aHandler, for use in error messages. If omitted, we use
* aHandler.name.
*
* (SpiderMonkey does generate good names for anonymous functions, but we
* don't have a way to get at them from JavaScript at the moment.)
*/
exports.makeInfallible = function makeInfallible(aHandler, aName) {
if (!aName)
aName = aHandler.name;

return function (/* arguments */) {
try {
return aHandler.apply(this, arguments);
} catch (ex) {
let who = "Handler function";
if (aName) {
who += " " + aName;
}
exports.reportException(who, ex);
}
}
}

/**
* Interleaves two arrays element by element, returning the combined array, like
* a zip. In the case of arrays with different sizes, undefined values will be
* interleaved at the end along with the extra values of the larger array.
*
* @param Array a
* @param Array b
* @returns Array
* The combined array, in the form [a1, b1, a2, b2, ...]
*/
exports.zip = function zip(a, b) {
if (!b) {
return a;
}
if (!a) {
return b;
}
const pairs = [];
for (let i = 0, aLength = a.length, bLength = b.length;
i < aLength || i < bLength;
i++) {
pairs.push([a[i], b[i]]);
}
return pairs;
};

/**
* Waits for the next tick in the event loop to execute a callback.
*/
exports.executeSoon = function executeSoon(aFn) {
Services.tm.mainThread.dispatch({
run: exports.makeInfallible(aFn)
}, Ci.nsIThread.DISPATCH_NORMAL);
};

/**
* Waits for the next tick in the event loop.
*
* @return Promise
* A promise that is resolved after the next tick in the event loop.
*/
exports.waitForTick = function waitForTick() {
let deferred = promise.defer();
exports.executeSoon(deferred.resolve);
return deferred.promise;
};

/**
* Waits for the specified amount of time to pass.
*
* @param number aDelay
* The amount of time to wait, in milliseconds.
* @return Promise
* A promise that is resolved after the specified amount of time passes.
*/
exports.waitForTime = function waitForTime(aDelay) {
let deferred = promise.defer();
setTimeout(deferred.resolve, aDelay);
return deferred.promise;
};

/**
* Like Array.prototype.forEach, but doesn't cause jankiness when iterating over
* very large arrays by yielding to the browser and continuing execution on the
* next tick.
*
* @param Array aArray
* The array being iterated over.
* @param Function aFn
* The function called on each item in the array. If a promise is
* returned by this function, iterating over the array will be paused
* until the respective promise is resolved.
* @returns Promise
* A promise that is resolved once the whole array has been iterated
* over, and all promises returned by the aFn callback are resolved.
*/
exports.yieldingEach = function yieldingEach(aArray, aFn) {
const deferred = promise.defer();

let i = 0;
let len = aArray.length;
let outstanding = [deferred.promise];

(function loop() {
const start = Date.now();

while (i < len) {
// Don't block the main thread for longer than 16 ms at a time. To
// maintain 60fps, you have to render every frame in at least 16ms; we
// aren't including time spent in non-JS here, but this is Good
// Enough(tm).
if (Date.now() - start > 16) {
exports.executeSoon(loop);
return;
}

try {
outstanding.push(aFn(aArray[i], i++));
} catch (e) {
deferred.reject(e);
return;
}
}

deferred.resolve();
}());

return promise.all(outstanding);
}

/**
* Like XPCOMUtils.defineLazyGetter, but with a |this| sensitive getter that
* allows the lazy getter to be defined on a prototype and work correctly with
* instances.
*
* @param Object aObject
* The prototype object to define the lazy getter on.
* @param String aKey
* The key to define the lazy getter on.
* @param Function aCallback
* The callback that will be called to determine the value. Will be
* called with the |this| value of the current instance.
*/
exports.defineLazyPrototypeGetter =
function defineLazyPrototypeGetter(aObject, aKey, aCallback) {
Object.defineProperty(aObject, aKey, {
configurable: true,
get: function() {
const value = aCallback.call(this);

Object.defineProperty(this, aKey, {
configurable: true,
writable: true,
value: value
});

return value;
}
});
}

/**
* Safely get the property value from a Debugger.Object for a given key. Walks
* the prototype chain until the property is found.
*
* @param Debugger.Object aObject
* The Debugger.Object to get the value from.
* @param String aKey
* The key to look for.
* @return Any
*/
exports.getProperty = function getProperty(aObj, aKey) {
let root = aObj;
try {
do {
const desc = aObj.getOwnPropertyDescriptor(aKey);
if (desc) {
if ("value" in desc) {
return desc.value;
}
// Call the getter if it's safe.
return exports.hasSafeGetter(desc) ? desc.get.call(root).return : undefined;
}
aObj = aObj.proto;
} while (aObj);
} catch (e) {
// If anything goes wrong report the error and return undefined.
exports.reportException("getProperty", e);
}
return undefined;
};

/**
* Determines if a descriptor has a getter which doesn't call into JavaScript.
*
* @param Object aDesc
* The descriptor to check for a safe getter.
* @return Boolean
* Whether a safe getter was found.
*/
exports.hasSafeGetter = function hasSafeGetter(aDesc) {
let fn = aDesc.get;
return fn && fn.callable && fn.class == "Function" && fn.script === undefined;
};

/**
* Check if it is safe to read properties and execute methods from the given JS
* object. Safety is defined as being protected from unintended code execution
* from content scripts (or cross-compartment code).
*
* See bugs 945920 and 946752 for discussion.
*
* @type Object aObj
* The object to check.
* @return Boolean
* True if it is safe to read properties from aObj, or false otherwise.
*/
exports.isSafeJSObject = function isSafeJSObject(aObj) {
if (Cu.getGlobalForObject(aObj) ==
Cu.getGlobalForObject(exports.isSafeJSObject)) {
return true; // aObj is not a cross-compartment wrapper.
}

let principal = Cu.getObjectPrincipal(aObj);
if (Services.scriptSecurityManager.isSystemPrincipal(principal)) {
return true; // allow chrome objects
}

return Cu.isXrayWrapper(aObj);
};

exports.dumpn = function dumpn(str) {
if (exports.dumpn.wantLogging) {
dump("DBG-SERVER: " + str + "
");
}
}

// We want wantLogging to be writable. The exports object is frozen by the
// loader, so define it on dumpn instead.
exports.dumpn.wantLogging = false;

exports.dbg_assert = function dbg_assert(cond, e) {
if (!cond) {
return e;
}
}
0/5000
จาก: -
เป็น: -
ผลลัพธ์ (ไทย) 1: [สำเนา]
คัดลอก!
/ * นี้รหัสฟอร์มมีเงื่อนไขความ Mozilla * ใบอนุญาต v. 2.0 ถ้าสำเนาของ MPL ไม่ได้มีการกระจายนี้ * ไฟล์ คุณสามารถขอรับที่ http://mozilla.org/MPL/2.0/ */"ใช้อย่างเข้มงวด"/ * สาธารณูปโภคทั่วไปที่ใช้ตลอดทั้ง devtools */hasChrome ให้เป็นสากล โดยโหลด มันเป็นความจริงถ้าเรากำลังทำงานอยู่หัวข้อหลัก และถ้าเป็นเท็จ เรากำลังทำบนเธรดของผู้ปฏิบัติงานvar {Ci, Cu } = require("chrome")บริการ var = require("Services")var {setTimeout } = require("Timer")/** เปิด |aError| ข้อผิดพลาด เป็นสายอักขระ โดยไม่ล้มเหลว */exports.safeErrorString ={safeErrorString(aError) ฟังก์ชัน ลอง{ ให้ errorString = aError.toString() ถ้า (typeof errorString == "สตริง") { พยายามกับกองซ้อน |errorString| ถ้าจะพ่นผิด หรือ ไม่สาย ไม่ได้ใช้งาน ลอง{ ถ้า{(aError.stack) ให้กอง = aError.stack.toString() ถ้า (กอง typeof == "สตริง") { errorString += "
Stack: " + กอง } } } {} (ee) จับ ผนวกบรรทัดเพิ่มเติมและข้อมูลหมายเลขของคอลัมน์ผลลัพธ์ เนื่องจากมันอาจไม่ได้เป็นส่วนหนึ่งของข้อผิดพลาด stringified ถ้า (typeof aError.lineNumber == "หมายเลข" & & typeof aError.columnNumber == "หมายเลข") { errorString += "บรรทัด: " + aError.lineNumber + ", คอลัมน์: " + aError.columnNumber } errorString กลับ } } {} (ee) จับ กลับมา"";}/** รายงานที่ |aWho| สร้างข้อยกเว้น |aException| */exports.reportException ={ฟังก์ชัน reportException (aWho, aException) ให้ผงชูรส = aWho + "มีข้อยกเว้น: " + exports.safeErrorString(aException) ถ่ายโอนข้อมูล (ผงชูรส + "
"); ถ้า{(Cu.reportError) /* * หมายเหตุว่า เทียมทดสอบ xpcshell เป็นแหล่งสำหรับการลงทะเบียน * ข้อความคอนโซล ดังนั้นเมื่อเรากำลังรันการทดสอบ นี้จะทำให้ * การทดสอบจบ */ Cu.reportError(msg) }}/** กำหนดฟังก์ชันตัวจัดการที่อาจโยน กลับตัวจัดการที่ถูกต้อง * ฟังก์ชัน ที่เรียกใช้ตัวจัดการ fallible ล็อกข้อยกเว้น นั้น * ขว้าง * ฟังก์ชัน aHandler * @param * การจัดการฟังก์ชัน ซึ่งอาจโยน สตริ aName * @param * เป็นชื่อสำหรับ aHandler สำหรับการใช้ในข้อความข้อผิดพลาด ถ้าไม่ใส่ เราใช้ * aHandler.name * * (SpiderMonkey สร้างดีชื่อฟังก์ชันไม่ แต่เรา * ไม่ได้รับพวกเขาจาก JavaScript ในขณะนั้น) */exports.makeInfallible ={ฟังก์ชัน makeInfallible (aHandler, aName) ถ้า (! aName) aName = aHandler.name ส่งกลับฟังก์ชัน (/ * อาร์กิวเมนต์ * /) { ลอง{ กลับ aHandler.apply (นี้ อาร์กิวเมนต์); ตรวจจับ (อดีต) { ให้ที่ "จัดการ" ฟังก์ชัน = ถ้า{(aName) ที่+= "" + aName } exports.reportException(who, ex) } }}/** Interleaves อาร์เรย์สององค์ประกอบโดยองค์ประกอบ ความอาร์เรย์รวม เช่น * การไปรษณีย์ ในกรณีของอาร์เรย์มีขนาดแตกต่างกัน ไม่ได้กำหนดค่าจะเป็น * แผนที่ในตอนท้ายพร้อมกับค่าของอาร์เรย์ขนาดใหญ่พิเศษ * เรย์ * @param บีอาร์เรย์ * @param เรย์ * @returns * รวมอาร์เรย์ ในแบบ [a1, b1, a2, b2,...] */exports.zip ={(a, b) ไปรษณีย์ฟังก์ชัน ถ้า (! b) { กลับเป็น } ถ้า (! การ) { กลับ b } คู่ค่า const =[]; สำหรับ (ให้ฉัน = 0, aLength = a.length, bLength = b.length ฉัน < aLength || ฉัน < bLength i++) { pairs.push ([a [i], b[i]]) } กลับคู่};/** * รอขีดถัดไปวนรอบในกรณีที่การดำเนินการติดต่อกลับ */exports.executeSoon ={executeSoon(aFn) ฟังก์ชัน Services.tm.mainThread.dispatch ({ ทำงาน: exports.makeInfallible(aFn) }, Ci.nsIThread.DISPATCH_NORMAL);};/** * รอขีดถัดไปวนในกรณีที่ * สัญญา * @return * สัญญาที่แก้ไขหลังจากขีดถัดไปวนในกรณีที่ */exports.waitForTick ={waitForTick() ฟังก์ชัน ให้เลื่อนเวลา = promise.defer() exports.executeSoon(deferred.resolve) deferred.promise กลับ};/** * รอระบุจำนวนเวลาที่จะส่ง * * @param หมายเลข aDelay * จำนวนของเวลาในการรอ ในหน่วยมิลลิวินาที สัญญา * @return * เป็นสัญญาที่แก้ไขหลังจากเวลาผ่านไป */exports.waitForTime ={waitForTime(aDelay) ฟังก์ชัน ให้เลื่อนเวลา = promise.defer() setTimeout (deferred.resolve, aDelay); deferred.promise กลับ};/** เช่น Array.prototype.forEach แต่ไม่ทำให้เกิด jankiness เมื่อวนซ้ำ * อาร์เรย์ขนาดใหญ่มาก โดยผลผลิตไปยังเบราว์เซอร์ และต่อการดำเนินการในการ * ขีดถัดไป * * @param อาร์เรย์ aArray * มีทวิภาควนซ้ำผ่านอาร์เรย์ aFn ฟังก์ชัน * @param * การทำงานที่เรียกว่าแต่ละรายการในอาร์เรย์ ถ้าสัญญา * ที่ถูกส่งกลับ โดยฟังก์ชันนี้ วนซ้ำอาร์เรย์จะถูกหยุดชั่วคราว * จนกว่าสัญญาเกี่ยวข้องไม่ได้รับการแก้ไข สัญญา * @returns * สัญญาที่แก้ไขเมื่ออาร์เรย์ทั้งหมดได้ถูกทวิภาควนซ้ำ * กว่า และสัญญาทั้งหมดที่ส่งคืน โดยติดต่อกลับ aFn ที่แก้ไข */exports.yieldingEach ={yieldingEach (aArray, aFn) ฟังก์ชัน เลื่อนเวลา const = promise.defer() ให้ฉัน = 0 ให้เลน = aArray.length ให้โดดเด่น = [deferred.promise]; (ฟังก์ชัน loop() { เริ่มต้นค่า const = Date.now() ในขณะที่ (ฉัน < เลน) { อย่าบล็อกหัวข้อหลักสำหรับยาวเกิน 16 ms ครั้ง ถึง รักษา 60fps คุณต้องแสดงทุกเฟรมที่ 16ms เรา ไม่รวมเวลาที่ใช้ไม่ใช่-JS ที่นี่ แต่นี้เป็นดี Enough(tm) ถ้า (Date.now() - เริ่มต้น > 16) { exports.executeSoon(loop) กลับ } ลอง{ outstanding.push (aFn (aArray [i] i ++)); } {(e) จับ deferred.reject(e) กลับ } } deferred.resolve() }()); promise.all(outstanding) กลับ}/** * เช่น XPCOMUtils.defineLazyGetter แต่การ |this| มีที่สำคัญที่ ให้มีขี้เกียจกำหนดบนต้นแบบ และทำงานอย่างถูกต้องด้วย * อินสแตนซ์ * aObject * @param วัตถุ * วัตถุต้นแบบกำหนดมีขี้เกียจ * @param สตริ aKey * คีย์สามารถมีซี่บน * @param ฟังก์ชัน aCallback * การเรียกกลับที่จะเรียกว่าการกำหนดค่า จะ * เรียก ด้วย |this| ค่าของอินสแตนซ์ปัจจุบัน */exports.defineLazyPrototypeGetter =ฟังก์ชัน defineLazyPrototypeGetter (aObject, aCallback aKey ) { Object.defineProperty (aObject, aKey { โครง: จริง รับ: function() { ค่าค่า const = aCallback.call(this) Object.defineProperty (นี้ aKey { โครง: จริง เขียน: ความจริง ค่า: ค่า }); ส่งกลับค่า } });}/** * ปลอดภัยได้ค่าคุณสมบัติ Debugger.Object เป็นการกำหนดคีย์ เดิน * ต้นแบบสายจนพบคุณสมบัติ * * @param Debugger.Object aObject * Debugger.Object การรับค่าจาก * @param สตริ aKey * คีย์เพื่อค้นหา * @return ใด ๆ */exports.getProperty =ฟังก์ชัน getProperty (aObj, aKey) { ให้ราก = aObj ลอง{ ทำ{ สูงสุดค่า const = aObj.getOwnPropertyDescriptor(aKey) ถ้า{(สูงสุด) ถ้า{("ค่า" สูงสุด) desc.value กลับ } โทรมีที่ปลอดภัย กลับ exports.hasSafeGetter(desc) .return desc.get.call (ราก): ยังไม่ได้กำหนด } aObj = aObj.proto } ขณะ (aObj); } {(e) จับ ถ้าอะไรผิด รายงานข้อผิดพลาด และกลับไม่ได้กำหนด exports.reportException ("getProperty", e); } กลับไม่ได้กำหนด};/** * กำหนดถ้าบอกการได้มีซึ่งไม่เรียกเป็น JavaScript * aDesc * @param วัตถุ * ตัวบอกเกี่ยวกับการตรวจสอบมีความปลอดภัย บูลีน * @return * ว่ามีเซฟพบ */exports.hasSafeGetter ={hasSafeGetter(aDesc) ฟังก์ชัน ให้ fn = aDesc.get กลับ fn & & fn.callable และ & fn.class == "ฟังก์ชัน" & & fn.script === ยังไม่ได้กำหนด};/** * ตรวจสอบว่า เป็นเซฟไปอ่านคุณสมบัติ และปฏิบัติวิธีจาก JS กำหนด * วัตถุ ความปลอดภัยถูกกำหนดเป็นการป้องกันจากโค้ดไม่ได้ตั้งใจ * จากสคริปต์เนื้อหา (หรือข้ามช่องรหัส) * * ดูข้อผิดพลาด 945920 และ 946752 สำหรับการสนทนา * aObj * @type วัตถุ * วัตถุเพื่อตรวจสอบ บูลีน * @return * จริงปลอดภัยอ่านคุณสมบัติจาก aObj หรือเท็จมิฉะนั้น */exports.isSafeJSObject ={isSafeJSObject(aObj) ฟังก์ชัน ถ้า (Cu.getGlobalForObject(aObj) == Cu.getGlobalForObject(exports.isSafeJSObject)) { กลับเป็นจริง aObj ไม่ห่อข้ามช่อง } ให้หลัก = Cu.getObjectPrincipal(aObj) ถ้า (Services.scriptSecurityManager.isSystemPrincipal(principal)) { กลับเป็นจริง ทำให้วัตถุโครเมี่ยม } Cu.isXrayWrapper(aObj) กลับ};exports.dumpn ={dumpn(str) ฟังก์ชัน ถ้า{(exports.dumpn.wantLogging) ถ่ายโอนข้อมูล ("เซิร์ฟเวอร์ DBG: " + str + "
"); }}เราต้อง wantLogging ให้เขียน ส่งออกวัตถุถูกแช่แข็งโดยโหลด เพื่อ กำหนดว่าใน dumpn แทนexports.dumpn.wantLogging = falseexports.dbg_assert ={ฟังก์ชัน dbg_assert (cond, e) ถ้า (! cond) { กลับ e }}
การแปล กรุณารอสักครู่..
ผลลัพธ์ (ไทย) 2:[สำเนา]
คัดลอก!
/ * รหัสที่มาแบบฟอร์มนี้อยู่ภายใต้เงื่อนไขของประชาชน Mozilla
ใบอนุญาต * v. 2.0 ถ้าสำเนาของ MPL ไม่ได้กระจายกับ
ไฟล์ * คุณสามารถได้รับหนึ่งที่ http://mozilla.org/MPL/2.0/ * / "ใช้อย่างเข้มงวด"; / ​​* สาธารณูปโภคทั่วไปใช้ตลอด devtools * / // hasChrome ให้เป็นโลกโดยการโหลด มันเป็นความจริงถ้าเรากำลังทำงาน// ในหัวข้อหลักและเท็จถ้าเรากำลังทำงานอยู่บนด้ายคน. var {Ci, Cu} = ต้อง ("โครเมี่ยม"); var บริการ = ต้อง ("บริการ"); var {} = setTimeout ต้อง ("เวลา"); / ** . * เปิดข้อผิดพลาด | aError | เป็นสตริงโดยไม่ต้องล้มเหลว* / exports.safeErrorString = safeErrorString ฟังก์ชั่น (aError) { try { ให้ errorString = aError.toString () ; ถ้า (typeof errorString == "สตริง") { // พยายามที่จะแนบไปยังกอง | errorString | ถ้ามันจะพ่นข้อผิดพลาดหรือไม่ // สตริงไม่ได้ใช้มัน. try { ถ้า (aError.stack) { ให้กอง = aError.stack.toString (); ถ้า (กอง typeof == "สตริง" ) { errorString + = " nStack:" + กอง; } } } catch (EE) {} // ผนวกสายเพิ่มเติมและข้อมูลจำนวนคอลัมน์ที่จะส่งออก// เพราะมันอาจจะไม่เป็นส่วนหนึ่งของข้อผิดพลาด stringified. ถ้า ( typeof aError.lineNumber == "จำนวน" && typeof aError.columnNumber == "จำนวน") { errorString + = "เส้น" + aError.lineNumber + "คอลัมน์" + aError.columnNumber; } กลับ errorString; } } catch (EE) {} กลับ "







































";
} / ** . * รายงานข่าวว่า | aWho | โยนข้อยกเว้น | aException | * / exports.reportException = reportException ฟังก์ชั่น (aWho, aException) { ให้ msg = aWho + "โยนข้อยกเว้น" + exports.safeErrorString ( aException) การถ่ายโอนข้อมูล (msg + " n"); ถ้า (Cu.reportError) { / * * * * * * * * โปรดทราบว่าเทียมทดสอบ xpcshell ลงทะเบียนสำหรับผู้สังเกตการณ์* ข้อความคอนโซลดังนั้นเมื่อเรากำลังใช้การทดสอบนี้จะทำให้เกิด* การทดสอบที่จะเลิก. * / Cu.reportError (msg); } } / ** * ฟังก์ชั่นได้รับการจัดการที่อาจโยนกลับจัดการความผิด* ฟังก์ชั่นที่เรียกตัวจัดการทำผิดได้และบันทึกข้อยกเว้นใด ๆ มันพ่น *. * * * * * * * * @ พระรามฟังก์ชั่น aHandler * ฟังก์ชั่นการจัดการซึ่งอาจจะโยน. * @ พระรามสตริง ANAME * ชื่อ aHandler สำหรับใช้ในข้อความผิดพลาด. ถ้าไม่มีการระบุที่เราใช้aHandler.name *. * * * * * * * * (แมงมุมจะสร้างชื่อที่ดีสำหรับฟังก์ชั่นที่ไม่ระบุชื่อ แต่เรา* ไม่ได้มีวิธีการที่จะได้รับพวกเขาจากการใช้งาน JavaScript ในขณะนี้). * / exports.makeInfallible = makeInfallible ฟังก์ชั่น (aHandler, ANAME) { ถ้า (ANAME)! ANAME = aHandler.name; ฟังก์ชั่นการกลับมา (/ ข้อโต้แย้ง * * /) { try { กลับ aHandler.apply (ซึ่งขัดแย้ง); } catch (อดีต) { ให้ที่ = "ฟังก์ชั่ Handler"; ถ้า (ANAME) { ที่ + = "" + ANAME; } exports.reportException ( ที่อดีต); } } } / ** * interleaves สององค์ประกอบอาร์เรย์โดยองค์ประกอบกลับอาร์เรย์รวมเช่น* ไปรษณีย์ ในกรณีของอาร์เรย์ที่มีขนาดที่แตกต่างกันไม่ได้กำหนดค่าจะเป็น* บรรณนิทัศน์ ณ สิ้นพร้อมกับค่าพิเศษของอาร์เรย์ขนาดใหญ่. * * * * * * * * @ พระรามอาร์เรย์* @ พระรามอาร์เรย์ข* @returns อาร์เรย์* อาเรย์รวมใน รูปแบบ [a1, b1, A2, B2, ... ] * / exports.zip = ซิปฟังก์ชั่น (b) { ถ้า {(ข) กลับ; } ถ้า {(!) ผลตอบแทนข; } คู่ const = []; for (ให้ i = 0, aLength = a.length, bLength = b.length; ฉัน <aLength || ฉัน <bLength; i ++) { pairs.push ([[i] ข [i]] ); } คู่กลับ; }; / ** * รอสำหรับติ๊กต่อไปในห่วงเหตุการณ์ที่จะดำเนินการเรียกกลับ. * / exports.executeSoon = executeSoon ฟังก์ชั่น (AFN) { Services.tm.mainThread.dispatch ({ ทำงาน: การส่งออก .makeInfallible (AFN) } Ci.nsIThread.DISPATCH_NORMAL); }; / ** . * รอติ๊กต่อไปในวงเหตุการณ์* * * * * * * * กลับ @ สัญญา* สัญญาว่าจะแก้ไขปัญหาได้หลังจากที่ติ๊กต่อไปในวงเหตุการณ์* / exports.waitForTick ฟังก์ชั่น = waitForTick () { ให้รอการตัดบัญชี = promise.defer (); exports.executeSoon (deferred.resolve); กลับ deferred.promise; }; / ** * รอสำหรับจำนวนเงินที่กำหนดเวลาที่จะผ่าน* * * * * * * * หมายเลข @ พระราม aDelay * เวลาที่จะรอในมิลลิวินาที. * กลับ @ สัญญา* สัญญาว่าจะแก้ไขปัญหาได้หลังจากที่จำนวนเงินที่ระบุเวลาผ่านไป. * / exports.waitForTime = waitForTime ฟังก์ชั่น (aDelay) { ให้รอการตัดบัญชี = promise.defer (); setTimeout (deferred.resolve, aDelay); กลับ deferred.promise; }; / ** * ชอบ Array.prototype.forEach แต่ไม่ก่อให้เกิด jankiness เมื่อ iterating กว่า* อาร์เรย์มีขนาดใหญ่มากโดยยอมที่จะ เบราว์เซอร์และการดำเนินการอย่างต่อเนื่องเกี่ยวกับติ๊กต่อไป *. * * * * * * * * @ พระรามอาร์เรย์ aArray * อาร์เรย์ถูกซ้ำไป. * @ พระรามฟังก์ชั่น AFN * ฟังก์ชั่นที่เรียกว่าในแต่ละรายการในอาร์เรย์ หากสัญญาถูก* ส่งกลับโดยฟังก์ชันนี้ iterating มากกว่าอาร์เรย์จะถูกหยุดชั่วคราว* จนกว่าสัญญาที่เกี่ยวข้องได้รับการแก้ไข. * @returns สัญญา* สัญญาว่าจะแก้ไขปัญหาได้ทันทีอาร์เรย์ทั้งหมดได้รับการซ้ำ* ไปและสัญญาทั้งหมดส่งกลับโดย โทรกลับ AFN ได้รับการแก้ไข. * / exports.yieldingEach = yieldingEach ฟังก์ชั่น (aArray, AFN) { const รอการตัดบัญชี = promise.defer (); ให้ i = 0; ให้ len = aArray.length; ให้โดดเด่น = [deferred.promise]; (วงฟังก์ชั่น () { เริ่มต้น const = Date.now (); ในขณะที่ (i <len) { . // อย่าปิดกั้นหัวข้อหลักนานกว่า 16 มิลลิวินาทีในช่วงเวลาที่ต้องการ// รักษา 60fps คุณจะต้องทำให้ กรอบทุกอย่างน้อย 16ms เรา// ไม่รวมถึงเวลาที่ใช้ในการไม่ JS นี่ แต่นี้เป็นสิ่งที่ดี. // พอ (TM) ถ้า (Date.now () - เริ่มต้น> 16) { exports.executeSoon ( ห่วง) กลับ; } try { outstanding.push (AFN (aArray [i], i ++)); } catch (จ) { deferred.reject (จ); กลับ; } } deferred.resolve (); } ()) ; ตอบแทน promise.all (ที่โดดเด่น); } / ** * ชอบ XPCOMUtils.defineLazyGetter แต่ด้วย | นี้ | ทะเยอทะยานที่สำคัญที่ช่วยให้ * ทะเยอทะยานขี้เกียจที่จะได้รับการกำหนดไว้ในต้นแบบและการทำงานอย่างถูกต้องกับกรณี *. * * * * * * * * @ พระราม aObject วัตถุ* วัตถุต้นแบบที่จะกำหนดทะเยอทะยานขี้เกียจบน. * @ พระรามสตริง Akey * ที่สำคัญในการกำหนดความทะเยอทะยานขี้เกียจบน. * @ พระรามฟังก์ชั่น aCallback * โทรกลับที่จะถูกเรียกว่าการกำหนดมูลค่า จะได้รับการเรียกว่ามี * | นี้ | ค่าเช่นปัจจุบัน. * / exports.defineLazyPrototypeGetter = defineLazyPrototypeGetter ฟังก์ชั่น (aObject, Akey, aCallback) { Object.defineProperty (aObject, Akey { กำหนด: จริงจะได้รับ: ฟังก์ชั่น () { ค่า const = aCallback.call (นี้); Object.defineProperty (นี้ Akey { กำหนดค่า: true, เขียน: จริง, ค่า: ค่า}); ค่าตอบแทน; } }); } / ** * ปลอดภัยได้รับมูลค่าทรัพย์สิน จาก Debugger.Object สำหรับคีย์ที่กำหนด เดิน* โซ่ต้นแบบจนทรัพย์สินที่พบ. * * * * * * * * @ พระราม Debugger.Object aObject * Debugger.Object ที่จะได้รับค่าจาก. * @ พระรามสตริง Akey * ที่สำคัญที่จะมองหา. * กลับ @ ใด ๆ* / ส่งออก getProperty = getProperty ฟังก์ชั่น (aObj, Akey) { ให้ราก = aObj; try { ทำ { const เรียง = aObj.getOwnPropertyDescriptor (Akey) ถ้า (สูงสุด) { ถ้า ("ค่า" ในสูงสุด) { กลับ desc.value; } / / โทรทะเยอทะยานถ้ามันปลอดภัย. กลับ exports.hasSafeGetter (สูงสุด) desc.get.call (ราก) .return: undefined; } aObj = aObj.proto; } ในขณะที่ (aObj); } catch (จ) { // ถ้ามีอะไรที่ไม่ถูกต้องรายงานข้อผิดพลาดและกลับไม่ได้กำหนด. exports.reportException (" getProperty "จ); } กลับไม่ได้กำหนด; }; / ** . * ตรวจสอบว่ามีข้อบ่งทะเยอทะยานที่ไม่ได้โทรเข้ามาใช้งาน JavaScript * * * * * * * * @ พระรามวัตถุ aDesc . * อธิบายเพื่อตรวจสอบความทะเยอทะยานปลอดภัย* กลับ @ บูลีน. * ไม่ว่าจะเป็นผู้ถูกกระทำความปลอดภัยพบ* / exports.hasSafeGetter = hasSafeGetter ฟังก์ชั่น (aDesc) { ให้ Fn = aDesc.get; กลับ Fn && && fn.callable fn.class == "ฟังก์ชั่น" && fn.script === ไม่ได้กำหนด; }; / ** * ตรวจสอบว่ามีความปลอดภัยในการอ่านคุณสมบัติและดำเนินการวิธีการที่กำหนดจาก JS * วัตถุ ความปลอดภัยถูกกำหนดให้เป็นถูกป้องกันจากการเรียกใช้โค้ดที่ไม่ได้ตั้งใจ* จากสคริปต์เนื้อหา (หรือรหัสข้ามช่อง). * * * * * * * * ดูข้อบกพร่อง 945,920 และ 946,752 สำหรับการอภิปราย. * * * * * * * * @type วัตถุ aObj * วัตถุที่จะตรวจสอบ. * กลับ @ บูล* ทรู ถ้ามันเป็นความปลอดภัยในการอ่านคุณสมบัติจาก aObj หรือเท็จอย่างอื่น. * / exports.isSafeJSObject = isSafeJSObject ฟังก์ชั่น (aObj) { ถ้า (Cu.getGlobalForObject (aObj) == Cu.getGlobalForObject (exports.isSafeJSObject)) { กลับจริง; // aObj ไม่ได้เป็นเสื้อคลุมข้ามช่อง. } ให้เงินต้น = Cu.getObjectPrincipal (aObj) ถ้า (Services.scriptSecurityManager.isSystemPrincipal (เงินต้น)) { กลับจริง; // ให้วัตถุที่เป็นโครเมี่ยม} กลับ Cu.isXrayWrapper (aObj); }; exports.dumpn = dumpn ฟังก์ชั่น (STR) { ถ้า (exports.dumpn.wantLogging) { การถ่ายโอนข้อมูล ("DBG-SERVER:" + Str + " n" ); } } // เราต้องการ wantLogging จะเขียนได้ การส่งออกวัตถุถูกแช่แข็งโดย. โหลด // ดังนั้นกำหนดไว้ใน dumpn แทนexports.dumpn.wantLogging = false; exports.dbg_assert = dbg_assert ฟังก์ชั่น (ระบบอี) { ถ้า (! ปรับอากาศ) { กลับทาง e; } }




















































































































































































































































































การแปล กรุณารอสักครู่..
ผลลัพธ์ (ไทย) 3:[สำเนา]
คัดลอก!
/ * รหัสแหล่งที่มารูปแบบนี้อยู่ภายใต้เงื่อนไขของใบอนุญาตสาธารณะของ Mozilla
* V 2.0 ถ้าสำเนาของ MPL ไม่ได้แจกด้วย
* แฟ้มคุณสามารถได้รับหนึ่งที่ http : / / Mozilla . org / MPL / 2.0 / * /

" ใช้อย่างเข้มงวด " ;

/ * สาธารณูปโภคทั่วไปที่ใช้ตลอด devtools . * /

/ / haschrome ให้เป็นสากล โดยโหลด มันเป็นความจริง ถ้าเราวิ่ง
/ / ในหัวข้อหลักและเป็นเท็จ ถ้าเราวิ่งบนทำงานด้าย
var { CI , ซียู } = ต้อง ( " Chrome " ) ;
บริการ = VAR ต้องการ ( " บริการ " ) ;
settimeout } { var = ต้อง ( " . " ) ;

/ * *
* เปิด | ความคลาดเคลื่อน | เป็นข้อผิดพลาด สตริงโดยไม่ต้องล้มเหลว .
/
exports.safeerrorstring = ฟังก์ชัน safeerrorstring ( ความคลาดเคลื่อน ) { {

ลองให้ errorstring = ความคลาดเคลื่อน . tostring() ;
( ถ้าใช้ errorstring = = " ข้อความ " ) {
/ / พยายามที่จะแนบกอง | errorstring | . ถ้ามันผิดพลาดข้อผิดพลาดหรือ
/ / ไม่ใช่เชือก อย่าไปใช้มันเลย

ลอง { ถ้า ( ความคลาดเคลื่อน กอง ) {
ให้กอง = ความคลาดเคลื่อน กอง . tostring() ;
( ถ้าใช้กอง = = " ข้อความ " ) {
errorstring = " nstack กอง ;
"

} } } จับ ( EE ) { }

/ / ผนวกเพิ่มเติมบรรทัดและหมายเลขคอลัมน์ข้อมูลผลผลิต
/ / เพราะว่ามันอาจจะไม่ได้เป็นส่วนหนึ่งของข้อผิดพลาด stringified .
ถ้าใช้ aerror.linenumber = = " ตัวเลข " ของ&& aerror.columnnumber = = " ตัวเลข " ) {
errorstring = " บรรทัด " aerror.linenumber " คอลัมน์ " ความคลาดเคลื่อน . columnnumber ;
}

กลับมา errorstring ;
}
} จับ ( EE ) { }

กลับมา " < ล้มเหลวพยายามที่จะหาข้อผิดพลาดของรายละเอียด > " ;
}

/ * *
* | องค์การอนามัยโลกรายงานว่า | โยนข้อยกเว้น | aexception | .
/
exports.reportexception = ฟังก์ชัน ( องค์การอนามัยโลก reportexception ,aexception ) {
ให้ MSG = องค์การอนามัยโลก " โยนข้อยกเว้น : " ส่งออก safeerrorstring ( aexception ) ;

ทิ้ง ( MSG " n " ) ;

ถ้า ( ลบ . reporterror ) {
/
* หมายเหตุว่า xpcshell เทียมทดสอบลงทะเบียนสังเกตการณ์สำหรับ
* คอนโซลข้อความ ดังนั้น เมื่อเรา กำลังทดสอบอยู่ ซึ่งจะก่อให้เกิด
*
* / ทดสอบลาออก
ลบ . reporterror ( MSG ) ;
}
}

/ * *
* ให้ผู้ดูแลการทำงานที่อาจโยนกลับแน่นอนผู้ดูแล
* ฟังก์ชันที่เรียกความผิดพลาด แฮนด์เลอร์ และบันทึกข้อยกเว้นใด ๆมัน
* พ่น .
*
*
* @ พระราม ahandler ฟังก์ชันเป็นผู้ดูแลการทำงาน ซึ่งอาจจะโยน .
*
* @ พระราม aname สตริงชื่อ ahandler เพื่อใช้ในข้อความข้อผิดพลาด ถ้าไม่ เราใช้ ahandler
*
*
* ชื่อ สไปเดอร์มังกี้ ( ไม่สร้างชื่อที่ดีสำหรับฟังก์ชันที่ไม่ระบุชื่อ แต่เรา
การแปล กรุณารอสักครู่..
 
ภาษาอื่น ๆ
การสนับสนุนเครื่องมือแปลภาษา: กรีก, กันนาดา, กาลิเชียน, คลิงออน, คอร์สิกา, คาซัค, คาตาลัน, คินยารวันดา, คีร์กิซ, คุชราต, จอร์เจีย, จีน, จีนดั้งเดิม, ชวา, ชิเชวา, ซามัว, ซีบัวโน, ซุนดา, ซูลู, ญี่ปุ่น, ดัตช์, ตรวจหาภาษา, ตุรกี, ทมิฬ, ทาจิก, ทาทาร์, นอร์เวย์, บอสเนีย, บัลแกเรีย, บาสก์, ปัญจาป, ฝรั่งเศส, พาชตู, ฟริเชียน, ฟินแลนด์, ฟิลิปปินส์, ภาษาอินโดนีเซี, มองโกเลีย, มัลทีส, มาซีโดเนีย, มาราฐี, มาลากาซี, มาลายาลัม, มาเลย์, ม้ง, ยิดดิช, ยูเครน, รัสเซีย, ละติน, ลักเซมเบิร์ก, ลัตเวีย, ลาว, ลิทัวเนีย, สวาฮิลี, สวีเดน, สิงหล, สินธี, สเปน, สโลวัก, สโลวีเนีย, อังกฤษ, อัมฮาริก, อาร์เซอร์ไบจัน, อาร์เมเนีย, อาหรับ, อิกโบ, อิตาลี, อุยกูร์, อุสเบกิสถาน, อูรดู, ฮังการี, ฮัวซา, ฮาวาย, ฮินดี, ฮีบรู, เกลิกสกอต, เกาหลี, เขมร, เคิร์ด, เช็ก, เซอร์เบียน, เซโซโท, เดนมาร์ก, เตลูกู, เติร์กเมน, เนปาล, เบงกอล, เบลารุส, เปอร์เซีย, เมารี, เมียนมา (พม่า), เยอรมัน, เวลส์, เวียดนาม, เอสเปอแรนโต, เอสโทเนีย, เฮติครีโอล, แอฟริกา, แอลเบเนีย, โคซา, โครเอเชีย, โชนา, โซมาลี, โปรตุเกส, โปแลนด์, โยรูบา, โรมาเนีย, โอเดีย (โอริยา), ไทย, ไอซ์แลนด์, ไอร์แลนด์, การแปลภาษา.

Copyright ©2025 I Love Translation. All reserved.

E-mail: