let nextHandle = 1; const RESOLVED = (() => Promise.resolve())(); const activeHandles: { [key: number]: any } = {}; /** * Finds the handle in the list of active handles, and removes it. * Returns `true` if found, `false` otherwise. Used both to clear * Immediate scheduled tasks, and to identify if a task should be scheduled. */ function findAndClearHandle(handle: number): boolean { if (handle in activeHandles) { delete activeHandles[handle]; return true; } return false; } /** * Helper functions to schedule and unschedule microtasks. */ export const Immediate = { setImmediate(cb: () => void): number { const handle = nextHandle++; activeHandles[handle] = true; RESOLVED.then(() => findAndClearHandle(handle) && cb()); return handle; }, clearImmediate(handle: number): void { findAndClearHandle(handle); }, }; /** * Used for internal testing purposes only. Do not export from library. */ export const TestTools = { pending() { return Object.keys(activeHandles).length; } };
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
ArgumentOutOfRangeError.ts | File | 857 B | 0644 |
|
EmptyError.ts | File | 643 B | 0644 |
|
Immediate.ts | File | 1.02 KB | 0644 |
|
ObjectUnsubscribedError.ts | File | 787 B | 0644 |
|
TimeoutError.ts | File | 586 B | 0644 |
|
UnsubscriptionError.ts | File | 875 B | 0644 |
|
applyMixins.ts | File | 406 B | 0644 |
|
canReportError.ts | File | 692 B | 0644 |
|
errorObject.ts | File | 133 B | 0644 |
|
hostReportError.ts | File | 237 B | 0644 |
|
identity.ts | File | 53 B | 0644 |
|
isArray.ts | File | 112 B | 0644 |
|
isArrayLike.ts | File | 124 B | 0644 |
|
isDate.ts | File | 104 B | 0644 |
|
isFunction.ts | File | 88 B | 0644 |
|
isInteropObservable.ts | File | 354 B | 0644 |
|
isIterable.ts | File | 246 B | 0644 |
|
isNumeric.ts | File | 427 B | 0644 |
|
isObject.ts | File | 96 B | 0644 |
|
isObservable.ts | File | 380 B | 0644 |
|
isPromise.ts | File | 365 B | 0644 |
|
isScheduler.ts | File | 174 B | 0644 |
|
noop.ts | File | 57 B | 0644 |
|
not.ts | File | 259 B | 0644 |
|
pipe.ts | File | 2.72 KB | 0644 |
|
root.ts | File | 1.09 KB | 0644 |
|
subscribeTo.ts | File | 1.39 KB | 0644 |
|
subscribeToArray.ts | File | 389 B | 0644 |
|
subscribeToIterable.ts | File | 830 B | 0644 |
|
subscribeToObservable.ts | File | 666 B | 0644 |
|
subscribeToPromise.ts | File | 440 B | 0644 |
|
subscribeToResult.ts | File | 1.13 KB | 0644 |
|
toSubscriber.ts | File | 779 B | 0644 |
|
tryCatch.ts | File | 426 B | 0644 |
|