char/avril
(wip) why'd you have to go and make things so complicaaaaated?
git clone https://git.t4t.associates/char/avril
711e4d5
main
1import { 2ArrayPrototypePush , 3Error , 4ObjectSetPrototypeOf , 5TypeError , 6} from "ext:core/primordials" ; 7 8// Keep live initializers in the JS heap, but do not run them when building a snapshot. 9let initializers = ObjectSetPrototypeOf ([], null ); 10 11export function onRuntimeStart ( callback ) { 12if ( initializers === undefined ) throw new Error ( "Runtime already started" ); 13if ( typeof callback !== "function" ) { 14throw new TypeError ( "Expected a runtime initializer" ); 15} 16ArrayPrototypePush ( initializers , callback ); 17} 18 19export function startRuntime () { 20if ( initializers === undefined ) throw new Error ( "Runtime already started" ); 21const pending = initializers ; 22initializers = undefined ; 23for ( let i = 0 ; i < pending . length ; i ++ ) { 24const initialize = pending [ i ]; 25if ( initialize () !== undefined ) { 26throw new TypeError ( "Runtime initializers must return undefined" ); 27} 28} 29}