summaryrefslogtreecommitdiff
path: root/packages/webapi/src/lib/Object.ts
blob: 5ad5b13880768f31d4af424f13ed35e9ccd73094 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import * as _ from './utils'

export const hasOwn = {
	hasOwn(instance: object, property: any) {
		return _.__object_hasOwnProperty(instance, property)
	}
}.hasOwn

export const initObject = (target: any, exclude: Set<string>) => {
	if (exclude.has('Object') || exclude.has('object') || exclude.has('hasOwn')) return

	const Class = target.Object || globalThis.Object

	Object.defineProperty(Class, 'hasOwn', {
		value: hasOwn,
		writable: true,
		enumerable: false,
		configurable: true
	})
}