UNPKG

locutus

Version:

Locutus other languages' standard libraries to JavaScript for fun and educational purposes

15 lines (14 loc) 588 B
import { getPhpRuntimeBoolean, setPhpRuntimeEntry } from "../_helpers/_phpRuntimeState.js"; export function set_time_limit(seconds) { // discuss at: https://locutus.io/php/set_time_limit/ // original by: Brett Zamir (https://brett-zamir.me) // test: skip-all // example 1: set_time_limit(4) // returns 1: undefined setTimeout(function () { if (!getPhpRuntimeBoolean('timeoutStatus', false)) { setPhpRuntimeEntry('timeoutStatus', true); } throw new Error('Maximum execution time exceeded'); }, seconds * 1000); }