Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80540 views
1
var require = function (file, cwd) {
2
var resolved = require.resolve(file, cwd || '/');
3
var mod = require.modules[resolved];
4
if (!mod) throw new Error(
5
'Failed to resolve module ' + file + ', tried ' + resolved
6
);
7
var res = mod._cached ? mod._cached : mod();
8
return res;
9
}
10
11
require.paths = [];
12
require.modules = {};
13
require.extensions = [".js",".coffee"];
14
15
require._core = {
16
'assert': true,
17
'events': true,
18
'fs': true,
19
'path': true,
20
'vm': true
21
};
22
23
require.resolve = (function () {
24
return function (x, cwd) {
25
if (!cwd) cwd = '/';
26
27
if (require._core[x]) return x;
28
var path = require.modules.path();
29
cwd = path.resolve('/', cwd);
30
var y = cwd || '/';
31
32
if (x.match(/^(?:\.\.?\/|\/)/)) {
33
var m = loadAsFileSync(path.resolve(y, x))
34
|| loadAsDirectorySync(path.resolve(y, x));
35
if (m) return m;
36
}
37
38
var n = loadNodeModulesSync(x, y);
39
if (n) return n;
40
41
throw new Error("Cannot find module '" + x + "'");
42
43
function loadAsFileSync (x) {
44
if (require.modules[x]) {
45
return x;
46
}
47
48
for (var i = 0; i < require.extensions.length; i++) {
49
var ext = require.extensions[i];
50
if (require.modules[x + ext]) return x + ext;
51
}
52
}
53
54
function loadAsDirectorySync (x) {
55
x = x.replace(/\/+$/, '');
56
var pkgfile = x + '/package.json';
57
if (require.modules[pkgfile]) {
58
var pkg = require.modules[pkgfile]();
59
var b = pkg.browserify;
60
if (typeof b === 'object' && b.main) {
61
var m = loadAsFileSync(path.resolve(x, b.main));
62
if (m) return m;
63
}
64
else if (typeof b === 'string') {
65
var m = loadAsFileSync(path.resolve(x, b));
66
if (m) return m;
67
}
68
else if (pkg.main) {
69
var m = loadAsFileSync(path.resolve(x, pkg.main));
70
if (m) return m;
71
}
72
}
73
74
return loadAsFileSync(x + '/index');
75
}
76
77
function loadNodeModulesSync (x, start) {
78
var dirs = nodeModulesPathsSync(start);
79
for (var i = 0; i < dirs.length; i++) {
80
var dir = dirs[i];
81
var m = loadAsFileSync(dir + '/' + x);
82
if (m) return m;
83
var n = loadAsDirectorySync(dir + '/' + x);
84
if (n) return n;
85
}
86
87
var m = loadAsFileSync(x);
88
if (m) return m;
89
}
90
91
function nodeModulesPathsSync (start) {
92
var parts;
93
if (start === '/') parts = [ '' ];
94
else parts = path.normalize(start).split('/');
95
96
var dirs = [];
97
for (var i = parts.length - 1; i >= 0; i--) {
98
if (parts[i] === 'node_modules') continue;
99
var dir = parts.slice(0, i + 1).join('/') + '/node_modules';
100
dirs.push(dir);
101
}
102
103
return dirs;
104
}
105
};
106
})();
107
108
require.alias = function (from, to) {
109
var path = require.modules.path();
110
var res = null;
111
try {
112
res = require.resolve(from + '/package.json', '/');
113
}
114
catch (err) {
115
res = require.resolve(from, '/');
116
}
117
var basedir = path.dirname(res);
118
119
var keys = (Object.keys || function (obj) {
120
var res = [];
121
for (var key in obj) res.push(key)
122
return res;
123
})(require.modules);
124
125
for (var i = 0; i < keys.length; i++) {
126
var key = keys[i];
127
if (key.slice(0, basedir.length + 1) === basedir + '/') {
128
var f = key.slice(basedir.length);
129
require.modules[to + f] = require.modules[basedir + f];
130
}
131
else if (key === basedir) {
132
require.modules[to] = require.modules[basedir];
133
}
134
}
135
};
136
137
require.define = function (filename, fn) {
138
var dirname = require._core[filename]
139
? ''
140
: require.modules.path().dirname(filename)
141
;
142
143
var require_ = function (file) {
144
return require(file, dirname)
145
};
146
require_.resolve = function (name) {
147
return require.resolve(name, dirname);
148
};
149
require_.modules = require.modules;
150
require_.define = require.define;
151
var module_ = { exports : {} };
152
153
require.modules[filename] = function () {
154
require.modules[filename]._cached = module_.exports;
155
fn.call(
156
module_.exports,
157
require_,
158
module_,
159
module_.exports,
160
dirname,
161
filename
162
);
163
require.modules[filename]._cached = module_.exports;
164
return module_.exports;
165
};
166
};
167
168
if (typeof process === 'undefined') process = {};
169
170
if (!process.nextTick) process.nextTick = (function () {
171
var queue = [];
172
var canPost = typeof window !== 'undefined'
173
&& window.postMessage && window.addEventListener
174
;
175
176
if (canPost) {
177
window.addEventListener('message', function (ev) {
178
if (ev.source === window && ev.data === 'browserify-tick') {
179
ev.stopPropagation();
180
if (queue.length > 0) {
181
var fn = queue.shift();
182
fn();
183
}
184
}
185
}, true);
186
}
187
188
return function (fn) {
189
if (canPost) {
190
queue.push(fn);
191
window.postMessage('browserify-tick', '*');
192
}
193
else setTimeout(fn, 0);
194
};
195
})();
196
197
if (!process.title) process.title = 'browser';
198
199
if (!process.binding) process.binding = function (name) {
200
if (name === 'evals') return require('vm')
201
else throw new Error('No such module')
202
};
203
204
if (!process.cwd) process.cwd = function () { return '.' };
205
206
if (!process.env) process.env = {};
207
if (!process.argv) process.argv = [];
208
209
require.define("path", Function(
210
[ 'require', 'module', 'exports', '__dirname', '__filename' ],
211
"function filter (xs, fn) {\n var res = [];\n for (var i = 0; i < xs.length; i++) {\n if (fn(xs[i], i, xs)) res.push(xs[i]);\n }\n return res;\n}\n\n// resolves . and .. elements in a path array with directory names there\n// must be no slashes, empty elements, or device names (c:\\) in the array\n// (so also no leading and trailing slashes - it does not distinguish\n// relative and absolute paths)\nfunction normalizeArray(parts, allowAboveRoot) {\n // if the path tries to go above the root, `up` ends up > 0\n var up = 0;\n for (var i = parts.length; i >= 0; i--) {\n var last = parts[i];\n if (last == '.') {\n parts.splice(i, 1);\n } else if (last === '..') {\n parts.splice(i, 1);\n up++;\n } else if (up) {\n parts.splice(i, 1);\n up--;\n }\n }\n\n // if the path is allowed to go above the root, restore leading ..s\n if (allowAboveRoot) {\n for (; up--; up) {\n parts.unshift('..');\n }\n }\n\n return parts;\n}\n\n// Regex to split a filename into [*, dir, basename, ext]\n// posix version\nvar splitPathRe = /^(.+\\/(?!$)|\\/)?((?:.+?)?(\\.[^.]*)?)$/;\n\n// path.resolve([from ...], to)\n// posix version\nexports.resolve = function() {\nvar resolvedPath = '',\n resolvedAbsolute = false;\n\nfor (var i = arguments.length; i >= -1 && !resolvedAbsolute; i--) {\n var path = (i >= 0)\n ? arguments[i]\n : process.cwd();\n\n // Skip empty and invalid entries\n if (typeof path !== 'string' || !path) {\n continue;\n }\n\n resolvedPath = path + '/' + resolvedPath;\n resolvedAbsolute = path.charAt(0) === '/';\n}\n\n// At this point the path should be resolved to a full absolute path, but\n// handle relative paths to be safe (might happen when process.cwd() fails)\n\n// Normalize the path\nresolvedPath = normalizeArray(filter(resolvedPath.split('/'), function(p) {\n return !!p;\n }), !resolvedAbsolute).join('/');\n\n return ((resolvedAbsolute ? '/' : '') + resolvedPath) || '.';\n};\n\n// path.normalize(path)\n// posix version\nexports.normalize = function(path) {\nvar isAbsolute = path.charAt(0) === '/',\n trailingSlash = path.slice(-1) === '/';\n\n// Normalize the path\npath = normalizeArray(filter(path.split('/'), function(p) {\n return !!p;\n }), !isAbsolute).join('/');\n\n if (!path && !isAbsolute) {\n path = '.';\n }\n if (path && trailingSlash) {\n path += '/';\n }\n \n return (isAbsolute ? '/' : '') + path;\n};\n\n\n// posix version\nexports.join = function() {\n var paths = Array.prototype.slice.call(arguments, 0);\n return exports.normalize(filter(paths, function(p, index) {\n return p && typeof p === 'string';\n }).join('/'));\n};\n\n\nexports.dirname = function(path) {\n var dir = splitPathRe.exec(path)[1] || '';\n var isWindows = false;\n if (!dir) {\n // No dirname\n return '.';\n } else if (dir.length === 1 ||\n (isWindows && dir.length <= 3 && dir.charAt(1) === ':')) {\n // It is just a slash or a drive letter with a slash\n return dir;\n } else {\n // It is a full dirname, strip trailing slash\n return dir.substring(0, dir.length - 1);\n }\n};\n\n\nexports.basename = function(path, ext) {\n var f = splitPathRe.exec(path)[2] || '';\n // TODO: make this comparison case-insensitive on windows?\n if (ext && f.substr(-1 * ext.length) === ext) {\n f = f.substr(0, f.length - ext.length);\n }\n return f;\n};\n\n\nexports.extname = function(path) {\n return splitPathRe.exec(path)[3] || '';\n};\n\n//@ sourceURL=path"
212
));
213
214
require.define("timers", Function(
215
[ 'require', 'module', 'exports', '__dirname', '__filename' ],
216
"module.exports = require(\"timers-browserify\")\n//@ sourceURL=timers"
217
));
218
219
require.define("/node_modules/timers-browserify/package.json", Function(
220
[ 'require', 'module', 'exports', '__dirname', '__filename' ],
221
"module.exports = {\"main\":\"main.js\"}\n//@ sourceURL=/node_modules/timers-browserify/package.json"
222
));
223
224
require.define("/node_modules/timers-browserify/main.js", Function(
225
[ 'require', 'module', 'exports', '__dirname', '__filename' ],
226
"// DOM APIs, for completeness\n\nexports.setTimeout = setTimeout;\nexports.clearTimeout = clearTimeout;\nexports.setInterval = setInterval;\nexports.clearInterval = clearInterval;\n\n// TODO: Change to more effiecient list approach used in Node.js\n// For now, we just implement the APIs using the primitives above.\n\nexports.enroll = function(item, delay) {\n item._timeoutID = setTimeout(item._onTimeout, delay);\n};\n\nexports.unenroll = function(item) {\n clearTimeout(item._timeoutID);\n};\n\nexports.active = function(item) {\n // our naive impl doesn't care (correctness is still preserved)\n};\n\n//@ sourceURL=/node_modules/timers-browserify/main.js"
227
));
228
229
require.define("/main.js", Function(
230
[ 'require', 'module', 'exports', '__dirname', '__filename' ],
231
"var timers = require('timers');\n\nvar obj = {\n _onTimeout: function() {\n console.log('Timer ran for: ' + (new Date().getTime() - obj.now) + ' ms');\n },\n start: function() {\n console.log('Timer should run for 100 ms');\n this.now = new Date().getTime();\n timers.enroll(this, 100);\n }\n};\n\nobj.start();\n\n//@ sourceURL=/main.js"
232
));
233
require("/main.js");
234
235