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

makeup-next-id

Package Overview
Dependencies
Maintainers
5
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

makeup-next-id

Assign the next id in sequence to an element, if an id property does not already exist.

  • 0.4.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
120
decreased by-70.52%
Maintainers
5
Weekly downloads
 
Created
Source

makeup-next-id

Assigns the next id in sequence to an element, if an id property does not already exist.

The id will consist of a configurable prefix (default: 'nid'), followed by three randomly generated chars, then a number in sequence. For example: nid-sdv-1, nid-sdv-2, nid-sdv-3, etc.

Experimental

This module is still in an experimental state, until it reaches v1 you must consider all minor releases as breaking changes.

Example

// import the module
import nextId from 'makeup-next-id';

// get NodeList
const widgetEls = document.querySelectorAll('.widget');

// assign next id to each element
widgetEls.forEach((el) => nextId(el));

Markup before:

<div class="widget"></div>
<div class="widget"></div>
<div class="widget"></div>

Markup after:

<div class="widget" id="nid-tCa-1"></div>
<div class="widget" id="nid-tCa-2"></div>
<div class="widget" id="nid-tCa-3"></div>

Custom Events

  • None

Dependencies

  • nanoid

Polyfills

  • None

Keywords

FAQs

Package last updated on 02 Feb 2022

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