Skip to content

Latest commit

 

History

History
41 lines (33 loc) · 930 Bytes

readme.md

File metadata and controls

41 lines (33 loc) · 930 Bytes

SAT WAITING LIBRARY

npm downloads

Content

waitFor

	const { waitFor } = require('sat-utils')

	waitFor.setDefaultOpts({
  	timeout: 2500, // default waiting time is 2500 ms
  	interval: 250,	// default re-check condition interval time is 250 ms
  	message: 'Failed',	// default error message is "Failed"
  	waiterError: TypeError,	// default error is TypeError
	});

	test()
	async function test() {
  	await waitFor(async () => {
  		const result = await someAsyncLogic()
  		return result;
  	})
	}

	test1()
	async function test1() {
  await waitFor(async () => {
  	const result = await someAsyncLogic()
  	return result;
  }, {
  	analyseResult: (result) => result.status === 200;
  	timeout: 25000,
  	interval: 250,
  	message: (time) => throw new Error(`My custom error throw function with time ${time}`)
  })
	}