Skip to content

Instantly share code, notes, and snippets.

@beck
Created November 16, 2016 17:31
Show Gist options
  • Select an option

  • Save beck/5c0f19d1669554d07f329e35aab23fe0 to your computer and use it in GitHub Desktop.

Select an option

Save beck/5c0f19d1669554d07f329e35aab23fe0 to your computer and use it in GitHub Desktop.
Lodash and Amersand Router clash
global.location = {};
global.location.replace = function(){};
global.location.href = '';
global.location.pathname = '';
global.window = {};
global.window.location = global.location;
var partialRight = require('lodash').partialRight;
var partial = require('lodash').partial;
var AmpRouter = require('ampersand-router');
var msg = function(greet, name) {
console.log(greet, name, '!');
};
var Router = AmpRouter.extend({
routes: {
':msg/jo': 'jo',
'hi/:name': 'hi',
},
jo: partialRight(msg, 'jo'),
hi: partial(msg, 'hi'),
});
var r = new Router();
r.history.start();
r.navigate('sup/jo');
r.navigate('hi/sam');
process.exit();
// console outuput:
// sup null !
// hi sam !
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment