Skip to content

Commit

Permalink
feat(bool): adding boolean matching condition operator
Browse files Browse the repository at this point in the history
  • Loading branch information
roggervalf committed Feb 28, 2021
1 parent d9f7b67 commit 028c968
Show file tree
Hide file tree
Showing 8 changed files with 84 additions and 3 deletions.
22 changes: 22 additions & 0 deletions dist/main.es.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/main.es.js.map

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions dist/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/main.js.map

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions src/conditionOperators/boolean/bool.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { bool } from './bool';

describe('bool', () => {
it('returns true', () => {
expect(bool(true, true)).toBeTruthy;
expect(bool(false, false)).toBeTruthy;
});

it('returns false', () => {
expect(bool(true, false)).toBeFalsy;
expect(bool(false, true)).toBeFalsy;
});
});
22 changes: 22 additions & 0 deletions src/conditionOperators/boolean/bool.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* Boolean matching.
*
* @since 4.7.0
* @category Boolean
* @param {number} data The value to be compared.
* @param {number} expected The expected value.
* @returns {boolean} Returns `true` if `value` is equal to `expected value`.
* @example
* ```javascript
* bool(true, true)
* // => true
*
* bool(true, false)
* // => false
* ```
*/
export function bool(data: boolean, expected: boolean): boolean {
return (
data === expected
);
}
2 changes: 2 additions & 0 deletions src/conditionOperators/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {bool} from './boolean/bool';
import {numericEquals} from './numeric/numericEquals';
import {numericGreaterThan} from './numeric/numericGreaterThan';
import {numericGreaterThanEquals} from './numeric/numericGreaterThanEquals';
Expand All @@ -11,6 +12,7 @@ import {stringNotEquals} from './string/stringNotEquals';
import {stringNotEqualsIgnoreCase} from './string/stringNotEqualsIgnoreCase';

export const operators: Record<string, unknown>={
bool,
numericEquals,
numericGreaterThan,
numericGreaterThanEquals,
Expand Down
2 changes: 1 addition & 1 deletion www/src/components/documentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const DocumentationStyled = styled.section`
td,
th {
min-width: 5rem;
min-width: 6rem;
max-width: 17rem;
white-space: break-spaces;
padding: 10px;
Expand Down

0 comments on commit 028c968

Please sign in to comment.