react / react-0.13.3 / examples / basic-commonjs / node_modules / browserify / node_modules / isarray / build / build.js
80724 views1/**2* Require the given path.3*4* @param {String} path5* @return {Object} exports6* @api public7*/89function require(path, parent, orig) {10var resolved = require.resolve(path);1112// lookup failed13if (null == resolved) {14orig = orig || path;15parent = parent || 'root';16var err = new Error('Failed to require "' + orig + '" from "' + parent + '"');17err.path = orig;18err.parent = parent;19err.require = true;20throw err;21}2223var module = require.modules[resolved];2425// perform real require()26// by invoking the module's27// registered function28if (!module.exports) {29module.exports = {};30module.client = module.component = true;31module.call(this, module.exports, require.relative(resolved), module);32}3334return module.exports;35}3637/**38* Registered modules.39*/4041require.modules = {};4243/**44* Registered aliases.45*/4647require.aliases = {};4849/**50* Resolve `path`.51*52* Lookup:53*54* - PATH/index.js55* - PATH.js56* - PATH57*58* @param {String} path59* @return {String} path or null60* @api private61*/6263require.resolve = function(path) {64if (path.charAt(0) === '/') path = path.slice(1);65var index = path + '/index.js';6667var paths = [68path,69path + '.js',70path + '.json',71path + '/index.js',72path + '/index.json'73];7475for (var i = 0; i < paths.length; i++) {76var path = paths[i];77if (require.modules.hasOwnProperty(path)) return path;78}7980if (require.aliases.hasOwnProperty(index)) {81return require.aliases[index];82}83};8485/**86* Normalize `path` relative to the current path.87*88* @param {String} curr89* @param {String} path90* @return {String}91* @api private92*/9394require.normalize = function(curr, path) {95var segs = [];9697if ('.' != path.charAt(0)) return path;9899curr = curr.split('/');100path = path.split('/');101102for (var i = 0; i < path.length; ++i) {103if ('..' == path[i]) {104curr.pop();105} else if ('.' != path[i] && '' != path[i]) {106segs.push(path[i]);107}108}109110return curr.concat(segs).join('/');111};112113/**114* Register module at `path` with callback `definition`.115*116* @param {String} path117* @param {Function} definition118* @api private119*/120121require.register = function(path, definition) {122require.modules[path] = definition;123};124125/**126* Alias a module definition.127*128* @param {String} from129* @param {String} to130* @api private131*/132133require.alias = function(from, to) {134if (!require.modules.hasOwnProperty(from)) {135throw new Error('Failed to alias "' + from + '", it does not exist');136}137require.aliases[to] = from;138};139140/**141* Return a require function relative to the `parent` path.142*143* @param {String} parent144* @return {Function}145* @api private146*/147148require.relative = function(parent) {149var p = require.normalize(parent, '..');150151/**152* lastIndexOf helper.153*/154155function lastIndexOf(arr, obj) {156var i = arr.length;157while (i--) {158if (arr[i] === obj) return i;159}160return -1;161}162163/**164* The relative require() itself.165*/166167function localRequire(path) {168var resolved = localRequire.resolve(path);169return require(resolved, parent, path);170}171172/**173* Resolve relative to the parent.174*/175176localRequire.resolve = function(path) {177var c = path.charAt(0);178if ('/' == c) return path.slice(1);179if ('.' == c) return require.normalize(p, path);180181// resolve deps by returning182// the dep in the nearest "deps"183// directory184var segs = parent.split('/');185var i = lastIndexOf(segs, 'deps') + 1;186if (!i) i = 0;187path = segs.slice(0, i + 1).join('/') + '/deps/' + path;188return path;189};190191/**192* Check if module is defined at `path`.193*/194195localRequire.exists = function(path) {196return require.modules.hasOwnProperty(localRequire.resolve(path));197};198199return localRequire;200};201require.register("isarray/index.js", function(exports, require, module){202module.exports = Array.isArray || function (arr) {203return Object.prototype.toString.call(arr) == '[object Array]';204};205206});207require.alias("isarray/index.js", "isarray/index.js");208209210211