makeup-next-id
Advanced tools
Comparing version 0.3.0 to 0.4.0
{ | ||
"name": "makeup-next-id", | ||
"description": "Assign the next id in sequence to an element, if an id property does not already exist.", | ||
"version": "0.3.0", | ||
"main": "dist/index.js", | ||
"version": "0.4.0", | ||
"main": "./dist/cjs/index.js", | ||
"module": "./dist/mjs/index.js", | ||
"exports": { | ||
".": { | ||
"import": "./dist/mjs/index.js", | ||
"require": "./dist/cjs/index.js" | ||
} | ||
}, | ||
"repository": "https://github.com/makeup/makeup-js/tree/master/packages/makeup-next-id", | ||
@@ -10,3 +17,5 @@ "author": "Ian McBurnie <ianmcburnie@hotmail.com>", | ||
"scripts": { | ||
"compile": "babel src --out-dir dist", | ||
"compile": "npm run compile:mjs && npm run compile:cjs", | ||
"compile:mjs": "esbuild src/index.js --outfile=dist/mjs/index.js --format=esm", | ||
"compile:cjs": "babel --plugins @babel/plugin-transform-modules-commonjs src/index.js --out-file dist/cjs/index.js", | ||
"clean": "rimraf *.log .DS_Store" | ||
@@ -22,3 +31,4 @@ }, | ||
"browser.json", | ||
"dist/index.js", | ||
"dist/cjs/index.js", | ||
"dist/mjs/index.js", | ||
"package-lock.json" | ||
@@ -25,0 +35,0 @@ ], |
# 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 <em>known</em> id, ahead of time, please use a different approach! | ||
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 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. | ||
This module is still in an experimental state, until it reaches v1 you must consider all minor releases as breaking changes. | ||
## Install | ||
```js | ||
// via npm | ||
npm install makeup-next-id | ||
// via yarn | ||
yarn add makeup-next-id | ||
``` | ||
## Example | ||
```js | ||
// require the module | ||
const nextId = require('makeup-next-id'); | ||
// import the module | ||
import nextId from 'makeup-next-id'; | ||
// get NodeList | ||
const widgets = document.querySelectorAll('.widget'); | ||
const widgetEls = document.querySelectorAll('.widget'); | ||
// assign next id to each element | ||
widgets.forEach(function(el) { | ||
nextId(el); | ||
}); | ||
widgetEls.forEach((el) => nextId(el)); | ||
``` | ||
@@ -56,3 +46,3 @@ | ||
* None | ||
* [nanoid](https://www.npmjs.com/package/nanoid) | ||
@@ -59,0 +49,0 @@ ## Polyfills |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5313
6
64
51