MCPcopy
hub / github.com/stemkoski/stemkoski.github.com / runInContext

Function runInContext

MathBox/mathbox-bundle.js:35566–41884  ·  view source on GitHub ↗

* Create a new `lodash` function using the given context object. * * @static * @memberOf _ * @category Utilities * @param {Object} [context=root] The context object. * @returns {Function} Returns the `lodash` function.

(context)

Source from the content-addressed store, hash-verified

35564 * @returns {Function} Returns the `lodash` function.
35565 */
35566 function runInContext(context) {
35567 // Avoid issues with some ES3 environments that attempt to use values, named
35568 // after built-in constructors like `Object`, for the creation of literals.
35569 // ES5 clears this up by stating that literals must use built-in constructors.
35570 // See http://es5.github.io/#x11.1.5.
35571 context = context ? _.defaults(root.Object(), context, _.pick(root, contextProps)) : root;
35572
35573 /** Native constructor references */
35574 var Array = context.Array,
35575 Boolean = context.Boolean,
35576 Date = context.Date,
35577 Function = context.Function,
35578 Math = context.Math,
35579 Number = context.Number,
35580 Object = context.Object,
35581 RegExp = context.RegExp,
35582 String = context.String,
35583 TypeError = context.TypeError;
35584
35585 /**
35586 * Used for `Array` method references.
35587 *
35588 * Normally `Array.prototype` would suffice, however, using an array literal
35589 * avoids issues in Narwhal.
35590 */
35591 var arrayRef = [];
35592
35593 /** Used for native method references */
35594 var objectProto = Object.prototype;
35595
35596 /** Used to restore the original `_` reference in `noConflict` */
35597 var oldDash = context._;
35598
35599 /** Used to resolve the internal [[Class]] of values */
35600 var toString = objectProto.toString;
35601
35602 /** Used to detect if a method is native */
35603 var reNative = RegExp('^' +
35604 String(toString)
35605 .replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
35606 .replace(/toString| for [^\]]+/g, '.*?') + '$'
35607 );
35608
35609 /** Native method shortcuts */
35610 var ceil = Math.ceil,
35611 clearTimeout = context.clearTimeout,
35612 floor = Math.floor,
35613 fnToString = Function.prototype.toString,
35614 getPrototypeOf = isNative(getPrototypeOf = Object.getPrototypeOf) && getPrototypeOf,
35615 hasOwnProperty = objectProto.hasOwnProperty,
35616 push = arrayRef.push,
35617 setTimeout = context.setTimeout,
35618 splice = arrayRef.splice,
35619 unshift = arrayRef.unshift;
35620
35621 /** Used to set meta data on functions */
35622 var defineProperty = (function() {
35623 // IE 8 only accepts DOM elements

Callers 1

mathbox-bundle.jsFile · 0.85

Calls 9

invertFunction · 0.85
shimIsPlainObjectFunction · 0.85
createAggregatorFunction · 0.85
isStringFunction · 0.85
mixinFunction · 0.85
forOwnFunction · 0.85
isNativeFunction · 0.70
isObjectFunction · 0.70
forEachFunction · 0.70

Tested by

no test coverage detected