const moveQueue = {
queue: [],
index: 0,
create() {
let endMoveCallback;
// создаём висячий промис и присваиваем его разрешение в endMoveCallback
const movePending = new Promise(resolve => endMoveCallback = resolve);
// index чисто для лога
endMoveCallback.index = this.index++;
// добавляем в очередь
this.queue.push(endMoveCallback);
// возвращаем проис ждущий вызова endMoveCallback
return movePending;
},
last() {
// забираем из очереди последнее добавленное
return this.queue.pop();
}
}
async function turn() {
await startMove();
await startShoot();
}
function startMove() {
console.log('startMove', moveQueue.index);
return moveQueue.create();
}
function endMove() {
const activeMoveEnd = moveQueue.last();
if (activeMoveEnd) {
console.log('endMove', activeMoveEnd.index)
activeMoveEnd();
} else {
onsole.error('`endMove` called when there are no active moves')
}
}
function startShoot() {
console.log('startShoot');
}
turn();
setTimeout(() => endMove(), 1000)
SteamKit2 is a .NET library designed to interoperate with Valve's Steam network. It aims to provide a simple, yet extensible, interface to perform various actions on the network.
<template>
<div class="doughnut">
<canvas ref="chart"></canvas>
</div>
</template>
<script setup>
import {onMounted, ref} from "vue";
import {
Chart,
DoughnutController,
ArcElement,
} from 'https://cdn.skypack.dev/chart.js@4.2.1';
Chart.register(
DoughnutController,
ArcElement,
);
const chart = ref(null);
const data = {
datasets: [
{
data: [40, 22, 8, 30],
backgroundColor: [
"#F04B92",
"#54B2FD",
"#FFC24B",
"#49EBCE",
],
display: true,
offset: 2,
spacing: -30,
borderColor: "#fff",
borderWidth: 2,
borderRadius: [
{outerStart: 16, outerEnd: 2, innerStart: 16},
{outerStart: 16, outerEnd: 2, innerStart: 16},
{outerStart: 16, outerEnd: 2, innerStart: 16},
{outerStart: 16, outerEnd: 16, innerStart: 16, innerEnd: 16}
],
cutout: "58%",
}
],
labels: false
};
const config = {
type: 'doughnut',
data,
options: {
rotation: 270,
circumference: 180,
maintainAspectRatio: false,
responsive: true,
animation: {
animateRotate: true
}
},
}
onMounted(() => {
const myChart = new Chart(
chart.value,
config
);
const ctx = myChart.canvas.getContext("2d");
ctx.scale(0.8, 0.8);
});
</script>
0 ? .. : true