Created
February 18, 2016 20:22
-
-
Save lancebecker/585199fb9d6850c82716 to your computer and use it in GitHub Desktop.
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
+angular.module( 'gizmos.filters' ).filter( 'indexToAlphabet', [ | |
+ function() { | |
+ return function( index, lettercase ) { | |
+ var index, alphabet, len | |
+ | |
+ alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
+ len = ( alphabet.length - 1 ) | |
+ | |
+ if ( lettercase === 'lowercase' ) { | |
+ alphabet = alphabet.toLowerCase() | |
+ } | |
+ | |
+ alphabet = alphabet.split("") | |
+ index = Math.abs( +index ) || 0 | |
+ | |
+ if ( index > len ) { | |
+ return alphabet[ 0 ] | |
+ } | |
+ | |
+ return alphabet[ index ] | |
+ | |
+ } | |
+ } | |
+]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment