Skip to content

Commit 1e3e1c3

Browse files
committed
Bump version 1.2.0
1 parent 50c145c commit 1e3e1c3

File tree

7 files changed

+180
-60
lines changed

7 files changed

+180
-60
lines changed

README.md

+15-13
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ Then a global variable `v` is exposed for the entire library:
8989
| [v.padLeft][padLeft] | [v.isAlphaDigit][isAlphaDigit] | [v.graphemeAt][graphemeAt] | [v.kebabCase][kebabCase] | **Escape** |
9090
| [v.padRight][padRight] | [v.isBlank][isBlank] | [v.last][last] | [v.lowerCase][lowerCase] | [v.escapeHtml][escapeHtml] |
9191
| [v.repeat][repeat] | [v.isDigit][isDigit] | [v.prune][prune] | [v.snakeCase][snakeCase] | [v.escapeRegExp][escapeRegExp] |
92-
| [v.replace][replace] | [v.isEmpty][isEmpty] | [v.slice][slice] | [v.upperCase][upperCase] | [v.unescapeHtml][unescapeHtml] |
93-
| [v.replaceAll][replaceAll] | [v.isLowerCase][isLowerCase] | [v.substr][substr] | **Split** | |
94-
| [v.reverse][reverse] | [v.isNumeric][isNumeric] | [v.substring][substring] | [v.chars][chars] | |
95-
| [v.reverseGrapheme][reverseGrapheme] | [v.isString][isString] | [v.truncate][truncate] | [v.codePoints][codePoints] | |
96-
| [v.slugify][slugify] | [v.isUpperCase][isUpperCase] | **Count** | [v.graphemes][graphemes] | |
97-
| [v.splice][splice] | [v.matches][matches] | [v.count][count] | [v.split][split] | |
98-
| [v.trim][trim] | [v.startsWith][startsWith] | [v.countGraphemes][countGraphemes] | [v.words][words] | |
99-
| [v.trimLeft][trimLeft] | **Format** | [v.countSubstrings][countSubstrings] | **Strip** | |
100-
| [v.trimRight][trimRight] | [v.sprintf][sprintf] | [v.countWhere][countWhere] | [v.stripTags][stripTags] | |
92+
| [v.replace][replace] | [v.isEmpty][isEmpty] | [v.slice][slice] | [v.titleCase][titleCase] | [v.unescapeHtml][unescapeHtml] |
93+
| [v.replaceAll][replaceAll] | [v.isLowerCase][isLowerCase] | [v.substr][substr] | [v.upperCase][upperCase] | **Strip** |
94+
| [v.reverse][reverse] | [v.isNumeric][isNumeric] | [v.substring][substring] | **Split** | [v.stripBom][stripBom] |
95+
| [v.reverseGrapheme][reverseGrapheme] | [v.isString][isString] | [v.truncate][truncate] | [v.chars][chars] | [v.stripTags][stripTags] |
96+
| [v.slugify][slugify] | [v.isUpperCase][isUpperCase] | **Count** | [v.codePoints][codePoints] | |
97+
| [v.splice][splice] | [v.matches][matches] | [v.count][count] | [v.graphemes][graphemes] | |
98+
| [v.trim][trim] | [v.startsWith][startsWith] | [v.countGraphemes][countGraphemes] | [v.split][split] | |
99+
| [v.trimLeft][trimLeft] | **Format** | [v.countSubstrings][countSubstrings] | [v.words][words] | |
100+
| [v.trimRight][trimRight] | [v.sprintf][sprintf] | [v.countWhere][countWhere] | | |
101101
| [v.wordWrap][wordWrap] | [v.vprintf][vprintf] | [v.countWords][countWords] | | |
102102

