Repository URL to install this package:
|
Version:
2.0.5 ▾
|
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)