File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -156,20 +156,21 @@ export const translationsConfigFile = _translationsConfigFile;
156156const _globals = ( typeof self === 'object' ? self : typeof global === 'object' ? global : { } as any ) ;
157157export const globals : any = _globals ;
158158
159- let _setImmediate : ( ( callback : ( ...args : any [ ] ) => void ) => number ) | null = null ;
160- export function setImmediate ( callback : ( ...args : any [ ] ) => void ) : number {
161- if ( _setImmediate === null ) {
162- if ( globals . setImmediate ) {
163- _setImmediate = globals . setImmediate . bind ( globals ) ;
164- } else if ( typeof process !== 'undefined' && typeof process . nextTick === 'function' ) {
165- _setImmediate = process . nextTick . bind ( process ) ;
166- } else {
167- _setImmediate = globals . setTimeout . bind ( globals ) ;
168- }
169- }
170- return _setImmediate ! ( callback ) ;
159+ interface ISetImmediate {
160+ ( callback : ( ...args : any [ ] ) => void ) : void ;
171161}
172162
163+ export const setImmediate : ISetImmediate = ( function defineSetImmediate ( ) {
164+ if ( globals . setImmediate ) {
165+ return globals . setImmediate . bind ( globals ) ;
166+ }
167+ if ( typeof process !== 'undefined' && typeof process . nextTick === 'function' ) {
168+ return process . nextTick . bind ( process ) ;
169+ }
170+ const _promise = Promise . resolve ( ) ;
171+ return ( callback : ( ...args : any [ ] ) => void ) => _promise . then ( callback ) ;
172+ } ) ( ) ;
173+
173174export const enum OperatingSystem {
174175 Windows = 1 ,
175176 Macintosh = 2 ,
Original file line number Diff line number Diff line change @@ -10,15 +10,15 @@ interface IProcess {
1010 env : IProcessEnvironment ;
1111
1212 cwd ( ) : string ;
13- nextTick ( callback : ( ...args : any [ ] ) => void ) : number ;
13+ nextTick ( callback : ( ...args : any [ ] ) => void ) : void ;
1414}
1515
1616declare const process : IProcess ;
1717const safeProcess : IProcess = ( typeof process === 'undefined' ) ? {
1818 cwd ( ) : string { return '/' ; } ,
1919 env : Object . create ( null ) ,
2020 get platform ( ) : string { return isWindows ? 'win32' : isMacintosh ? 'darwin' : 'linux' ; } ,
21- nextTick ( callback : ( ...args : any [ ] ) => void ) : number { return setImmediate ( callback ) ; }
21+ nextTick ( callback : ( ...args : any [ ] ) => void ) : void { return setImmediate ( callback ) ; }
2222} : process ;
2323
2424export const cwd = safeProcess . cwd ;
You can’t perform that action at this time.
0 commit comments