Created
September 18, 2012 07:54
-
-
Save zackdever/3741880 to your computer and use it in GitHub Desktop.
small collection of string/object coffeescript utilities
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
String::endswith = (str) -> @match new RegExp "#{str}$" | |
String::startswith = (str) -> @match new RegExp "^#{str}" | |
String::splitLines = () -> @split /\r\n|\r|\n/ | |
# not unlike jQuery.extend. | |
# adds new properties in object to target. | |
# does not override anything any target properties. | |
# TODO: test! | |
exports.extend = (target, object) -> | |
for key, val of object | |
target[key] ?= object[key] | |
exports.objectKeySize = (obj) -> | |
size = 0 | |
size++ for key of obj when obj.hasOwnProperty key | |
size |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment