Package Exports
- popo
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (popo) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
popo 
Simple way to implement polymorphism in javascript
Install
Install with npm:
npm install --save popoUsage
There is only possible overload function by arguments number
var popo = require('popo');
var sayHello = popo({
0: function () {
return 'Hello Anonymous!';
},
1: function (name) {
return 'Hello ' + name + '!';
}
}, function otherWay () {
return 'Do I need to say Hello?';
});
sayHello(); // 'Hello Anonymous!';
sayHello('Haruki'); // 'Hello Haruki!';
sayHello('Haruki', 'Murakami'); // 'Do I need to say Hello?';
TODO
- overload by type
- add browser support
- better implementation of
defaultfunction
Test
From the repo root:
npm testLicense
Copyright (c) 2014 Ruslan Ismagilov. Licensed under the MIT license.