summaryrefslogtreecommitdiff
path: root/packages/webapi/src/lib/Object.ts
blob: cfc1ea4a4e7c26daf9fd0fc5f620597527a9ffe5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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,
	})
}