decord/source/4447_ToPropertyDescriptor.js

54 lines
1.6 KiB
JavaScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 4447
// Function ID: 4448
2026-07-29 08:29:29 +00:00
// Name: ToPropertyDescriptor
2026-08-24 06:08:38 +00:00
// Dependencies: [4395, 541, 573, 4448, 4430]
// Module 4447 (ToPropertyDescriptor)
import isObject from "isObject" /* 4395 */;
2026-07-29 08:29:29 +00:00
export default function ToPropertyDescriptor(enumerable) {
2026-08-24 06:08:38 +00:00
if (isObject(enumerable)) {
2026-07-29 08:29:29 +00:00
const obj = {};
if (tmp(573)(enumerable, "enumerable")) {
2026-08-24 06:08:38 +00:00
obj["[[Enumerable]]"] = tmp(4448)(enumerable.enumerable);
2026-07-29 08:29:29 +00:00
}
if (tmp(573)(enumerable, "configurable")) {
2026-08-24 06:08:38 +00:00
obj["[[Configurable]]"] = tmp(4448)(enumerable.configurable);
2026-07-29 08:29:29 +00:00
}
if (tmp(573)(enumerable, "value")) {
obj["[[Value]]"] = enumerable.value;
}
if (tmp(573)(enumerable, "writable")) {
2026-08-24 06:08:38 +00:00
obj["[[Writable]]"] = tmp(4448)(enumerable.writable);
2026-07-29 08:29:29 +00:00
}
if (tmp(573)(enumerable, "get")) {
const get = enumerable.get;
if (undefined !== get) {
2026-08-24 06:08:38 +00:00
if (!tmp(4430)(get)) {
2026-07-29 08:29:29 +00:00
const tmp9 = new tmp(541)("getter must be a function");
throw tmp9;
}
}
obj["[[Get]]"] = get;
}
if (tmp(573)(enumerable, "set")) {
if (undefined !== enumerable.set) {
2026-08-24 06:08:38 +00:00
if (!tmp(4430)(set)) {
2026-07-29 08:29:29 +00:00
const tmp13 = new tmp(541)("setter must be a function");
throw tmp13;
}
}
obj["[[Set]]"] = enumerable.set;
}
if (tmp(573)(obj, "[[Get]]")) {
const tmp17 = new tmp(541)("Invalid property descriptor. Cannot both specify accessors and a value or writable attribute");
throw tmp17;
}
return obj;
} else {
const tmp5 = new tmp(541)("ToPropertyDescriptor requires an object");
throw tmp5;
}
};