react-crossroads
Version:
Client side router for web applications built with React and utilizing the Flux architecture. The backing routing engine is CrossroadsJs.
28 lines (25 loc) • 896 B
JavaScript
var NamedLocations,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
NamedLocations = {
locations: {
hash: require('./HashLocation'),
history: require('./HistoryLocation'),
refresh: require('./RefreshLocation'),
memory: require('./MemoryLocation')
},
locationFor: (function(_this) {
return function(name) {
var isSupported, location;
if (__indexOf.call(Object.keys(NamedLocations.locations), name) < 0) {
throw new Error('Location type is not supported');
}
location = NamedLocations.locations[name];
isSupported = location.isSupportedOrFallback();
if (isSupported !== true) {
location = NamedLocations.locations[isSupported];
}
return location;
};
})(this)
};
module.exports = NamedLocations;