Skip to content

Commit

Permalink
feat: add isNotFloat
Browse files Browse the repository at this point in the history
Ref #98
  • Loading branch information
char0n committed Aug 24, 2017
1 parent 40d74e6 commit 652d317
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 5 deletions.
9 changes: 7 additions & 2 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,20 @@ declare namespace RamdaAdjunct {
*/
isInteger(val: any): boolean;

/**
* Checks whether the passed value is complement of `integer`.
*/
isNotInteger(val: any): boolean;

/**
* Checks whether the passed value is a `float`.
*/
isFloat(val: any): boolean;

/**
* Checks whether the passed value is complement of `integer`.
* Checks whether the passed value is complement of a `float`.
*/
isNotInteger(val: any): boolean;
isNotFloat(val: any): boolean;

/**
* A function that returns `undefined`.
Expand Down
9 changes: 6 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ import isNotNaN from './isNotNaN';
import isFinite from './isFinite';
import isNotFinite from './isNotFinite';
import isInteger from './isInteger';
import isFloat from './isFloat';
import isNotInteger from './isNotInteger';
import isFloat from './isFloat';
import isNotFloat from './isNotFloat';
// Function
import stubUndefined from './stubUndefined';
import stubNull from './stubNull';
Expand Down Expand Up @@ -116,8 +117,9 @@ export { default as isNotNaN } from './isNotNaN';
export { default as isFinite } from './isFinite';
export { default as isNotFinite } from './isNotFinite';
export { default as isInteger } from './isInteger';
export { default as isFloat } from './isFloat';
export { default as isNotInteger } from './isNotInteger';
export { default as isFloat } from './isFloat';
export { default as isNotFloat } from './isNotFloat';
// Function
export { default as stubUndefined } from './stubUndefined';
export { default as stubNull } from './stubNull';
Expand Down Expand Up @@ -200,8 +202,9 @@ const RA = {
isFinite,
isNotFinite,
isInteger,
isFloat,
isNotInteger,
isFloat,
isNotFloat,
// Function
stubUndefined,
stubNull,
Expand Down
35 changes: 35 additions & 0 deletions src/isNotFloat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import { complement } from 'ramda';

import isFloat from './isFloat';

/**
* Checks whether the passed value is complement of a `float`.
*
* @func isNotFloat
* @memberOf RA
* @since {@link https://char0n.github.io/ramda-adjunct/1.14.0|v1.14.0}
* @category Type
* @sig * -> Boolean
* @param {*} val The value to test
* @return {Boolean}
* @see {@link RA.isFloat|isFloat}
* @example
*
* RA.isNotFloat(0); //=> true
* RA.isNotFloat(1); //=> true
* RA.isNotFloat(-100000); //=> true
*
* RA.isNotFloat(0.1); //=> false
* RA.isNotFloat(Math.PI); //=> false
*
* RA.isNotFloat(NaN); //=> true
* RA.isNotFloat(Infinity); //=> true
* RA.isNotFloat(-Infinity); //=> true
* RA.isNotFloat('10'); //=> true
* RA.isNotFloat(true); //=> true
* RA.isNotFloat(false); //=> true
* RA.isNotFloat([1]); //=> true
*/
const isNotFloat = complement(isFloat);

export default isNotFloat;
28 changes: 28 additions & 0 deletions test/isNotFloat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import RA from '../src/index';
import MAX_SAFE_INTEGER from '../src/internal/polyfills/Number.MAX_SAFE_INTEGER';
import MIN_SAFE_INTEGER from '../src/internal/polyfills/Number.MIN_SAFE_INTEGER';
import eq from './shared/eq';


describe('isNotFloat', function() {
it('tests a value for complement of a `float`', function() {
eq(RA.isNotFloat(0), true);
eq(RA.isNotFloat(1), true);
eq(RA.isNotFloat(-100000), true);
eq(RA.isNotFloat(MAX_SAFE_INTEGER), true);
eq(RA.isNotFloat(MIN_SAFE_INTEGER), true);
eq(RA.isNotFloat(5e+0), true);

eq(RA.isNotFloat(0.1), false);
eq(RA.isNotFloat(Math.PI), false);
eq(RA.isNotFloat(5.56789e+0), false);

eq(RA.isNotFloat(NaN), true);
eq(RA.isNotFloat(Infinity), true);
eq(RA.isNotFloat(-Infinity), true);
eq(RA.isNotFloat('10'), true);
eq(RA.isNotFloat(true), true);
eq(RA.isNotFloat(false), true);
eq(RA.isNotFloat([1]), true);
});
});

0 comments on commit 652d317

Please sign in to comment.