Skip to content

Commit

Permalink
Lowercase primitives in JSDoc params, other style improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Planeshifter committed Jun 2, 2016
1 parent 503c3db commit 62896b9
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/document.js
Expand Up @@ -20,7 +20,7 @@ var isBoolean = require( 'validate.io-boolean-primitive' );
* Creates a document instance.
*
* @constructor
* @param {String} text - document text
* @param {string} text - document text
* @returns {Document} class instance
*/
function Document( text ) {
Expand All @@ -34,7 +34,7 @@ function Document( text ) {
/**
* Returns a string representation of the document.
*
* @returns {String} document text
* @returns {string} document text
*/
Document.prototype.toString = function toString() {
return this.text;
Expand Down Expand Up @@ -136,7 +136,7 @@ Document.prototype.removeInvalidCharacters = function removeInvalidCharacters()
* Removes the supplied words from the documents.
*
* @param {Array} words - array of words to remove
* @param {Boolean} [caseInsensitive=false] - boolean indicating whether to ignore case when comparing words
* @param {boolean} [caseInsensitive=false] - boolean indicating whether to ignore case when comparing words
* @returns {Document} document reference
*/
Document.prototype.removeWords = function removeWords( words, caseInsensitive ) {
Expand All @@ -163,21 +163,25 @@ Document.prototype.removeWords = function removeWords( words, caseInsensitive )
* Removes the supplied words from the document without checking input argument types.
*
* @param {Array} words - array of words to remove
* @param {Boolean} [caseInsensitive=false] - boolean indicating whether to ignore case when comparing words
* @param {boolean} [caseInsensitive=false] - boolean indicating whether to ignore case when comparing words
* @returns {Document} document reference
*/
Document.prototype.removeWordsUnsafe = function removeWordsUnsafe( words, caseInsensitive ) {
var myRegExp;
var options;
var i;

for ( i = 0; i < words.length; i++ ) {
var options = caseInsensitive ? 'gi' : 'g';
var myRegExp = new RegExp( '\\b' + words[i] + '\\b', options );
options = caseInsensitive ? 'gi' : 'g';
myRegExp = new RegExp( '\\b' + words[i] + '\\b', options );
this.text = this.text.replace( myRegExp, '' );
}
// Clean the newly created extra whitespace...
this.clean();
return this;
}; // end METHOD removeWordsUnsafe()


// EXPORTS //

module.exports = Document;

0 comments on commit 62896b9

Please sign in to comment.