UNPKG

mic-inspector

Version:

A react inspector which a most similar of Chorme DevTools inspector

36 lines (35 loc) 1.26 kB
import { DescriptorValueType } from './types'; import { getNameType } from './locale'; /** * Named property descriptor */ export class NamedDescriptor { constructor(owner, name, arg1, arg2, enumerable = true, configurable = true) { this.owner = owner; this.name = name; this.fullname = name.toString(); this.nameType = getNameType(name); this.enumerable = enumerable; this.configurable = configurable; // if the property has accessor if (typeof arg1 === 'function' && typeof arg2 !== 'number') { this.value = void 0; this.get = arg1; this.set = arg2; this.valueType = DescriptorValueType.Normal; return; } const vt = arg2; // if the property value type is a getter if ((vt & DescriptorValueType.Getter) === DescriptorValueType.Getter) { this.fullname = `get ${this.fullname}`; } // if the property value type is a setter else if ((vt & DescriptorValueType.Setter) === DescriptorValueType.Setter) { this.fullname = `set ${this.fullname}`; } this.value = arg1; this.get = this.set = void 0; this.valueType = vt; } }