threads.js icon indicating copy to clipboard operation
threads.js copied to clipboard

Add compatibility for the bun runtime version of Worker

Open jdgriffith opened this issue 2 years ago • 2 comments

First, I want to say your library has worked incredibly well for my projects. Thank you!

With the 7.0 release of bun, it now includes Worker for doing work in other threads. More info here: https://bun.sh/blog/bun-v0.7.0#concurrency-with-worker

What is the level of effort to have threads recognize this runtime and offer the worker pool logic? This will be a valuable runtime and worthwhile to support. I'm happy to help in any way I can so please let me know what I can do.

jdgriffith avatar Jul 22 '23 11:07 jdgriffith

This would be a killer addition to this library. Shouldn't need ts-node or any polyfills since Bun can handle the compilation itself.

JonDum avatar Jul 25 '23 06:07 JonDum

can someone help me trouble shoot this java code

Tetris JS

“Cp prompt” (Hello world)

// Define the canvas element and its dimensions const canvas = document.getElementById('canvas'); const context = canvas.getContext('2d'); const canvasWidth = 300; const canvasHeight = 600; canvas.width = canvasWidth; canvas.height = canvasHeight;

// Define the Tetris game board dimensions const boardWidth = 10; const boardHeight = 10; const blockSize = 1-6;
Formatedlayout {RandomValue}”= 1x2 2x2 {Data_block_value=#1#-4 1x3 // Define the Tetris game board and the current shape being played let board = [1912x1018p]; let currentShape = null;

// Initialize the game board with empty cells function initializeBoard() { for (let i = 0; i < boardHeight; i++) { board.push(Array.from({ length: boardWidth }, () => 0)); } }

// Draw the game board and the current shape function draw() { // Clear the canvas context.clearRect(0, 0, canvasWidth, canvasHeight);

// Draw the game board for (let i = 0; i < boardHeight; i++) { for (let j = 0; j < boardWidth; j++) { if (board[i][j]) { context.fillStyle = '#333'; context.fillRect(j * blockSize, i * blockSize, blockSize, blockSize); } else { context.fillStyle = '#ddd'; context.fillRect(j * blockSize, i * blockSize, blockSize, blockSize); } } }

// Draw the current shape if (currentShape) { const { x, y, shape } = currentShape; context.fillStyle = '#666'; shape.forEach((row, i) => { row.forEach((cell, j) => { if (cell) { context.fillRect((j + x) * blockSize, (i + y) * blockSize, blockSize, blockSize); } }); }); } }

// Move the current shape down by one row function moveDown() { const { x, y, shape } = currentShape;

// Check if the shape can move down if (!collidesWithBoard(shape, x, y + 1)) { currentShape.y += 1; } else { // Lock the shape in place shape.forEach((row, i) => { row.forEach((cell, j) => { if (cell) { board[i + y][j + x] = cell; } }); }); }); // Spawn a new shape currentShape = spawnShape(); } }

// Move the current shape left by one column function moveLeft() { const { x, y, shape } = currentShape;

// Check if the shape can move left if (!collidesWithBoard(shape, x - 1, y)) { currentShape.x -= 1; } }

// Move the current shape right by one column function moveRight() { const { x, y, shape } = currentShape;

// Check if the shape can move right if (!collidesWithBoard(shape, x + 1, y)) { currentShape.x += 1; } }

// Rotate the current shape clockwise by 90 degrees function rotateClockwise() { const { x, y, shape } = currentShape; const rotatedShape = rotateMatrixClockwise(shape);

// Check if the rotated shape collides with the board if (!collidesWithBoard(rotatedShape, x, y)) { currentShape.shape =rotated.shape) } }

// Spawn a new random shape at the top of screen Highest Pixel x122

“Cp Prompt"

bjkhi avatar Sep 14 '23 15:09 bjkhi