Skip to content

Instantly share code, notes, and snippets.

@chrisnicola
Created June 4, 2014 20:47
Show Gist options
  • Save chrisnicola/7f25039a868493d13658 to your computer and use it in GitHub Desktop.
Save chrisnicola/7f25039a868493d13658 to your computer and use it in GitHub Desktop.
# Provides angular filters for lodash or underscore functions
module = angular.module('_filters', [])
_(_).functions().each (name) ->
n = name
module.filter '_' + n, -> _[n]
@chrisnicola
Copy link
Author

Turns all Underscore/Lodash functions into AngularJS filters in 4 lines. The need to locally scope "name" really threw me for a while. Every single filter would return _.zipObject. Stupid Javascript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment