import pollUntil from './pollUntil' ; import { toExecuteString } from '../lib/util' ; import { CancellablePromise } from '@theintern/common' ; export default function pollUntilTruthy < T > ( poller , timeout ? , pollInterval ? ) ; export default function pollUntilTruthy < T > ( poller , args ? , timeout ? , pollInterval ? ) ; export default function pollUntilTruthy < T > ( poller , args ? , timeout ? , pollInterval ? ) ; export default function pollUntilTruthy < T , U > ( poller , args ? , timeout ? , pollInterval ? ) ; export default function pollUntilTruthy < T , U , V > ( poller , args ? , timeout ? , pollInterval ? ) ; export default function pollUntilTruthy < T , U , V , W > ( poller , args ? , timeout ? , pollInterval ? ) ; export default function pollUntilTruthy < T , U , V , W , X > ( poller , args ? , timeout ? , pollInterval ? ) ; export default function pollUntilTruthy < T , U , V , W , X , Y > ( poller , args ? , timeout ? , pollInterval ? ) ; export default function pollUntilTruthy < T , U , V , W , X , Y > ( poller , argsOrTimeout ? , timeout ? , pollInterval ? ) { const args = [ ] ; if ( typeof argsOrTimeout === 'number' ) { pollInterval = timeout ; timeout = argsOrTimeout ; } else if ( argsOrTimeout ) { args . push ( ... argsOrTimeout ) ; } args . unshift ( toExecuteString ( poller ) ) ; const _poller = function ( poller ) { const args = Array . prototype . slice . apply ( arguments ) . slice ( 1 ) ; const result = new Function ( poller ) . apply ( null , args ) ; return result ? result : undefined ; } ; return pollUntil ( toExecuteString ( _poller ) , args , timeout , pollInterval ) ; }