Skip to content

Commit

Permalink
Bump version 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
panzerdp committed Jan 12, 2017
1 parent 50c145c commit 1e3e1c3
Show file tree
Hide file tree
Showing 7 changed files with 180 additions and 60 deletions.
28 changes: 15 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,15 @@ Then a global variable `v` is exposed for the entire library:
| [v.padLeft][padLeft] | [v.isAlphaDigit][isAlphaDigit] | [v.graphemeAt][graphemeAt] | [v.kebabCase][kebabCase] | **Escape** |
| [v.padRight][padRight] | [v.isBlank][isBlank] | [v.last][last] | [v.lowerCase][lowerCase] | [v.escapeHtml][escapeHtml] |
| [v.repeat][repeat] | [v.isDigit][isDigit] | [v.prune][prune] | [v.snakeCase][snakeCase] | [v.escapeRegExp][escapeRegExp] |
| [v.replace][replace] | [v.isEmpty][isEmpty] | [v.slice][slice] | [v.upperCase][upperCase] | [v.unescapeHtml][unescapeHtml] |
| [v.replaceAll][replaceAll] | [v.isLowerCase][isLowerCase] | [v.substr][substr] | **Split** | |
| [v.reverse][reverse] | [v.isNumeric][isNumeric] | [v.substring][substring] | [v.chars][chars] | |
| [v.reverseGrapheme][reverseGrapheme] | [v.isString][isString] | [v.truncate][truncate] | [v.codePoints][codePoints] | |
| [v.slugify][slugify] | [v.isUpperCase][isUpperCase] | **Count** | [v.graphemes][graphemes] | |
| [v.splice][splice] | [v.matches][matches] | [v.count][count] | [v.split][split] | |
| [v.trim][trim] | [v.startsWith][startsWith] | [v.countGraphemes][countGraphemes] | [v.words][words] | |
| [v.trimLeft][trimLeft] | **Format** | [v.countSubstrings][countSubstrings] | **Strip** | |
| [v.trimRight][trimRight] | [v.sprintf][sprintf] | [v.countWhere][countWhere] | [v.stripTags][stripTags] | |
| [v.replace][replace] | [v.isEmpty][isEmpty] | [v.slice][slice] | [v.titleCase][titleCase] | [v.unescapeHtml][unescapeHtml] |
| [v.replaceAll][replaceAll] | [v.isLowerCase][isLowerCase] | [v.substr][substr] | [v.upperCase][upperCase] | **Strip** |
| [v.reverse][reverse] | [v.isNumeric][isNumeric] | [v.substring][substring] | **Split** | [v.stripBom][stripBom] |
| [v.reverseGrapheme][reverseGrapheme] | [v.isString][isString] | [v.truncate][truncate] | [v.chars][chars] | [v.stripTags][stripTags] |
| [v.slugify][slugify] | [v.isUpperCase][isUpperCase] | **Count** | [v.codePoints][codePoints] | |
| [v.splice][splice] | [v.matches][matches] | [v.count][count] | [v.graphemes][graphemes] | |
| [v.trim][trim] | [v.startsWith][startsWith] | [v.countGraphemes][countGraphemes] | [v.split][split] | |
| [v.trimLeft][trimLeft] | **Format** | [v.countSubstrings][countSubstrings] | [v.words][words] | |
| [v.trimRight][trimRight] | [v.sprintf][sprintf] | [v.countWhere][countWhere] | | |
| [v.wordWrap][wordWrap] | [v.vprintf][vprintf] | [v.countWords][countWords] | | |

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

