diff --git a/index.js b/index.js index dc8c3f1..0f2a118 100644 --- a/index.js +++ b/index.js @@ -9,11 +9,19 @@ export default class BananaSlug { /** * Create a new slug class. */ - constructor () { + constructor (previousOccurrences) { /** @type {Record} */ // eslint-disable-next-line no-unused-expressions - this.occurrences - + if(previousOccurrences){ + this.occurrences = previousOccurrences.reduce((obj, slug) => { + const strippedSlug = slug.replace(/-\d+$/, ''); + obj[strippedSlug] = (obj[strippedSlug] || 0) + 1; + return obj; + }, {}); + } + else { + this.occurrences + } this.reset() }