Learn more  » Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Bower components Debian packages RPM packages NuGet packages

skava / chain-able-deps   js

Repository URL to install this package:

Version: 6.0.4 

/ src / fp / propSatisfies.ts

import { AnyArrayOrObj, ObjValue } from '../_typings'
import curry from '../fp/curry'
import { hasIn } from '../is'

export interface PropSatisfiesPredicate<Value> extends Function {
  (value: Value): boolean
}

// @todo - seems backwards
// 5.0.0-beta.7
function propSatisfies<Obj, Property extends keyof Obj>(
  propertyPath: Property,
  fnIs: PropSatisfiesPredicate<ObjValue<Obj>>,
  obj: Obj
) {
  return hasIn(obj, propertyPath) ? fnIs(obj[propertyPath]) : false
}

export default curry(3, propSatisfies)