[CODE_OF_CONDUCT]: https://github.com/panzerdp/voca/blob/master/CODE_OF_CONDUCT.md
[CONTRIBUTING]: https://github.com/panzerdp/voca/blob/master/.github/CONTRIBUTING.md
[voca_min_js]: https://raw.githubusercontent.com/panzerdp/voca/1.1.0/dist/voca.min.js
[source_map]: https://raw.githubusercontent.com/panzerdp/voca/1.1.0/dist/voca.min.js.map
[voca_js]: https://raw.githubusercontent.com/panzerdp/voca/1.1.0/dist/voca.js
[voca_min_js]: https://raw.githubusercontent.com/panzerdp/voca/1.2.0/dist/voca.min.js
[source_map]: https://raw.githubusercontent.com/panzerdp/voca/1.2.0/dist/voca.min.js.map
[voca_js]: https://raw.githubusercontent.com/panzerdp/voca/1.2.0/dist/voca.js
[voca]: https://vocajs.com
[logo]: https://github.com/panzerdp/voca/raw/master/jsdoc/template/static/images/[email protected]
[logo_commonjs]: https://github.com/panzerdp/voca/raw/master/jsdoc/template/static/images/[email protected]
Expand All @@ -146,6 +146,7 @@ Licensed under [MIT](https://github.com/panzerdp/voca/blob/master/LICENSE.md)
[kebabCase]: https://vocajs.com/#kebabCase
[lowerCase]: https://vocajs.com/#lowerCase
[snakeCase]: https://vocajs.com/#snakeCase
[titleCase]: https://vocajs.com/#titleCase
[upperCase]: https://vocajs.com/#upperCase

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

[stripTags]: https://vocajs.com/#stripTags
[stripTags]: https://vocajs.com/#stripTags
[stripBom]: https://vocajs.com/#stripBom
121 changes: 88 additions & 33 deletions dist/voca.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Voca string library 1.1.0
* Voca string library 1.2.0
* https://vocajs.com
*
* Copyright Dmitri Pavlutin and other contributors
Expand Down Expand Up @@ -518,7 +518,7 @@ function camelCase(subject) {
function decapitalize(subject) {
var subjectString = coerceToString(subject);
if (subjectString === '') {
return subjectString;
return '';
}
return subjectString.substr(0, 1).toLowerCase() + subjectString.substr(1);
}
Expand Down Expand Up @@ -596,6 +596,33 @@ function upperCase(subject) {
return subjectString.toUpperCase();
}

/**
* Converts the subject to title case.
*
* @function titleCase
* @static
* @since 1.2.0
* @memberOf Case
* @param {string} [subject=''] The string to convert to title case.
* @param {Array} [ignoreWords] The words that should not be capitalized.
* @return {string} Returns the title case string.
* @example
* v.titleCase('learning to fly');
* // => 'Learning To Fly'
*
* v.titleCase('another brick in the wall', ['in', 'the']);
* // => 'Another Brick in the Wall'
*/
function titleCase(subject, ignoreWords) {
var subjectString = coerceToString(subject);
var ignoreWordsArray = Array.isArray(ignoreWords) ? ignoreWords : [];
var wordsRegExp = REGEXP_EXTENDED_ASCII.test(subjectString) ? REGEXP_LATIN_WORD : REGEXP_WORD;
return subjectString.replace(wordsRegExp, function (word) {
var lowerCaseWord = word.toLowerCase();
return ignoreWordsArray.indexOf(lowerCaseWord) !== -1 ? lowerCaseWord : capitalize(lowerCaseWord, true);
});
}

/**
* Clip the number to interval `downLimit` to `upLimit`.
*
Expand Down Expand Up @@ -2295,7 +2322,7 @@ function removeCombiningMarks(character, cleanCharacter) {
function latinise(subject) {
var subjectString = coerceToString(subject);
if (subjectString === '') {
return subjectString;
return '';
}
return subjectString.replace(REGEXP_NON_LATIN, getLatinCharacter).replace(REGEXP_COMBINING_MARKS, removeCombiningMarks);
}
Expand Down Expand Up @@ -2574,6 +2601,8 @@ function splice(subject, start, deleteCount, toAdd) {
return subjectString.slice(0, startPosition) + toAddString + subjectString.slice(startPosition + deleteCountNumber);
}

var reduce$1 = Array.prototype.reduce;

/**
* Removes whitespaces from the left side of the `subject`.
*
Expand All @@ -2582,7 +2611,7 @@ function splice(subject, start, deleteCount, toAdd) {
* @since 1.0.0
* @memberOf Manipulate
* @param {string} [subject=''] The string to trim.
* @param {string} [whitespace=whitespace] The whitespace characters to trim.
* @param {string} [whitespace=whitespace] The whitespace characters to trim. List all characters that you want to be stripped.
* @return {string} Returns the trimmed string.
* @example
* v.trimLeft(' Starship Troopers');
Expand All @@ -2600,19 +2629,18 @@ function trimLeft(subject, whitespace$$1) {
if (isNil(whitespaceString)) {
return subjectString.replace(REGEXP_TRIM_LEFT, '');
}
var whitespaceLength = whitespaceString.length;
var matchWhitespace = true;
var totalWhitespaceLength = 0;
while (matchWhitespace) {
if (subjectString.indexOf(whitespaceString, totalWhitespaceLength) === totalWhitespaceLength) {
totalWhitespaceLength += whitespaceLength;
} else {
matchWhitespace = false;
return reduce$1.call(subjectString, function (trimmed, character) {
if (matchWhitespace && includes(whitespaceString, character)) {
return trimmed;
}
}
return subjectString.substring(totalWhitespaceLength);
matchWhitespace = false;
return trimmed + character;
}, '');
}

var reduceRight = Array.prototype.reduceRight;

/**
* Removes whitespaces from the right side of the `subject`.
*
Expand All @@ -2621,7 +2649,7 @@ function trimLeft(subject, whitespace$$1) {
* @since 1.0.0
* @memberOf Manipulate
* @param {string} [subject=''] The string to trim.
* @param {string} [whitespace=whitespace] The whitespace characters to trim.
* @param {string} [whitespace=whitespace] The whitespace characters to trim. List all characters that you want to be stripped.
* @return {string} Returns the trimmed string.
* @example
* v.trimRight('the fire rises ');
Expand All @@ -2639,20 +2667,14 @@ function trimRight(subject, whitespace$$1) {
if (isNil(whitespaceString)) {
return subjectString.replace(REGEXP_TRIM_RIGHT, '');
}
var whitespaceLength = whitespaceString.length;
var subjectLength = subjectString.length;
var matchWhitespace = true;
var totalWhitespaceLength = 0;
var position = void 0;
while (matchWhitespace) {
position = subjectLength - totalWhitespaceLength - whitespaceLength;
if (subjectString.indexOf(whitespaceString, position) === position) {
totalWhitespaceLength += whitespaceLength;
} else {
matchWhitespace = false;
return reduceRight.call(subjectString, function (trimmed, character) {
if (matchWhitespace && includes(whitespaceString, character)) {
return trimmed;
}
}
return subjectString.substring(0, subjectLength - totalWhitespaceLength);
matchWhitespace = false;
return character + trimmed;
}, '');
}

/**
Expand All @@ -2663,7 +2685,7 @@ function trimRight(subject, whitespace$$1) {
* @since 1.0.0
* @memberOf Manipulate
* @param {string} [subject=''] The string to trim.
* @param {string} [whitespace=whitespace] The whitespace characters to trim.
* @param {string} [whitespace=whitespace] The whitespace characters to trim. List all characters that you want to be stripped.
* @return {string} Returns the trimmed string.
* @example
* v.trim(' Mother nature ');
Expand Down Expand Up @@ -3185,6 +3207,37 @@ function split(subject, separator, limit) {
return subjectString.split(separator, limit);
}

var BYRE_ORDER_MARK = '\uFEFF';

/**
* Strips the byte order mark (BOM) from the beginning of `subject`.
*
* @function stripBom
* @static
* @since 1.2.0
* @memberOf Strip
* @param {string} [subject=''] The string to strip from.
* @return {string} Returns the stripped string.
* @example
*
* v.stripBom('\uFEFFsummertime sadness');
* // => 'summertime sadness'
*
* v.stripBom('summertime happiness');
* // => 'summertime happiness'
*
*/
function trim$1(subject) {
var subjectString = coerceToString(subject);
if (subjectString === '') {
return '';
}
if (subjectString[0] === BYRE_ORDER_MARK) {
return subjectString.substring(1);
}
return subjectString;
}

/**
* Checks whether `subject` contains substring at specific `index`.
*
Expand Down Expand Up @@ -3227,10 +3280,11 @@ var STATE_NON_WHITESPACE = 1;
var STATE_DONE = 2;

/**
* Parses the tag name from html content
* Parses the tag name from html content.
*
* @param {string} tagContent The tag content
* @return {string} Returns the tag name
* @ignore
* @param {string} tagContent The tag content.
* @return {string} Returns the tag name.
*/
function parseTagName(tagContent) {
var state = STATE_START_TAG;
Expand Down Expand Up @@ -3290,7 +3344,7 @@ var STATE_COMMENT = 3;
* v.stripTags('Sun<br/>set', '', '-');
* // => 'Sun-set'
*/
function trim$1(subject, allowableTags, replacement) {
function trim$2(subject, allowableTags, replacement) {
subject = coerceToString(subject);
if (subject === '') {
return '';
Expand Down Expand Up @@ -3413,7 +3467,6 @@ function trim$1(subject, allowableTags, replacement) {
}
}
}

return output;
}

Expand Down Expand Up @@ -3532,6 +3585,7 @@ var functions = {
kebabCase: kebabCase,
lowerCase: lowerCase,
snakeCase: snakeCase,
titleCase: titleCase,
upperCase: upperCase,

count: count,
Expand Down Expand Up @@ -3599,7 +3653,8 @@ var functions = {
split: split,
words: words,

stripTags: trim$1,
stripBom: trim$1,
stripTags: trim$2,

noConflict: noConflict,
version: version
Expand Down
4 changes: 2 additions & 2 deletions dist/voca.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/voca.min.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions jsdoc/template/tmpl/introduction.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,11 @@ slugify('caffé latté'); // => 'caffe-latte'</code></pre>

<ul>
<li>
<a href="https://raw.githubusercontent.com/panzerdp/voca/1.1.0/dist/voca.min.js">voca.min.js</a>
minified production-ready, with <a href="https://raw.githubusercontent.com/panzerdp/voca/1.1.0/dist/voca.min.js.map">source map</a>
<a href="https://raw.githubusercontent.com/panzerdp/voca/1.2.0/dist/voca.min.js">voca.min.js</a>
minified production-ready, with <a href="https://raw.githubusercontent.com/panzerdp/voca/1.2.0/dist/voca.min.js.map">source map</a>
</li>
<li>
<a href="https://raw.githubusercontent.com/panzerdp/voca/1.1.0/dist/voca.js">voca.js</a> uncompressed
<a href="https://raw.githubusercontent.com/panzerdp/voca/1.2.0/dist/voca.js">voca.js</a> uncompressed
with comments
</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "voca",
"version": "1.1.0",
"version": "1.2.0",
"description": "The ultimate JavaScript string library",
"homepage": "https://vocajs.com",
"author": {
Expand Down
Loading

0 comments on commit 1e3e1c3

Please sign in to comment.