lib/sequelize-slugify.js
function (instance, sourceFields, suffixFields) {
        return (function suffixHelper(instance, sourceFields, suffixFields, suffixCount) {
            if (!suffixFields || !Array.isArray(suffixFields)) {
                return Promise.resolve(null);
            }

            if (suffixCount > suffixFields.length) {
                return Promise.resolve(slugifyFields(instance, slugOptions.source.concat(suffixFields.slice(0))));
            }

            var slug = slugifyFields(instance, slugOptions.source.concat(suffixFields.slice(0, suffixCount)));

            return checkSlug(slug).then(function (isUnique) {
                if (isUnique) {
                    return slug;
                }

                return suffixHelper(instance, sourceFields, suffixFields, suffixCount + 1);
            });
        })(instance, sourceFields, suffixFields, 1);
    }
function (instance, sourceFields, suffixFields) {
        return (function suffixHelper(instance, sourceFields, suffixFields, suffixCount) {
            if (!suffixFields || !Array.isArray(suffixFields)) {
                return Promise.resolve(null);
            }

            if (suffixCount > suffixFields.length) {
                return Promise.resolve(slugifyFields(instance, slugOptions.source.concat(suffixFields.slice(0))));
            }

            var slug = slugifyFields(instance, slugOptions.source.concat(suffixFields.slice(0, suffixCount)));

            return checkSlug(slug).then(function (isUnique) {
                if (isUnique) {
                    return slug;
                }

                return suffixHelper(instance, sourceFields, suffixFields, suffixCount + 1);
            });
        })(instance, sourceFields, suffixFields, 1);
    }
function ( instance , sourceFields , suffixFields ) { return ( function suffixHelper ( instance , sourceFields , suffixFields , suffixCount ) { if ( ! suffixFields || ! Array . isArray ( suffixFields ) ) { return Promise . resolve ( null ) ; } if ( suffixCount > suffixFields . length ) { return Promise . resolve ( slugifyFields ( instance , slugOptions . source . concat ( suffixFields . slice ( 0 ) ) ) ) ; } var slug = slugifyFields ( instance , slugOptions . source . concat ( suffixFields . slice ( 0 , suffixCount ) ) ) ; return checkSlug ( slug ) . then ( function ( isUnique ) { if ( isUnique ) { return slug ; } return suffixHelper ( instance , sourceFields , suffixFields , suffixCount + 1 ) ; } ) ; } ) ( instance , sourceFields , suffixFields , 1 ) ; }
Adds on additional suffixes based on the specified suffix fields.

@param instance The model instance to use.
@param sourceFields An array of source fields to use to generate the base slug.
@param suffixFields An array of suffix fields to use to generate the additional slug suffixes.
@return A promise that resolves to a slug once a unique one is found or all of the suffix fields have been exhausted. Returns null if no suffix fields are provided.
Adds on additional suffixes based on the specified suffix fields .