Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
detect-grid
Advanced tools
Detect and mark grid cells for easy styling.
This package detects the rows and columns of a layout visually by comparing the offset from the top-left edge of the parent container. Each element is assigned a row and column index.
It will mark each detected cell with data attributes for easy targeting in CSS. This makes styling cells by index feasible even in flexbox or grid layouts where visual position doesn't always follow source order.
npm install detect-grid
Returns an array of rows and columns for further processing. Indices are zero-based.
import detectGrid from 'detect-grid'
const grid = document.querySelector('.grid')
const rows = detectGrid(grid)
rows.forEach((cols, rowIndex) => {
cols.forEach((cell, colIndex) => {
console.log(`Cell at row ${rowIndex} and col ${colIndex}`, cell.textContent)
})
})
Detects rows and columns and mark them with data attributes for CSS styling.
import { markGrid } from 'detect-grid'
const grid = document.querySelector('.grid')
markGrid(grid, { selector: '.cell' })
Before
<div class="grid">
<div>
<div class="cell"></div>
<div class="cell"></div>
</div>
<div>
<div class="cell"></div>
<div class="cell"></div>
</div>
</div>
After
:warning: While the
detectGrid
function returns zero-based arrays, the data attributes added bymarkGrid
start counting from1
to keep compatibility with CSS nth-child selectors.
<div class="grid">
<div>
<div class="cell" data-nth-row="1" data-nth-col="1" data-first-row data-first-col></div>
<div class="cell" data-nth-row="1" data-nth-col="2" data-first-row data-last-col></div>
</div>
<div>
<div class="cell" data-nth-row="2" data-nth-col="1" data-first-col></div>
<div class="cell" data-nth-row="2" data-nth-col="2" data-last-col></div>
</div>
<div>
<div class="cell" data-nth-row="2" data-nth-col="1" data-last-row data-first-col></div>
<div class="cell" data-nth-row="2" data-nth-col="2" data-last-row data-last-col></div>
</div>
</div>
FAQs
Detect and mark grid cells for easy styling
The npm package detect-grid receives a total of 13 weekly downloads. As such, detect-grid popularity was classified as not popular.
We found that detect-grid demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.