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.2.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. If you need a known id, ahead of time, please use a different approach!

Experimental

This CommonJS module is still in an experimental state, until it reaches v1.0.0 you must consider all minor releases as breaking changes. Patch releases may introduce new features, but will be backwards compatible.

Install

// via npm
npm install makeup-next-id

// via yarn
yarn add makeup-next-id

Example

// require the module
const nextId = require('makeup-next-id');

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

// assign next id to each element
widgets.forEach(function(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 10 Jul 2021

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