Skip to content

Instantly share code, notes, and snippets.

@orlin
Created December 15, 2010 18:59
Show Gist options
  • Select an option

  • Save orlin/742422 to your computer and use it in GitHub Desktop.

Select an option

Save orlin/742422 to your computer and use it in GitHub Desktop.
underscore.js with strings and other mixins (a node.js module)
_ = require("underscore")
_.mixin require("underscore.strings")
_.mixin
# Converts the arguments list to an Array
aToArr: (list) ->
if _.isArguments(list)
_.toArray(list).slice(0)
else
console.log "aToArr called with these non-arguments: #{list}"
[list]
# Merges all from a list of objects in return for a single one
# sequentially overwrites keys (with disrespect for nested values)
oneForAll: (into, rest...) ->
for item in rest
for key, val of item
into[key] = val
into
module.exports = _
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment