diff options
Diffstat (limited to 'tools/eslint/node_modules/parse-entities/index.js')
-rw-r--r-- | tools/eslint/node_modules/parse-entities/index.js | 90 |
1 files changed, 22 insertions, 68 deletions
diff --git a/tools/eslint/node_modules/parse-entities/index.js b/tools/eslint/node_modules/parse-entities/index.js index 8106853433..f2c9e02a52 100644 --- a/tools/eslint/node_modules/parse-entities/index.js +++ b/tools/eslint/node_modules/parse-entities/index.js @@ -1,16 +1,6 @@ -/** - * @author Titus Wormer - * @copyright 2015 Titus Wormer - * @license MIT - * @module parse-entities - * @fileoverview Parse HTML character references: fast, spec-compliant, - * positional information. - */ - 'use strict'; /* Dependencies. */ -var has = require('has'); var characterEntities = require('character-entities'); var legacy = require('character-entities-legacy'); var invalid = require('character-reference-invalid'); @@ -22,6 +12,7 @@ var alphanumerical = require('is-alphanumerical'); module.exports = wrapper; /* Methods. */ +var own = {}.hasOwnProperty; var fromCharCode = String.fromCharCode; var noop = Function.prototype; @@ -100,14 +91,10 @@ MESSAGES[NUMERIC_DISALLOWED] = NUMERIC_REFERENCE + ' cannot be disallowed'; MESSAGES[NUMERIC_PROHIBITED] = NUMERIC_REFERENCE + ' cannot be outside the ' + 'permissible Unicode range'; -/** - * Wrap to ensure clean parameters are given to `parse`. - * - * @param {string} value - Value with entities. - * @param {Object?} [options] - Configuration. - */ +/* Wrap to ensure clean parameters are given to `parse`. */ function wrapper(value, options) { var settings = {}; + var option; var key; if (!options) { @@ -115,7 +102,8 @@ function wrapper(value, options) { } for (key in defaults) { - settings[key] = options[key] == null ? defaults[key] : options[key]; + option = options[key]; + settings[key] = option === null || option === undefined ? defaults[key] : option; } if (settings.position.indent || settings.position.start) { @@ -126,12 +114,7 @@ function wrapper(value, options) { return parse(value, settings); } -/** - * Parse entities. - * - * @param {string} value - Value to tokenise. - * @param {Object?} [settings] - Configuration. - */ +/* Parse entities. */ function parse(value, settings) { var additional = settings.additional; var nonTerminated = settings.nonTerminated; @@ -227,7 +210,9 @@ function parse(value, settings) { continue; } - start = begin = end = index + 1; + start = index + 1; + begin = start; + end = start; /* Numerical entity. */ if (following !== OCTOTHORP) { @@ -249,7 +234,9 @@ function parse(value, settings) { } } - entityCharacters = entity = characters = EMPTY; + entityCharacters = EMPTY; + entity = EMPTY; + characters = EMPTY; test = TESTS[type]; end--; @@ -267,7 +254,7 @@ function parse(value, settings) { * last viable named reference. This * ensures we do not need to walk backwards * later. */ - if (type === NAMED && has(legacy, characters)) { + if (type === NAMED && own.call(legacy, characters)) { entityCharacters = characters; entity = legacy[characters]; } @@ -278,7 +265,7 @@ function parse(value, settings) { if (terminated) { end++; - if (type === NAMED && has(characterEntities, characters)) { + if (type === NAMED && own.call(characterEntities, characters)) { entityCharacters = characters; entity = characterEntities[characters]; } @@ -419,12 +406,7 @@ function parse(value, settings) { /* Return the reduced nodes, and any possible warnings. */ return result.join(EMPTY); - /** - * Get current position. - * - * @return {Object} - Positional information of a - * single point. - */ + /* Get current position. */ function now() { return { line: line, @@ -433,15 +415,7 @@ function parse(value, settings) { }; } - /** - * “Throw” a parse-error: a warning. - * - * @param {number} code - Identifier of reason for - * failing. - * @param {number} offset - Offset in characters from - * the current position point at which the - * parse-error ocurred, cannot point past newlines. - */ + /* “Throw” a parse-error: a warning. */ function parseError(code, offset) { var position = now(); @@ -451,23 +425,14 @@ function parse(value, settings) { handleWarning.call(warningContext, MESSAGES[code], position, code); } - /** - * Get character at position. - * - * @param {number} position - Indice of character in `value`. - * @return {string} - Character at `position` in - * `value`. - */ + /* Get character at position. */ function at(position) { return value.charAt(position); } - /** - * Flush `queue` (normal text). Macro invoked before + /* Flush `queue` (normal text). Macro invoked before * each entity and at the end of `value`. - * - * Does nothing when `queue` is empty. - */ + * Does nothing when `queue` is empty. */ function flush() { if (queue) { result.push(queue); @@ -484,24 +449,13 @@ function parse(value, settings) { } } -/** - * Check whether `character` is outside the permissible - * unicode range. - * - * @param {number} code - Value. - * @return {boolean} - Whether `character` is an - * outside the permissible unicode range. - */ +/* Check if `character` is outside the permissible + * unicode range. */ function isProhibited(code) { return (code >= 0xD800 && code <= 0xDFFF) || (code > 0x10FFFF); } -/** - * Check whether `character` is disallowed. - * - * @param {number} code - Value. - * @return {boolean} - Whether `character` is disallowed. - */ +/* Check if `character` is disallowed. */ function isWarning(code) { if ( (code >= 0x0001 && code <= 0x0008) || |