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 / types / collection / isMapish.ts
Size: Mime:
import { hasIn } from '../attributes/properties/hasIn'
import isMap from './isMap'

export interface Mapish {
  get: any
  set: any
  entries: any
  keys: any
  clear: any
  delete: any
}

/**
 * @func isMapish
 *
 * @memberOf is
 * @since 3.0.0
 * @extends isMap
 * @alias isMapLike
 * @variation also checks `instanceof Chainable`
 *
 * @param  {*} x value to check
 * @return {boolean} isMapish
 *
 * @example
 *
 *    isMapish(new Map)
 *    //=> true
 *
 *    isMapish(new Chain)
 *    //=> true
 *
 *    isMapish({})
 *    //=> false
 *
 *    isMapish(1)
 *    //=> false
 *
 */
const isMapishness = (x: any): x is Map<any, any> | Mapish =>
  hasIn(x, 'get') &&
  hasIn(x, 'set') &&
  hasIn(x, 'entries') &&
  hasIn(x, 'keys') &&
  hasIn(x, 'clear') &&
  hasIn(x, 'delete')

export default (x: any): x is Map<any, any> | Mapish =>
  isMap(x) || isMapishness(x)