Ramda eqBy
var R = require("../source/index.js");
var eq = require("./shared/eq.js");
var {Just} = require("./shared/Maybe.js");


describe("eqBy", function() {

  it("determines whether two values map to the same value in the codomain", function() {
    eq(R.eqBy(Math.abs, 5, 5), true);
    eq(R.eqBy(Math.abs, 5, -5), true);
    eq(R.eqBy(Math.abs, -5, 5), true);
    eq(R.eqBy(Math.abs, -5, -5), true);
    eq(R.eqBy(Math.abs, 42, 99), false);
  });

  it("has R.equals semantics", function() {
    eq(R.eqBy(R.identity, 0, -0), false);
    eq(R.eqBy(R.identity, -0, 0), false);
    eq(R.eqBy(R.identity, NaN, NaN), true);
    eq(R.eqBy(R.identity, new Just([42]), new Just([42])), true);
  });

});

Related articles

Ramda splitWhenever

var R = require("../source/index.js"); var eq = require("./shared/eq.js"); describe("splitWhenever", function() { it("Splits an array into slices, whenever the predicate returns true", function() { eq(R.splitWhenever(R.equals(2), [1, 2, 3, 2, 4,

Ramda splitAt

var R = require("../source/index.js"); var eq = require("./shared/eq.js"); describe("splitAt", function() { it("splits an array at a given index", function() { eq(R.splitAt(1, [1, 2, 3]), [[1], [2, 3]]); }); it("splits a string at a given in

Ramda mergeDeepWith

var assert = require("assert"); var R = require("../source/index.js"); var eq = require("./shared/eq.js"); describe("mergeDeepWith", function() { function last(x, y) { return y; } it("takes two objects, recursively merges their own properties and

Ramda zipObj

var R = require("../source/index.js"); var eq = require("./shared/eq.js"); describe("zipObj", function() { it("combines an array of keys with an array of values into a single object", function() { eq(R.zipObj(["a", "b", "c"], [1, 2, 3]), {a: 1, b

Ramda juxt

var R = require("../source/index.js"); var eq = require("./shared/eq.js"); describe("juxt", function() { function hello() { return "hello"; } function bye() { return "bye"; } it("works with no functions and no values", function() { eq(R.juxt

Ramda nthArg

var R = require("../source/index.js"); var eq = require("./shared/eq.js"); describe("nthArg", function() { it("returns a function which returns its nth argument", function() { eq(R.nthArg(0)("foo", "bar"), "foo"); eq(R.nthArg(1)("foo", "bar")

Ramda dec

var R = require("../source/index.js"); var eq = require("./shared/eq.js"); describe("dec", function() { it("decrements its argument", function() { eq(R.dec(-1), -2); eq(R.dec(0), -1); eq(R.dec(1), 0); eq(R.dec(12.34), 11.34); eq(

Ramda examplesRunner

var assert = require("assert");var fs = require("fs");var R = require("../source/index.js");var dox = require("dox");// simple object to hold info about our examplesfunction ExampleTest(dox_info, original_source, alias_of) { this.func_name = this

Ramda lensPath

var R = require("../source/index.js"); var eq = require("./shared/eq.js"); var testObj = { a: [{ b: 1 }, { b: 2 }], d: 3 }; describe("lensPath", function() { describe("view", function() { it("focuses the specified object property

Ramda unfold

var R = require("../source/index.js"); var eq = require("./shared/eq.js"); describe("unfold", function() { it("unfolds simple functions with a starting point to create a list", function() { eq(R.unfold(function(n) {if (n > 0) {return [n, n - 1];}