-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
enhancement: do not split if types is empty list
This is a minor change... if the `types` option is set to an empty string or array, text will not be split.
- Loading branch information
1 parent
aefa002
commit 953c2c9
Showing
6 changed files
with
37 additions
and
10 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
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function isArray(value) { | ||
return Array.isArray(value) | ||
} |
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,15 +1,16 @@ | ||
import isString from './isString' | ||
import isArray from './isArray' | ||
/** | ||
* Takes a comma separated list of `types` and returns an objet | ||
* Takes a list of `types` and returns an object | ||
* | ||
* @param {string | string[]} value a comma separated list of split types | ||
* @return {{lines: boolean, words: boolean, chars: boolean}} | ||
*/ | ||
export default function parseTypes(value) { | ||
const types = isString(value) || Array.isArray(value) ? String(value) : '' | ||
const types = isString(value) || isArray(value) ? String(value) : '' | ||
return { | ||
lines: /line/i.test(types), | ||
words: /word/i.test(types), | ||
chars: /(char)|(character)/i.test(types), | ||
chars: /char/i.test(types), | ||
} | ||
} |
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