Skip to content

Instantly share code, notes, and snippets.

@alexanderjeurissen
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexanderjeurissen/9307617 to your computer and use it in GitHub Desktop.
Save alexanderjeurissen/9307617 to your computer and use it in GitHub Desktop.
A string prototype that returns an array of char codes for the given string.
String::charCodes = ->
@split("").reduce (previousValue, currentValue, index, array) ->
array[index] = currentValue.charCodeAt 0
array
, 0
String.prototype.charCodes = function() {
return this.split('').reduce(function (previousValue, currentValue, index, array) {
array[index] = currentValue.charCodeAt(0);
return array;
},0);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment