-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from yusufshakeel/dev
v0.8.1
- Loading branch information
Showing
11 changed files
with
72 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
const {DEFAULT_OMIT_CHARACTERS} = require('./constants.js'); | ||
const characterSet = require('./character-set.js'); | ||
|
||
/** | ||
* This will generate a string of unique characters based on the options provided. | ||
* @param {object} characterSetOptions The options to build the character set. | ||
* @param {string[]} omitCharacters The array of characters that will be omitted. | ||
* @returns {string} The set of characters based on the options provided. | ||
*/ | ||
function characterSetBuilder(characterSetOptions) { | ||
function characterSetBuilder(characterSetOptions, omitCharacters = DEFAULT_OMIT_CHARACTERS) { | ||
const {builtIn = [], custom = []} = characterSetOptions; | ||
return [...new Set([...builtIn.map(charSetName => characterSet(charSetName)), ...custom].join(''))].join(''); | ||
const charactersToOmit = [...new Set(omitCharacters.join(''))]; | ||
const charactersFromCharacterSetOptions = [...new Set([...builtIn.map(characterSetName => characterSet(characterSetName)), ...custom].join(''))]; | ||
const charactersToUse = charactersFromCharacterSetOptions.filter(character => !charactersToOmit.includes(character)); | ||
return charactersToUse.join(''); | ||
} | ||
|
||
module.exports = characterSetBuilder; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters