Pot.js と PotLite.js で利用可能。
引数 cond の戻り値が 真 (true) になるまで待機します。
引数 cond が 真 (true) を返すまでスレッドを待機させます。
処理は、同期で行われるため sleep のように待機することができます。
スレッドの詳細は、nsIThread - MDN を参照ください。
Pot.globalize() が適応されている場合、Pot.throughout() が throughout() で実行できます。
返り値はありません。
// XPCOM が有効な環境での例 function sleep(seconds) { var time = Pot.now(), msec = seconds * 1000; Pot.throughout(function() { return Pot.now() - time >= msec; }); } var x = 1; Pot.debug(x); // 1 // 5 秒 待機する sleep(5); // 5 秒後に以下のコードが実行される x += 1; Pot.debug(x); // 2