mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 10:07:48 +00:00
Use invert to assign htmlUnescapes.
Former-commit-id: 20f9f29d622643e2f59bbc4a57fd2456c09ef49e
This commit is contained in:
82
lodash.js
82
lodash.js
@@ -206,31 +206,6 @@
|
||||
cloneableClasses[numberClass] = cloneableClasses[objectClass] = cloneableClasses[regexpClass] =
|
||||
cloneableClasses[stringClass] = true;
|
||||
|
||||
/**
|
||||
* Used to convert characters to HTML entities:
|
||||
*
|
||||
* Though the `>` character is escaped for symmetry, characters like `>` and `/`
|
||||
* don't require escaping in HTML and have no special meaning unless they're part
|
||||
* of a tag or an unquoted attribute value.
|
||||
* http://mathiasbynens.be/notes/ambiguous-ampersands (under "semi-related fun fact")
|
||||
*/
|
||||
var htmlEscapes = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
"'": '''
|
||||
};
|
||||
|
||||
/** Used to convert HTML entities to characters */
|
||||
var htmlUnescapes = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
''': "'"
|
||||
};
|
||||
|
||||
/** Used to determine if values are of the language type Object */
|
||||
var objectTypes = {
|
||||
'boolean': false,
|
||||
@@ -828,6 +803,25 @@
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* Creates an object composed of the inverted keys and values of the given `object`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Objects
|
||||
* @param {Object} object The object to invert.
|
||||
* @returns {Object} Returns the created inverted object.
|
||||
* @example
|
||||
*
|
||||
* _.invert({ 'first': 'Moe', 'second': 'Larry', 'third': 'Curly' });
|
||||
* // => { 'Moe': 'first', 'Larry': 'second', 'Curly': 'third' } (order is not guaranteed)
|
||||
*/
|
||||
var invert = createIterator({
|
||||
'args': 'object',
|
||||
'init': '{}',
|
||||
'inLoop': 'result[value] = index'
|
||||
});
|
||||
|
||||
/**
|
||||
* Checks if `value` is an `arguments` object.
|
||||
*
|
||||
@@ -990,6 +984,25 @@
|
||||
'inLoop': 'result.push(index)'
|
||||
});
|
||||
|
||||
/**
|
||||
* Used to convert characters to HTML entities:
|
||||
*
|
||||
* Though the `>` character is escaped for symmetry, characters like `>` and `/`
|
||||
* don't require escaping in HTML and have no special meaning unless they're part
|
||||
* of a tag or an unquoted attribute value.
|
||||
* http://mathiasbynens.be/notes/ambiguous-ampersands (under "semi-related fun fact")
|
||||
*/
|
||||
var htmlEscapes = {
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
"'": '''
|
||||
};
|
||||
|
||||
/** Used to convert HTML entities to characters */
|
||||
var htmlUnescapes = invert(htmlEscapes);
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
@@ -1239,25 +1252,6 @@
|
||||
return hasOwnProperty.call(object, property);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an object composed of the inverted keys and values of the given `object`.
|
||||
*
|
||||
* @static
|
||||
* @memberOf _
|
||||
* @category Objects
|
||||
* @param {Object} object The object to invert.
|
||||
* @returns {Object} Returns the created inverted object.
|
||||
* @example
|
||||
*
|
||||
* _.invert({ 'first': 'Moe', 'second': 'Larry', 'third': 'Curly' });
|
||||
* // => { 'Moe': 'first', 'Larry': 'second', 'Curly': 'third' } (order is not guaranteed)
|
||||
*/
|
||||
var invert = createIterator({
|
||||
'args': 'object',
|
||||
'init': '{}',
|
||||
'inLoop': 'result[value] = index'
|
||||
});
|
||||
|
||||
/**
|
||||
* Checks if `value` is a boolean (`true` or `false`) value.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user