MCPcopy Index your code
hub / github.com/PrairieLearn/PrairieLearn / runInContext

Function runInContext

public/javascripts/socket.io.js:1980–2816  ·  view source on GitHub ↗
(context, exports)

Source from the content-addressed store, hash-verified

1978 // Public: Initializes JSON 3 using the given `context` object, attaching the
1979 // `stringify` and `parse` functions to the specified `exports` object.
1980 function runInContext(context, exports) {
1981 context || (context = root["Object"]());
1982 exports || (exports = root["Object"]());
1983
1984 // Native constructor aliases.
1985 var Number = context["Number"] || root["Number"],
1986 String = context["String"] || root["String"],
1987 Object = context["Object"] || root["Object"],
1988 Date = context["Date"] || root["Date"],
1989 SyntaxError = context["SyntaxError"] || root["SyntaxError"],
1990 TypeError = context["TypeError"] || root["TypeError"],
1991 Math = context["Math"] || root["Math"],
1992 nativeJSON = context["JSON"] || root["JSON"];
1993
1994 // Delegate to the native `stringify` and `parse` implementations.
1995 if (typeof nativeJSON == "object" && nativeJSON) {
1996 exports.stringify = nativeJSON.stringify;
1997 exports.parse = nativeJSON.parse;
1998 }
1999
2000 // Convenience aliases.
2001 var objectProto = Object.prototype,
2002 getClass = objectProto.toString,
2003 isProperty, forEach, undef;
2004
2005 // Test the `Date#getUTC*` methods. Based on work by @Yaffle.
2006 var isExtended = new Date(-3509827334573292);
2007 try {
2008 // The `getUTCFullYear`, `Month`, and `Date` methods return nonsensical
2009 // results for certain dates in Opera >= 10.53.
2010 isExtended = isExtended.getUTCFullYear() == -109252 && isExtended.getUTCMonth() === 0 && isExtended.getUTCDate() === 1 &&
2011 // Safari < 2.0.2 stores the internal millisecond time value correctly,
2012 // but clips the values returned by the date methods to the range of
2013 // signed 32-bit integers ([-2 ** 31, 2 ** 31 - 1]).
2014 isExtended.getUTCHours() == 10 && isExtended.getUTCMinutes() == 37 && isExtended.getUTCSeconds() == 6 && isExtended.getUTCMilliseconds() == 708;
2015 } catch (exception) {}
2016
2017 // Internal: Determines whether the native `JSON.stringify` and `parse`
2018 // implementations are spec-compliant. Based on work by Ken Snyder.
2019 function has(name) {
2020 if (has[name] !== undef) {
2021 // Return cached feature test result.
2022 return has[name];
2023 }
2024 var isSupported;
2025 if (name == "bug-string-char-index") {
2026 // IE <= 7 doesn't support accessing string characters using square
2027 // bracket notation. IE 8 only supports this for primitives.
2028 isSupported = "a"[0] != "a";
2029 } else if (name == "json") {
2030 // Indicates whether both `JSON.stringify` and `JSON.parse` are
2031 // supported.
2032 isSupported = has("json-stringify") && has("json-parse");
2033 } else {
2034 var value, serialized = '{"a":[1,true,false,null,"\\u0000\\b\\n\\f\\r\\t"]}';
2035 // Test `JSON.stringify`.
2036 if (name == "json-stringify") {
2037 var stringify = exports.stringify, stringifySupported = typeof stringify == "function" && isExtended;

Callers 1

socket.io.jsFile · 0.85

Calls 8

hasFunction · 0.85
callbackFunction · 0.85
serializeFunction · 0.85
getFunction · 0.85
lexFunction · 0.85
abortFunction · 0.85
walkFunction · 0.85
callMethod · 0.80

Tested by

no test coverage detected