Created
July 31, 2012 18:17
-
-
Save mrrooijen/3219143 to your computer and use it in GitHub Desktop.
Useful Batman.js Filters.
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
Batman.mixin Batman.Filters, | |
isCreating: (model) -> model?.get("lifecycle.state") == "creating" | |
isSaving: (model) -> model?.get("lifecycle.state") == "saving" | |
isDestroying: (model) -> model?.get("lifecycle.state") == "destroying" | |
isPersisting: (model) -> model?.get("lifecycle.state") in ["saving", "creating"] | |
isUndefined: (input) -> input == undefined | |
isNull: (input) -> input == null | |
isBlank: (input) -> input in [undefined, null, ""] | |
eq: (input, value) -> input == value | |
ne: (input, value) -> input != value | |
gt: (input, value) -> input > value | |
lt: (input, value) -> input < value | |
gte: (input, value) -> input >= value | |
lte: (input, value) -> input <= value | |
length: (input) -> input?.length | |
indexOf: (set, iteration) -> set?.indexOf(iteration) | |
isFirst: (set, iteration) -> set?.indexOf(iteration) == 0 | |
isLast: (set, iteration) -> set?.length - set.indexOf(iteration) == 1 | |
isEven: (input) -> input % 2 == 0 | |
isOdd: (input) -> input % 2 != 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Dude I made a website batmanfilters - where people can put their filters in ^^