Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 54 additions & 1 deletion dist/angular-filter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Bunch of useful filters for angularJS
* @version v0.4.6 - 2014-09-11 * @link https://github.com/a8m/angular-filter
* @version v0.4.6 - 2014-09-16 * @link https://github.com/a8m/angular-filter
* @author Ariel Mashraki <ariel@mashraki.co.il>
* @license MIT License, http://www.opensource.org/licenses/MIT
*/
Expand Down Expand Up @@ -154,6 +154,58 @@ angular.module('a8m.angular', [])
}
});

/**
* @ngdoc filter
* @name a8m.conditions
* @kind function
*
* @description
* reference to math conditions
*/

angular.module('a8m.conditions', [])

.filter('isGreaterThan', function () {
return function (input, check) {
return input > check;
};
})
.filter('isGreaterThanOrEqualTo', function () {
return function (input, check) {
return input >= check;
};
})
.filter('isLessThan', function () {
return function (input, check) {
return input < check;
};
})
.filter('isLessThanOrEqualTo', function () {
return function (input, check) {
return input <= check;
};
})
.filter('isEqualTo', function () {
return function (input, check) {
return input == check;
};
})
.filter('isNotEqualTo', function () {
return function (input, check) {
return input != check;
};
})
.filter('isIdenticalTo', function () {
return function (input, check) {
return input === check;
};
})
.filter('isNotIdenticalTo', function () {
return function (input, check) {
return input !== check;
};
});

/**
* @ngdoc filter
* @name isNull
Expand Down Expand Up @@ -1734,6 +1786,7 @@ angular.module('angular.filter', [
'a8m.math.sum',

'a8m.angular',
'a8m.conditions',
'a8m.is-null',

'a8m.filter-watcher'
Expand Down
4 changes: 2 additions & 2 deletions dist/angular-filter.min.js

Large diffs are not rendered by default.

Binary file modified dist/angular-filter.zip
Binary file not shown.
51 changes: 51 additions & 0 deletions src/_filter/boolean/conditions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* @ngdoc filter
* @name a8m.conditions
* @kind function
*
* @description
* reference to math conditions
*/

angular.module('a8m.conditions', [])

.filter('isGreaterThan', function () {
return function (input, check) {
return input > check;
};
})
.filter('isGreaterThanOrEqualTo', function () {
return function (input, check) {
return input >= check;
};
})
.filter('isLessThan', function () {
return function (input, check) {
return input < check;
};
})
.filter('isLessThanOrEqualTo', function () {
return function (input, check) {
return input <= check;
};
})
.filter('isEqualTo', function () {
return function (input, check) {
return input == check;
};
})
.filter('isNotEqualTo', function () {
return function (input, check) {
return input != check;
};
})
.filter('isIdenticalTo', function () {
return function (input, check) {
return input === check;
};
})
.filter('isNotIdenticalTo', function () {
return function (input, check) {
return input !== check;
};
});
1 change: 1 addition & 0 deletions src/filters.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ angular.module('angular.filter', [
'a8m.math.sum',

'a8m.angular',
'a8m.conditions',
'a8m.is-null',

'a8m.filter-watcher'
Expand Down
41 changes: 41 additions & 0 deletions test/spec/filter/boolean/conditions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
'use strict';

describe('conditionsFilter', function () {

var isGreaterThan,
isGreaterThanOrEqualTo,
isLessThan,
isLessThanOrEqualTo,
isEqualTo,
isNotEqualTo,
isIdenticalTo,
isNotIdenticalTo;

beforeEach(module('a8m.conditions'));

beforeEach(inject(function ($filter) {
isGreaterThan = $filter('isGreaterThan');
isGreaterThanOrEqualTo = $filter('isGreaterThanOrEqualTo');
isLessThan = $filter('isLessThan');
isLessThanOrEqualTo = $filter('isLessThanOrEqualTo');
isEqualTo = $filter('isEqualTo');
isNotEqualTo = $filter('isNotEqualTo');
isIdenticalTo = $filter('isIdenticalTo');
isNotIdenticalTo = $filter('isNotIdenticalTo');
}));

it('should check expected conditions', function() {
expect(isGreaterThan(1, 2)).toBe(false);
expect(isGreaterThanOrEqualTo(1, 1)).toBe(true);

expect(isLessThan(1, 2)).toBe(true);
expect(isLessThanOrEqualTo(3, 2)).toBe(false);

expect(isEqualTo(3, '3')).toBe(true);
expect(isNotEqualTo(3, '3')).toBe(false);

expect(isIdenticalTo(3, 3)).toBe(true);
expect(isNotIdenticalTo(3, 3)).toBe(false);
});

});