Last active
December 16, 2015 05:29
-
-
Save petsel/5385163 to your computer and use it in GitHub Desktop.
Trait example for "Enumerable" that implements only two methods [first] and [last]
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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