Plato on Github
Report Home
node_modules\atropa-regex\src\atropa-regex.js
Maintainability
61.39
Lines of code
94
Difficulty
12.92
Estimated Errors
0.22
Function weight
By Complexity
By SLOC
/// <reference path="../docs/vsdoc/OpenLayersAll.js"/> var atropa = require('atropa-header'); /*jslint indent: 4, maxerr: 50, white: true, browser: true, devel: true, plusplus: true, regexp: true */ /*global atropa */ // end header /** * Container for regex functions. * @author <a href="mailto:matthewkastor@gmail.com"> * Matthew Christopher Kastor-Inare III </a><br /> * ☭ Hial Atropa!! ☭ * @version 20120909 * @namespace Container for regex functions. */ atropa.regex = {}; /** * Regex patterns * @author <a href="mailto:matthewkastor@gmail.com"> * Matthew Christopher Kastor-Inare III </a><br /> * ☭ Hial Atropa!! ☭ * @namespace Regex patterns. */ atropa.regex.patterns = { /** * finds repeated words and phrases * @type RegExp */ repeatedWords : /(\b.{3,}\b)\s*(\1)/g, /** * finds paragraph breaks * @type RegExp */ paragraphBreaks : /(\r\n\r\n|\n\n|\r\r)/g, /** * finds line breaks * @type RegExp */ lineBreaks : /(\r\n|\r|\n)/g }; /** * Appends common prefix, suffix, and word boundary regex strings to * the supplied word. * @author <a href="mailto:matthewkastor@gmail.com"> * Matthew Christopher Kastor-Inare III </a><br /> * ☭ Hial Atropa!! ☭ * @version 20130110 * @param {String} word The word to append prefix and suffix to * @param {Integer} threshold The word.length at which it does not * make sense to append prefix and suffix. Defaults to 3. * @returns {String} Returns the supplied word with prefix, suffix, * and word boundaries attached. If the word.length was not greater * than the threshold, only word boundaries are attached. The string * represents a RegEx which should pick out most forms of regular * words. */ atropa.regex.appendPrefixesAndSuffixes = function (word, threshold) { "use strict"; var prefixes, suffixes; prefixes = '(pre|un|re)?'; suffixes = '(ification|' + 'tionally|' + 'ication|' + 'ified|istic|iness|' + 'fare|tion|ance|ence|less|ally|able|ness|ized|ised|' + 'ous|ify|ing|ity|ful|ant|ate|est|ism|izm|ist|' + 'ic|al|ed|er|et|ly|rs|in|' + 'y|s|r|d)?'; threshold = threshold === undefined ? 3 : threshold; if (word.length > threshold) { word = '\\b' + prefixes + word + suffixes + '\\b'; } else { word = '\\b()' + word + '()\\b'; } return word; }; while(atropa.data.requirements.length > 0) { atropa.data.requirements.pop()(); } module.exports = atropa;