You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
const{waitForCondition}=require('sat-utils')waitForCondition.setDefaultOpts({timeout: 2500,// default waiting time is 2500 msinterval: 250,// default re-check condition interval time is 250 msmessage: 'Failed',// default error message is "Failed"waiterError: TypeError,// default error is TypeError});test()asyncfunctiontest(){awaitwaitForCondition(async()=>{constresult=awaitsomeAsyncLogic()returnresult;})}test1()asyncfunctiontest1(){awaitwaitForCondition(async()=>{constresult=awaitsomeAsyncLogic()returnresult;},{analyseResult: (result)=>result.status===200;
timeout: 25000,interval: 250,message: (time)=>thrownewError(`My custom error throw function with time ${time}`)})}
getRandomArrayItem
const{ getRandomArrayItem }=require('sat-utils');constfirstItem=getRandomArrayItem([1,2,3,4]);// 2const[first,second]=getRandomArrayItem([1,2,3,4],2);// [3, 1]getRandomArrayItem([1,2,3,4],10);// => RangeError('getRandomArrayItem(): more elements taken ...getRandomArrayItem([]);// => RangeError('getRandomArrayItem(): given array is empty')getRandomArrayItem(null);// => TypeError 'getRandomArrayItem(): first argument should be an')
const{ shuffleArr }=require('sat-utils');constarr1=shuffleArr([2,3,1]);// [1,3,2]shuffleArr({});// TypeError 'shuffleArr(): first argument should be an array ...'
shuffleArrMutable
const{ shuffleArrMutable }=require('sat-utils');constarr=[1,2,3,4,5];shuffleArrMutable(arr);console.log(arr);// [ 5, 2, 4, 1, 3 ]shuffleArrMutable({});// TypeError 'shuffleArr(): first argument should be an array ...'
const{ execNumberExpression }=require('sat-utils');constisTruly=execNumberExpression('>10',11);// trueconstisTruly1=execNumberExpression('>10 and <12',11);// trueconstisTruly2=execNumberExpression('>10 and <13 and !== 12',11);// trueconstisTruly3=execNumberExpression('<9',11);// falseconstisTruly4=execNumberExpression('!==11',11);// false
getDirFilesList
const{ getDirFilesList }=require('sat-utils');constfiles=getDirFilesList('./node_modules');// all absolute file pathes in node_module folder