Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dot-matrix-grid

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dot-matrix-grid

A small library to help create dot matrix grids

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Grid position

pipeline status

Sometimes you want to make a grid of objects. Not like a CSS grid, more like a dot matrix data visualization. This library is a helper function that can return the position of a given element in an array.

The function takes two arguments:

  • rowLength which is the number of items in each row
  • elementIndex which is the index of the element that you want the position for

It will return an array where the first item represents the column (along the x axis) that item should go in and the second item represents the row (along the y axis) that the item should go in. The first item will be at [1, 1].

const getPosition = require('grid-position')

const data = ['a', 'b', 'c', 'd']
const rowLength = 2
const positions = data.map((d, i) => {
  return getPosition(rowLength, i)
})

// positions equals [[1, 1], [1, 2], [2, 1], [2, 2]]

Keywords

FAQs

Package last updated on 15 Aug 2018

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc