Fix doc bugs in _.runInContext, _.thru, _.forEachRight, & _.escapeRegExp. [closes #1065] [ci skip]

This commit is contained in:
jdalton
2015-03-21 09:58:45 -07:00
parent 3caa740fc4
commit 6006f499ac

View File

@@ -115,7 +115,8 @@
/** /**
* Used to match `RegExp` special characters. * Used to match `RegExp` special characters.
* See this [article on `RegExp` characters](http://www.regular-expressions.info/characters.html#special) * See this [article on `RegExp` characters](http://www.regular-expressions.info/characters.html#special)
* for more details. * for more details. In addition the forward slash is escaped to allow for
* easier `eval` and `Function` compilation use.
*/ */
var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g, var reRegExpChars = /[.*+?^${}()|[\]\/\\]/g,
reHasRegExpChars = RegExp(reRegExpChars.source); reHasRegExpChars = RegExp(reRegExpChars.source);
@@ -686,19 +687,19 @@
* @returns {Function} Returns a new `lodash` function. * @returns {Function} Returns a new `lodash` function.
* @example * @example
* *
* _.mixin({ 'add': function(a, b) { return a + b; } }); * _.mixin({ 'foo': _.constant('foo') });
* *
* var lodash = _.runInContext(); * var lodash = _.runInContext();
* lodash.mixin({ 'sub': function(a, b) { return a - b; } }); * lodash.mixin({ 'bar': lodash.constant('bar') });
* *
* _.isFunction(_.add); * _.isFunction(_.foo);
* // => true * // => true
* _.isFunction(_.sub); * _.isFunction(_.bar);
* // => false * // => false
* *
* lodash.isFunction(lodash.add); * lodash.isFunction(lodash.foo);
* // => false * // => false
* lodash.isFunction(lodash.sub); * lodash.isFunction(lodash.bar);
* // => true * // => true
* *
* // using `context` to mock `Date#getTime` use in `_.now` * // using `context` to mock `Date#getTime` use in `_.now`
@@ -5910,13 +5911,14 @@
* @returns {*} Returns the result of `interceptor`. * @returns {*} Returns the result of `interceptor`.
* @example * @example
* *
* _([1, 2, 3]) * _(' abc ')
* .last() * .chain()
* .trim()
* .thru(function(value) { * .thru(function(value) {
* return [value]; * return [value];
* }) * })
* .value(); * .value();
* // => [3] * // => ['abc']
*/ */
function thru(value, interceptor, thisArg) { function thru(value, interceptor, thisArg) {
return interceptor.call(thisArg, value); return interceptor.call(thisArg, value);
@@ -6430,7 +6432,7 @@
* *
* _([1, 2]).forEachRight(function(n) { * _([1, 2]).forEachRight(function(n) {
* console.log(n); * console.log(n);
* }).join(','); * }).value();
* // => logs each value from right to left and returns the array * // => logs each value from right to left and returns the array
*/ */
var forEachRight = createForEach(arrayEachRight, baseEachRight); var forEachRight = createForEach(arrayEachRight, baseEachRight);
@@ -10118,8 +10120,8 @@
} }
/** /**
* Escapes the `RegExp` special characters "\", "^", "$", ".", "|", "?", "*", * Escapes the `RegExp` special characters "\", "/", "^", "$", ".", "|", "?",
* "+", "(", ")", "[", "]", "{" and "}" in `string`. * "*", "+", "(", ")", "[", "]", "{" and "}" in `string`.
* *
* @static * @static
* @memberOf _ * @memberOf _
@@ -10129,7 +10131,7 @@
* @example * @example
* *
* _.escapeRegExp('[lodash](https://lodash.com/)'); * _.escapeRegExp('[lodash](https://lodash.com/)');
* // => '\[lodash\]\(https://lodash\.com/\)' * // => '\[lodash\]\(https:\/\/lodash\.com\/\)'
*/ */
function escapeRegExp(string) { function escapeRegExp(string) {
string = baseToString(string); string = baseToString(string);