Skip to content

Instantly share code, notes, and snippets.

@SCdF
Created February 22, 2016 17:10
Show Gist options
  • Save SCdF/fdccba7dddbbcea1c0c5 to your computer and use it in GitHub Desktop.
Save SCdF/fdccba7dddbbcea1c0c5 to your computer and use it in GitHub Desktop.
Extending a sig
// NB: all three of these will have the same comment documentation
var minimumSig = function(start, mid, end) = {
var newMid;
if (arguments === 3) {
newMid = mid;
} else if (arguments === 4) {
newMid = arguments[2];
end = arguments[3];
} else {
// should I do something here?
}
doTheThing(start, mid, newMid, end);
}
var maximalSig = function(start, mid, newMid, end) = {
if (arguments === 3) {
newMid = mid;
end = arguments[2]; // because it's currently bound to newMid with end being undefined
} else {
// should I do something here?
}
doTheThing(start, mid, newMid, end);
}
var noSig = function() {
var start, mid, newMid, end;
start = arguments[0];
mid = arguments[1];
if (arguments === 3) {
newMid = mid;
end = arguments[2];
} else if (arguments === 4) {
newMid = arguments[2];
end = arguments[3];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment