UNPKG

substance

Version:

Substance is a JavaScript library for web-based content editing. It provides building blocks for realizing custom text editors and web-based publishing system. It is developed to power our online editing platform [Substance](http://substance.io).

19 lines (17 loc) 352 B
const COUNTERS = new Map() export default function deterministicId (prefix) { prefix = prefix || '' let counter if (!COUNTERS.has(prefix)) { counter = 0 } else { counter = COUNTERS.get(prefix) } counter++ COUNTERS.set(prefix, counter) if (prefix) { return `${prefix}-${counter}` } else { return String(counter) } }