Instantly share code, notes, and snippets.

Embed
What would you like to do?
Trait example for "Enumerable" that implements only two methods [first] and [last]
/**
* see also / derived from:
* [https://github.com/petsel/composable/blob/master/src/components/Enumerable/Enumerable.first-last-item.js]
* [https://github.com/petsel/composable/blob/master/src/composites/Array/Array.first-last.js]
*/
var Enumerable_first_last = (function () {
var
Trait, // the "Enumerable_first_last" Trait Module.
first = function () {
return this[0];
},
last = function () {
return this[this.length - 1];
}
;
Trait = function () {
/**
* implementing the "Enumerable_first_last" Trait Module.
*/
this.first = first;
this.last = last;
};
return Trait;
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment