Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
exotic / src / mobx / deps / createInstanceofPredicate.ts
Size: Mime:
import { isObj } from '../../types/obj/check/isObj'

export function createPredicateForProperty(propName: string) {
  return function(x: any) {
    return isObj(x) && x[propName] === true
  }
}

export function createInstanceofPredicate<T>(
  name: string,
  clazz: new (...args: any[]) => T
): (x: any) => x is T {
  const propName = 'isMobX' + name
  clazz.prototype[propName] = true
  return function(x) {
    return isObj(x) && x[propName] === true
  } as any
}