const array = [1, 255, 639, 9, 7, 8, 5, 4, 2];
const randomIndex = arr => Math.round(Math.random() * (arr.length-1));
const randomEl = arr => {
let index = randomIndex(arr), prev = arr[index];
return () => {
do {
index = randomIndex(arr);
}
while(prev === arr[index]);
prev = arr[index];
return arr[index];
}
}
const getRandomEl = randomEl(array);
for(let i = 0; i < 10; i++) {
console.log(getRandomEl());
}
- awk -i inplace '/location \/projects\/'"$location"'/,/}/ {if(/proxy_pass/) sub(/:[0-9]+.;/,":'"$port"';")} {print}' "$file"
+ awk -i inplace '/location \/projects\/'"$location"'/,/}/ {if(/proxy_pass/) sub(/:[0-9]+.;/,":'"$port"';")} {print}' $(ls $file)
./replace_location_port.sh -n who-am-i -v v2.50.6 -p 222 -f etc/nginx/locations/\*.locations
catch
здесь тоже нужно учесть, т.к. он возвращает Promise<any>
, соответственно тебе нужно использовать примерно такую конструкцию:const getData = async (url: string): Promise<Res | any> => await fetch(url).then((data: Response): Promise<Res> => data.json()).catch(err => err.message);
modal: boolean = false
showmodal() {
this.modal = !this.modal
}
<button (click)="product.showmodal()" class="btn btn-primary">Детальная информация</button>
app-product
показывай или не показывай модалку в зависимости от modal