Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
2048-board-renderer
Advanced tools
Package for easily rendering boards from the game 2048. Uses data in the format provided from 2048-engine
to render the board.
See 2048-react for a convenient wrapper for use in React.
The package exposes one method.
createBoard(boardData)
It takes one argument, boardData
, which is a Board
object from 2048-engine
.
The function returns an object with the following properties:
htmlElement
: A HTMLElement
containing the rendered board.update
: A function that takes an updated boardData
Board
object and modifies htmlElement
to match the new state.Any updates to the board should be made using the update
function for animations to be played. New games should create new boards using createBoard
to avoid weird animations.
import { createBoard } from '2048-board-renderer';
import { createGame, Direction } from '2048-engine';
const game = createGame();
const board = createBoard(game.currentState.board);
document.getElementById('game')?.appendChild(board.htmlElement);
const move = (direction: Direction) => {
const gameState = game.move(direction);
board.update(gameState.board);
};
move(Direction.UP);
For a playable example see example
directory
The board HTMLElement is a div
with no styling regarding width. The width of the board is therefore determined by its parent container.
The height of the board is determined based on width and the aspect ratio of the board.
FAQs
2048 board renderer
The npm package 2048-board-renderer receives a total of 4 weekly downloads. As such, 2048-board-renderer popularity was classified as not popular.
We found that 2048-board-renderer demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.