103103
## Bug reports
@@ -132,9 +132,9 @@ Licensed under [MIT](https://github.com/panzerdp/voca/blob/master/LICENSE.md)
132132

133133
[CODE_OF_CONDUCT]: https://github.com/panzerdp/voca/blob/master/CODE_OF_CONDUCT.md
134134
[CONTRIBUTING]: https://github.com/panzerdp/voca/blob/master/.github/CONTRIBUTING.md
135-
[voca_min_js]: https://raw.githubusercontent.com/panzerdp/voca/1.1.0/dist/voca.min.js
136-
[source_map]: https://raw.githubusercontent.com/panzerdp/voca/1.1.0/dist/voca.min.js.map
137-
[voca_js]: https://raw.githubusercontent.com/panzerdp/voca/1.1.0/dist/voca.js
135+
[voca_min_js]: https://raw.githubusercontent.com/panzerdp/voca/1.2.0/dist/voca.min.js
136+
[source_map]: https://raw.githubusercontent.com/panzerdp/voca/1.2.0/dist/voca.min.js.map
137+
[voca_js]: https://raw.githubusercontent.com/panzerdp/voca/1.2.0/dist/voca.js
138138
[voca]: https://vocajs.com
139139
[logo]: https://github.com/panzerdp/voca/raw/master/jsdoc/template/static/images/voca-logo@300px.png
140140
[logo_commonjs]: https://github.com/panzerdp/voca/raw/master/jsdoc/template/static/images/commonjs@200px.png
@@ -146,6 +146,7 @@ Licensed under [MIT](https://github.com/panzerdp/voca/blob/master/LICENSE.md)
146146
[kebabCase]: https://vocajs.com/#kebabCase
147147
[lowerCase]: https://vocajs.com/#lowerCase
148148
[snakeCase]: https://vocajs.com/#snakeCase
149+
[titleCase]: https://vocajs.com/#titleCase
149150
[upperCase]: https://vocajs.com/#upperCase
150151

151152
[charAt]: https://vocajs.com/#charAt
@@ -213,4 +214,5 @@ Licensed under [MIT](https://github.com/panzerdp/voca/blob/master/LICENSE.md)
213214
[split]: https://vocajs.com/#split
214215
[words]: https://vocajs.com/#words
215216

216-
[stripTags]: https://vocajs.com/#stripTags
217+
[stripTags]: https://vocajs.com/#stripTags
218+
[stripBom]: https://vocajs.com/#stripBom

dist/voca.js

+88-33
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*!
2-
* Voca string library 1.1.0
2+
* Voca string library 1.2.0
33
* https://vocajs.com
44
*
55
* Copyright Dmitri Pavlutin and other contributors
@@ -518,7 +518,7 @@ function camelCase(subject) {
518518
function decapitalize(subject) {
519519
var subjectString = coerceToString(subject);
520520
if (subjectString === '') {
521-
return subjectString;
521+
return '';
522522
}
523523
return subjectString.substr(0, 1).toLowerCase() + subjectString.substr(1);
524524
}
@@ -596,6 +596,33 @@ function upperCase(subject) {
596596
return subjectString.toUpperCase();
597597
}
598598

599+
/**
600+
* Converts the subject to title case.
601+
*
602+
* @function titleCase
603+
* @static
604+
* @since 1.2.0
605+
* @memberOf Case
606+
* @param {string} [subject=''] The string to convert to title case.
607+
* @param {Array} [ignoreWords] The words that should not be capitalized.
608+
* @return {string} Returns the title case string.
609+
* @example
610+
* v.titleCase('learning to fly');
611+
* // => 'Learning To Fly'
612+
*
613+
* v.titleCase('another brick in the wall', ['in', 'the']);
614+
* // => 'Another Brick in the Wall'
615+
*/
616+
function titleCase(subject, ignoreWords) {
617+
var subjectString = coerceToString(subject);
618+
var ignoreWordsArray = Array.isArray(ignoreWords) ? ignoreWords : [];
619+
var wordsRegExp = REGEXP_EXTENDED_ASCII.test(subjectString) ? REGEXP_LATIN_WORD : REGEXP_WORD;
620+
return subjectString.replace(wordsRegExp, function (word) {
621+
var lowerCaseWord = word.toLowerCase();
622+
return ignoreWordsArray.indexOf(lowerCaseWord) !== -1 ? lowerCaseWord : capitalize(lowerCaseWord, true);
623+
});
624+
}
625+
599626
/**
600627
* Clip the number to interval `downLimit` to `upLimit`.
601628
*
@@ -2295,7 +2322,7 @@ function removeCombiningMarks(character, cleanCharacter) {
22952322
function latinise(subject) {
22962323
var subjectString = coerceToString(subject);
22972324
if (subjectString === '') {
2298-
return subjectString;
2325+
return '';
22992326
}
23002327
return subjectString.replace(REGEXP_NON_LATIN, getLatinCharacter).replace(REGEXP_COMBINING_MARKS, removeCombiningMarks);
23012328
}
@@ -2574,6 +2601,8 @@ function splice(subject, start, deleteCount, toAdd) {
25742601
return subjectString.slice(0, startPosition) + toAddString + subjectString.slice(startPosition + deleteCountNumber);
25752602
}
25762603

2604+
var reduce$1 = Array.prototype.reduce;
2605+
25772606
/**
25782607
* Removes whitespaces from the left side of the `subject`.
25792608
*
@@ -2582,7 +2611,7 @@ function splice(subject, start, deleteCount, toAdd) {
25822611
* @since 1.0.0
25832612
* @memberOf Manipulate
25842613
* @param {string} [subject=''] The string to trim.
2585-
* @param {string} [whitespace=whitespace] The whitespace characters to trim.
2614+
* @param {string} [whitespace=whitespace] The whitespace characters to trim. List all characters that you want to be stripped.
25862615
* @return {string} Returns the trimmed string.
25872616
* @example
25882617
* v.trimLeft(' Starship Troopers');
@@ -2600,19 +2629,18 @@ function trimLeft(subject, whitespace$$1) {
26002629
if (isNil(whitespaceString)) {
26012630
return subjectString.replace(REGEXP_TRIM_LEFT, '');
26022631
}
2603-
var whitespaceLength = whitespaceString.length;
26042632
var matchWhitespace = true;
2605-
var totalWhitespaceLength = 0;
2606-
while (matchWhitespace) {
2607-
if (subjectString.indexOf(whitespaceString, totalWhitespaceLength) === totalWhitespaceLength) {
2608-
totalWhitespaceLength += whitespaceLength;
2609-
} else {
2610-
matchWhitespace = false;
2633+
return reduce$1.call(subjectString, function (trimmed, character) {
2634+
if (matchWhitespace && includes(whitespaceString, character)) {
2635+
return trimmed;
26112636
}
2612-
}
2613-
return subjectString.substring(totalWhitespaceLength);
2637+
matchWhitespace = false;
2638+
return trimmed + character;
2639+
}, '');
26142640
}
26152641

2642+
var reduceRight = Array.prototype.reduceRight;
2643+
26162644
/**
26172645
* Removes whitespaces from the right side of the `subject`.
26182646
*
@@ -2621,7 +2649,7 @@ function trimLeft(subject, whitespace$$1) {
26212649
* @since 1.0.0
26222650
* @memberOf Manipulate
26232651
* @param {string} [subject=''] The string to trim.
2624-
* @param {string} [whitespace=whitespace] The whitespace characters to trim.
2652+
* @param {string} [whitespace=whitespace] The whitespace characters to trim. List all characters that you want to be stripped.
26252653
* @return {string} Returns the trimmed string.
26262654
* @example
26272655
* v.trimRight('the fire rises ');
@@ -2639,20 +2667,14 @@ function trimRight(subject, whitespace$$1) {
26392667
if (isNil(whitespaceString)) {
26402668
return subjectString.replace(REGEXP_TRIM_RIGHT, '');
26412669
}
2642-
var whitespaceLength = whitespaceString.length;
2643-
var subjectLength = subjectString.length;
26442670
var matchWhitespace = true;
2645-
var totalWhitespaceLength = 0;
2646-
var position = void 0;
2647-
while (matchWhitespace) {
2648-
position = subjectLength - totalWhitespaceLength - whitespaceLength;
2649-
if (subjectString.indexOf(whitespaceString, position) === position) {
2650-
totalWhitespaceLength += whitespaceLength;
2651-
} else {
2652-
matchWhitespace = false;
2671+
return reduceRight.call(subjectString, function (trimmed, character) {
2672+
if (matchWhitespace && includes(whitespaceString, character)) {
2673+
return trimmed;
26532674
}
2654-
}
2655-
return subjectString.substring(0, subjectLength - totalWhitespaceLength);
2675+
matchWhitespace = false;
2676+
return character + trimmed;
2677+
}, '');
26562678
}
26572679

26582680
/**
@@ -2663,7 +2685,7 @@ function trimRight(subject, whitespace$$1) {
26632685
* @since 1.0.0
26642686
* @memberOf Manipulate
26652687
* @param {string} [subject=''] The string to trim.
2666-
* @param {string} [whitespace=whitespace] The whitespace characters to trim.
2688+
* @param {string} [whitespace=whitespace] The whitespace characters to trim. List all characters that you want to be stripped.
26672689
* @return {string} Returns the trimmed string.
26682690
* @example
26692691
* v.trim(' Mother nature ');
@@ -3185,6 +3207,37 @@ function split(subject, separator, limit) {
31853207
return subjectString.split(separator, limit);
31863208
}
31873209

3210+
var BYRE_ORDER_MARK = '\uFEFF';
3211+
3212+
/**
3213+
* Strips the byte order mark (BOM) from the beginning of `subject`.
3214+
*
3215+
* @function stripBom
3216+
* @static
3217+
* @since 1.2.0
3218+
* @memberOf Strip
3219+
* @param {string} [subject=''] The string to strip from.
3220+
* @return {string} Returns the stripped string.
3221+
* @example
3222+
*
3223+
* v.stripBom('\uFEFFsummertime sadness');
3224+
* // => 'summertime sadness'
3225+
*
3226+
* v.stripBom('summertime happiness');
3227+
* // => 'summertime happiness'
3228+
*
3229+
*/
3230+
function trim$1(subject) {
3231+
var subjectString = coerceToString(subject);
3232+
if (subjectString === '') {
3233+
return '';
3234+
}
3235+
if (subjectString[0] === BYRE_ORDER_MARK) {
3236+
return subjectString.substring(1);
3237+
}
3238+
return subjectString;
3239+
}
3240+
31883241
/**
31893242
* Checks whether `subject` contains substring at specific `index`.
31903243
*
@@ -3227,10 +3280,11 @@ var STATE_NON_WHITESPACE = 1;
32273280
var STATE_DONE = 2;
32283281

32293282
/**
3230-
* Parses the tag name from html content
3283+
* Parses the tag name from html content.
32313284
*
3232-
* @param {string} tagContent The tag content
3233-
* @return {string} Returns the tag name
3285+
* @ignore
3286+
* @param {string} tagContent The tag content.
3287+
* @return {string} Returns the tag name.
32343288
*/
32353289
function parseTagName(tagContent) {
32363290
var state = STATE_START_TAG;
@@ -3290,7 +3344,7 @@ var STATE_COMMENT = 3;
32903344
* v.stripTags('Sun<br/>set', '', '-');
32913345
* // => 'Sun-set'
32923346
*/
3293-
function trim$1(subject, allowableTags, replacement) {
3347+
function trim$2(subject, allowableTags, replacement) {
32943348
subject = coerceToString(subject);
32953349
if (subject === '') {
32963350
return '';
@@ -3413,7 +3467,6 @@ function trim$1(subject, allowableTags, replacement) {
34133467
}
34143468
}
34153469
}
3416-
34173470
return output;
34183471
}
34193472

@@ -3532,6 +3585,7 @@ var functions = {
35323585
kebabCase: kebabCase,
35333586
lowerCase: lowerCase,
35343587
snakeCase: snakeCase,
3588+
titleCase: titleCase,
35353589
upperCase: upperCase,
35363590

35373591
count: count,
@@ -3599,7 +3653,8 @@ var functions = {
35993653
split: split,
36003654
words: words,
36013655

3602-
stripTags: trim$1,
3656+
stripBom: trim$1,
3657+
stripTags: trim$2,
36033658

36043659
noConflict: noConflict,
36053660
version: version

dist/voca.min.js

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/voca.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

jsdoc/template/tmpl/introduction.tmpl

+3-3
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,11 @@ slugify('caffé latté'); // => 'caffe-latte'</code></pre>
117117

118118
<ul>
119119
<li>
120-
<a href="https://raw.githubusercontent.com/panzerdp/voca/1.1.0/dist/voca.min.js">voca.min.js</a>
121-
minified production-ready, with <a href="https://raw.githubusercontent.com/panzerdp/voca/1.1.0/dist/voca.min.js.map">source map</a>
120+
<a href="https://raw.githubusercontent.com/panzerdp/voca/1.2.0/dist/voca.min.js">voca.min.js</a>
121+
minified production-ready, with <a href="https://raw.githubusercontent.com/panzerdp/voca/1.2.0/dist/voca.min.js.map">source map</a>
122122
</li>
123123
<li>
124-
<a href="https://raw.githubusercontent.com/panzerdp/voca/1.1.0/dist/voca.js">voca.js</a> uncompressed
124+
<a href="https://raw.githubusercontent.com/panzerdp/voca/1.2.0/dist/voca.js">voca.js</a> uncompressed
125125
with comments
126126
</li>
127127
</ul>

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "voca",
3-
"version": "1.1.0",
3+
"version": "1.2.0",
44
"description": "The ultimate JavaScript string library",
55
"homepage": "https://vocajs.com",
66
"author": {

0 commit comments

Comments
 (0)