Version 1
[yaffs-website] / node_modules / dom-walk / example / static / bundle.js
1 (function(){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 cached = require.cache[resolved];
8     var res = cached? cached.exports : mod();
9     return res;
10 };
11
12 require.paths = [];
13 require.modules = {};
14 require.cache = {};
15 require.extensions = [".js",".coffee"];
16
17 require._core = {
18     'assert': true,
19     'events': true,
20     'fs': true,
21     'path': true,
22     'vm': true
23 };
24
25 require.resolve = (function () {
26     return function (x, cwd) {
27         if (!cwd) cwd = '/';
28         
29         if (require._core[x]) return x;
30         var path = require.modules.path();
31         cwd = path.resolve('/', cwd);
32         var y = cwd || '/';
33         
34         if (x.match(/^(?:\.\.?\/|\/)/)) {
35             var m = loadAsFileSync(path.resolve(y, x))
36                 || loadAsDirectorySync(path.resolve(y, x));
37             if (m) return m;
38         }
39         
40         var n = loadNodeModulesSync(x, y);
41         if (n) return n;
42         
43         throw new Error("Cannot find module '" + x + "'");
44         
45         function loadAsFileSync (x) {
46             x = path.normalize(x);
47             if (require.modules[x]) {
48                 return x;
49             }
50             
51             for (var i = 0; i < require.extensions.length; i++) {
52                 var ext = require.extensions[i];
53                 if (require.modules[x + ext]) return x + ext;
54             }
55         }
56         
57         function loadAsDirectorySync (x) {
58             x = x.replace(/\/+$/, '');
59             var pkgfile = path.normalize(x + '/package.json');
60             if (require.modules[pkgfile]) {
61                 var pkg = require.modules[pkgfile]();
62                 var b = pkg.browserify;
63                 if (typeof b === 'object' && b.main) {
64                     var m = loadAsFileSync(path.resolve(x, b.main));
65                     if (m) return m;
66                 }
67                 else if (typeof b === 'string') {
68                     var m = loadAsFileSync(path.resolve(x, b));
69                     if (m) return m;
70                 }
71                 else if (pkg.main) {
72                     var m = loadAsFileSync(path.resolve(x, pkg.main));
73                     if (m) return m;
74                 }
75             }
76             
77             return loadAsFileSync(x + '/index');
78         }
79         
80         function loadNodeModulesSync (x, start) {
81             var dirs = nodeModulesPathsSync(start);
82             for (var i = 0; i < dirs.length; i++) {
83                 var dir = dirs[i];
84                 var m = loadAsFileSync(dir + '/' + x);
85                 if (m) return m;
86                 var n = loadAsDirectorySync(dir + '/' + x);
87                 if (n) return n;
88             }
89             
90             var m = loadAsFileSync(x);
91             if (m) return m;
92         }
93         
94         function nodeModulesPathsSync (start) {
95             var parts;
96             if (start === '/') parts = [ '' ];
97             else parts = path.normalize(start).split('/');
98             
99             var dirs = [];
100             for (var i = parts.length - 1; i >= 0; i--) {
101                 if (parts[i] === 'node_modules') continue;
102                 var dir = parts.slice(0, i + 1).join('/') + '/node_modules';
103                 dirs.push(dir);
104             }
105             
106             return dirs;
107         }
108     };
109 })();
110
111 require.alias = function (from, to) {
112     var path = require.modules.path();
113     var res = null;
114     try {
115         res = require.resolve(from + '/package.json', '/');
116     }
117     catch (err) {
118         res = require.resolve(from, '/');
119     }
120     var basedir = path.dirname(res);
121     
122     var keys = (Object.keys || function (obj) {
123         var res = [];
124         for (var key in obj) res.push(key);
125         return res;
126     })(require.modules);
127     
128     for (var i = 0; i < keys.length; i++) {
129         var key = keys[i];
130         if (key.slice(0, basedir.length + 1) === basedir + '/') {
131             var f = key.slice(basedir.length);
132             require.modules[to + f] = require.modules[basedir + f];
133         }
134         else if (key === basedir) {
135             require.modules[to] = require.modules[basedir];
136         }
137     }
138 };
139
140 (function () {
141     var process = {};
142     
143     require.define = function (filename, fn) {
144         if (require.modules.__browserify_process) {
145             process = require.modules.__browserify_process();
146         }
147         
148         var dirname = require._core[filename]
149             ? ''
150             : require.modules.path().dirname(filename)
151         ;
152         
153         var require_ = function (file) {
154             var requiredModule = require(file, dirname);
155             var cached = require.cache[require.resolve(file, dirname)];
156
157             if (cached && cached.parent === null) {
158                 cached.parent = module_;
159             }
160
161             return requiredModule;
162         };
163         require_.resolve = function (name) {
164             return require.resolve(name, dirname);
165         };
166         require_.modules = require.modules;
167         require_.define = require.define;
168         require_.cache = require.cache;
169         var module_ = {
170             id : filename,
171             filename: filename,
172             exports : {},
173             loaded : false,
174             parent: null
175         };
176         
177         require.modules[filename] = function () {
178             require.cache[filename] = module_;
179             fn.call(
180                 module_.exports,
181                 require_,
182                 module_,
183                 module_.exports,
184                 dirname,
185                 filename,
186                 process
187             );
188             module_.loaded = true;
189             return module_.exports;
190         };
191     };
192 })();
193
194
195 require.define("path",Function(['require','module','exports','__dirname','__filename','process'],"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"));
196
197 require.define("__browserify_process",Function(['require','module','exports','__dirname','__filename','process'],"var process = module.exports = {};\n\nprocess.nextTick = (function () {\n    var queue = [];\n    var canPost = typeof window !== 'undefined'\n        && window.postMessage && window.addEventListener\n    ;\n    \n    if (canPost) {\n        window.addEventListener('message', function (ev) {\n            if (ev.source === window && ev.data === 'browserify-tick') {\n                ev.stopPropagation();\n                if (queue.length > 0) {\n                    var fn = queue.shift();\n                    fn();\n                }\n            }\n        }, true);\n    }\n    \n    return function (fn) {\n        if (canPost) {\n            queue.push(fn);\n            window.postMessage('browserify-tick', '*');\n        }\n        else setTimeout(fn, 0);\n    };\n})();\n\nprocess.title = 'browser';\nprocess.browser = true;\nprocess.env = {};\nprocess.argv = [];\n\nprocess.binding = function (name) {\n    if (name === 'evals') return (require)('vm')\n    else throw new Error('No such module. (Possibly not yet loaded)')\n};\n\n(function () {\n    var cwd = '/';\n    var path;\n    process.cwd = function () { return cwd };\n    process.chdir = function (dir) {\n        if (!path) path = require('path');\n        cwd = path.resolve(dir, cwd);\n    };\n})();\n//@ sourceURL=__browserify_process"));
198
199 require.define("vm",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = require(\"vm-browserify\")\n//@ sourceURL=vm"));
200
201 require.define("/node_modules/vm-browserify/package.json",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = {\"main\":\"index.js\"}\n//@ sourceURL=/node_modules/vm-browserify/package.json"));
202
203 require.define("/node_modules/vm-browserify/index.js",Function(['require','module','exports','__dirname','__filename','process'],"var Object_keys = function (obj) {\n    if (Object.keys) return Object.keys(obj)\n    else {\n        var res = [];\n        for (var key in obj) res.push(key)\n        return res;\n    }\n};\n\nvar forEach = function (xs, fn) {\n    if (xs.forEach) return xs.forEach(fn)\n    else for (var i = 0; i < xs.length; i++) {\n        fn(xs[i], i, xs);\n    }\n};\n\nvar Script = exports.Script = function NodeScript (code) {\n    if (!(this instanceof Script)) return new Script(code);\n    this.code = code;\n};\n\nScript.prototype.runInNewContext = function (context) {\n    if (!context) context = {};\n    \n    var iframe = document.createElement('iframe');\n    if (!iframe.style) iframe.style = {};\n    iframe.style.display = 'none';\n    \n    document.body.appendChild(iframe);\n    \n    var win = iframe.contentWindow;\n    \n    forEach(Object_keys(context), function (key) {\n        win[key] = context[key];\n    });\n     \n    if (!win.eval && win.execScript) {\n        // win.eval() magically appears when this is called in IE:\n        win.execScript('null');\n    }\n    \n    var res = win.eval(this.code);\n    \n    forEach(Object_keys(win), function (key) {\n        context[key] = win[key];\n    });\n    \n    document.body.removeChild(iframe);\n    \n    return res;\n};\n\nScript.prototype.runInThisContext = function () {\n    return eval(this.code); // maybe...\n};\n\nScript.prototype.runInContext = function (context) {\n    // seems to be just runInNewContext on magical context objects which are\n    // otherwise indistinguishable from objects except plain old objects\n    // for the parameter segfaults node\n    return this.runInNewContext(context);\n};\n\nforEach(Object_keys(Script.prototype), function (name) {\n    exports[name] = Script[name] = function (code) {\n        var s = Script(code);\n        return s[name].apply(s, [].slice.call(arguments, 1));\n    };\n});\n\nexports.createScript = function (code) {\n    return exports.Script(code);\n};\n\nexports.createContext = Script.createContext = function (context) {\n    // not really sure what this one does\n    // seems to just make a shallow copy\n    var copy = {};\n    if(typeof context === 'object') {\n        forEach(Object_keys(context), function (key) {\n            copy[key] = context[key];\n        });\n    }\n    return copy;\n};\n\n//@ sourceURL=/node_modules/vm-browserify/index.js"));
204
205 require.define("/package.json",Function(['require','module','exports','__dirname','__filename','process'],"module.exports = {\"main\":\"index\"}\n//@ sourceURL=/package.json"));
206
207 require.define("/index.js",Function(['require','module','exports','__dirname','__filename','process'],"var slice = Array.prototype.slice\n\nmodule.exports = iterativelyWalk\n\nfunction iterativelyWalk(nodes, cb) {\n    nodes = slice.call(nodes)\n\n    while(nodes.length) {\n        var node = nodes.shift(),\n            ret = cb(node)\n\n        if (ret) {\n            return ret\n        }\n\n        if (node.childNodes.length) {\n            nodes = slice.call(node.childNodes).concat(nodes)\n        }\n    }\n}\n//@ sourceURL=/index.js"));
208
209 require.define("/example/index.js",Function(['require','module','exports','__dirname','__filename','process'],"var walk = require(\"../index\")\n\nwalk(document.body.childNodes, function (node) {\n    console.log(\"node\", node)\n})\n//@ sourceURL=/example/index.js"));
210 require("/example/index.js");
211 })();