Skip to main content
Module

x/rambda/source/pathEq-spec.ts

Faster and smaller alternative to Ramda
Go to Latest
File
import {pathEq} from 'rambda'
describe('R.pathEq', () => { it('with string path', () => { const pathToSearch = 'a.b.c' const input = {a: {b: {c: 1}}} const target = {c: 1}
const result = pathEq(pathToSearch, input, target) const curriedResult = pathEq(pathToSearch, input, target) result // $ExpectType boolean curriedResult // $ExpectType boolean })
it('with array path', () => { const pathToSearch = ['a', 'b', 'c'] const input = {a: {b: {c: 1}}} const target = {c: 1}
const result = pathEq(pathToSearch, input, target) const curriedResult = pathEq(pathToSearch, input, target) result // $ExpectType boolean curriedResult // $ExpectType boolean })})
describe('with ramda specs', () => { const testPath = ['x', 0, 'y'] const testObj = { x: [ {y: 2, z: 3}, {y: 4, z: 5}, ], }
const result1 = pathEq(testPath, 2, testObj) const result2 = pathEq(testPath, 2)(testObj) const result3 = pathEq(testPath)(2)(testObj) result1 // $ExpectType boolean result2 // $ExpectType boolean result3 // $ExpectType boolean})