-
-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add isValidNumber, isNotValidNumber #247
Conversation
src/index.js
Outdated
@@ -53,6 +53,9 @@ export { default as isInteger } from './isInteger'; | |||
export { default as isNotInteger } from './isNotInteger'; | |||
export { default as isFloat } from './isFloat'; | |||
export { default as isNotFloat } from './isNotFloat'; | |||
export { default as isValidNumber } from './isValidNumber'; | |||
export { default as isNotValidNumber } from './isNotValidNumber'; | |||
export { default as isInvalidNumber } from './isNotValidNumber'; // alias of isNotValidNumber |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO this is somehow misleading naming for isInvalidNumber
. The name indicates that the value checked by the predicate will be number, but not a valid one e.g. NaN, Infinity.
I would imagine isInvalidNumber to have the following signature
const isInvalidNumber = both(isNumber, isNotValidNumber);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. Agreed so:
- Do we need an alias for
isNotValidNumber
? I think probably not. - Do we want an
isInvalidNumber
function that only returns true forNaN
,Infinity
and-Infinity
? I'd say it's probably pretty esoteric.
src/isNotValidNumber.js
Outdated
import { complement } from 'ramda'; | ||
import isValidNumber from './isValidNumber'; | ||
|
||
/* eslint-disable max-len */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop this. Your lines length should not go over 100 chars
src/isNotValidNumber.js
Outdated
* RA.isNotValidNumber(1); //=> false | ||
* RA.isNotValidNumber(''); //=> true | ||
*/ | ||
/* eslint-enable max-len */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop this. Your lines length should not go over 100 chars
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what you mean. What should I drop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/* eslint-enable max-len */
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah. Sorry. Thought you'd wrapped all your jsdoc comment blocks in the enable/disable comments, but was just the one I cribbed from.
src/isNotValidNumber.js
Outdated
* | ||
* @func isNotValidNumber | ||
* @memberOf RA | ||
* @since {@link https://char0n.github.io/ramda-adjunct/X.X.X|vX.X.X} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/2.2.0/v2.2.0
@@ -0,0 +1,24 @@ | |||
import { complement } from 'ramda'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
divide absolute and relative imports by one empty line pls
src/isValidNumber.js
Outdated
* | ||
* @func isValidNumber | ||
* @memberOf RA | ||
* @since {@link https://char0n.github.io/ramda-adjunct/X.X.X|vX.X.X} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2.2.0
src/isValidNumber.js
Outdated
* @memberOf RA | ||
* @since {@link https://char0n.github.io/ramda-adjunct/X.X.X|vX.X.X} | ||
* @category Type | ||
* @sig * -> Boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
@see {@link RA.isNotValidNumber|isNotValidNumber}
import eq from './shared/eq'; | ||
import args from './shared/arguments'; | ||
import Symbol from './shared/Symbol'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
insert empty line
test/isNotValidNumber.js
Outdated
}); | ||
}); | ||
|
||
describe('isInvalidNumber', function() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please drop this one. We'll not deal with isInvalidNumber
in this PR.
import eq from './shared/eq'; | ||
import args from './shared/arguments'; | ||
import Symbol from './shared/Symbol'; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
insert another empty line
Regarding the |
Typescript signatures will looks like this: /**
* ... description
*/
isValidNumber(val: any): boolean;
/**
* ... description
*/
isNotValidNumber(val: any): boolean; |
src/isValidNumber.js
Outdated
* @return {Boolean} | ||
* @example | ||
* | ||
* RA.isValidNumber(1); //=> true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd add examples also for NaN, Infinity and -Infinity
src/isValidNumber.js
Outdated
* RA.isValidNumber(1); //=> true | ||
* RA.isValidNumber(''); //=> false | ||
*/ | ||
/* eslint-enable max-len */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drop this. Your lines length should not go over 100 chars
All changes made and I have removed alias |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Good job and thank you for the contribution!
isValidNumber
which tests whether a value is a number that is not eitherNaN
,Infinity
or-Infinity
.isNotValidNumber
which is the complement ofisValidNumber
.isInvalidNumber
which is aliased toisNotValidNumber
.Ref #235
Please note the following:
Typescript
I haven't added the three new functions to
index.d.ts
as I have no familiarity with TypeScript and I would be doing so blindly.Docs
I have set the
@since
versions at X.X.X as I don't know what version you will include this feat in.Tests
npm test
I have one failing test which was already failing when I pulled the branch and is unrelated to my changes. If you want me to dig deeper please let me know and I'll see if I can work out why it's failing on my machine:
npm test:ramda
Initally failed because of unmet peer dependency of
ajv
. I upgradedajv
to @5 and all pass other than the test outlined above.