generated from customcommander/project-blueprint
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
85635d3
commit 12693df
Showing
2 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/** | ||
* @license MIT | ||
* @copyright (c) 2021 Julien Gonzalez <hello@spinjs.com> | ||
*/ | ||
|
||
const {curry} = require('./functions'); | ||
|
||
/** | ||
* @namespace | ||
* @alias ROOT | ||
*/ | ||
module.exports = { | ||
/** | ||
* True if `a` and `b` are equal. Use `Object.is`. | ||
* | ||
* @example | ||
* ```javascript | ||
* const eq42 = eq(42); | ||
* | ||
* eq42(42); | ||
* //=> true | ||
* | ||
* eq42('42'); | ||
* //=> false | ||
* | ||
* eq(NaN, NaN); | ||
* //=> true; | ||
* ``` | ||
* | ||
* @public | ||
* @param {?} a | ||
* @param {?} b | ||
* @return {boolean} | ||
* @see ne | ||
*/ | ||
eq: curry((a, b) => Object.is(a, b) == true), | ||
|
||
/** | ||
* True if `a` and `b` are not equal. Use `Object.is`. | ||
* | ||
* @example | ||
* ```javascript | ||
* ne(null, undefined); | ||
* //=> true | ||
* | ||
* ne(NaN, NaN); | ||
* //=> false | ||
* ``` | ||
* | ||
* @public | ||
* @param {?} a | ||
* @param {?} b | ||
* @return {boolean} | ||
* @see eq | ||
*/ | ||
ne: curry((a, b) => Object.is(a, b) == false) | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const test = require('tape'); | ||
const {eq, ne} = require('../'); | ||
|
||
test('eq returns true if both parameters are equal', t => { | ||
const run = (a, b) => t.same(eq(a)(b), Object.is(a, b)); | ||
run(1, '1'); | ||
run(0, false); | ||
run(+0, -0); | ||
run(NaN, NaN); | ||
run(null, undefined); | ||
t.end(); | ||
}); | ||
|
||
test('ne returns true if both parameters are not equal', t => { | ||
const run = (a, b) => t.same(ne(a)(b), Object.is(a, b) == false); | ||
run(1, '1'); | ||
run(0, false); | ||
run(+0, -0); | ||
run(NaN, NaN); | ||
run(null, undefined); | ||
t.end(); | ||
}); |