mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-09-28 21:24:26 +08:00
This is need to be able to move to flat config which I am handling in a separate CL. The overrides are there as these packages got update today, so we need to way, but they were last touched 3 years ago, so reviewing their changes upstream as well. Bug: none Change-Id: I61534f881fd4e747c716b42b773f8f7f3e9bc761 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6063618 Commit-Queue: Nikolay Vitkov <nvitkov@chromium.org> Reviewed-by: Danil Somsikov <dsv@chromium.org>
42 lines
1.4 KiB
JavaScript
42 lines
1.4 KiB
JavaScript
'use strict';
|
|
|
|
var $TypeError = require('es-errors/type');
|
|
|
|
var DefinePropertyOrThrow = require('./DefinePropertyOrThrow');
|
|
var IsExtensible = require('./IsExtensible');
|
|
var IsPropertyKey = require('./IsPropertyKey');
|
|
var Type = require('./Type');
|
|
|
|
// https://262.ecma-international.org/13.0/#sec-definemethodproperty
|
|
|
|
module.exports = function DefineMethodProperty(homeObject, key, closure, enumerable) {
|
|
if (Type(homeObject) !== 'Object') {
|
|
throw new $TypeError('Assertion failed: `homeObject` is not an Object');
|
|
}
|
|
if (!IsPropertyKey(key)) {
|
|
throw new $TypeError('Assertion failed: `key` is not a Property Key or a Private Name');
|
|
}
|
|
if (typeof closure !== 'function') {
|
|
throw new $TypeError('Assertion failed: `closure` is not a function');
|
|
}
|
|
if (typeof enumerable !== 'boolean') {
|
|
throw new $TypeError('Assertion failed: `enumerable` is not a Boolean');
|
|
}
|
|
|
|
// 1. Assert: homeObject is an ordinary, extensible object with no non-configurable properties.
|
|
if (!IsExtensible(homeObject)) {
|
|
throw new $TypeError('Assertion failed: `homeObject` is not an ordinary, extensible object, with no non-configurable properties');
|
|
}
|
|
|
|
// 2. If key is a Private Name, then
|
|
// a. Return PrivateElement { [[Key]]: key, [[Kind]]: method, [[Value]]: closure }.
|
|
// 3. Else,
|
|
var desc = { // step 3.a
|
|
'[[Value]]': closure,
|
|
'[[Writable]]': true,
|
|
'[[Enumerable]]': enumerable,
|
|
'[[Configurable]]': true
|
|
};
|
|
DefinePropertyOrThrow(homeObject, key, desc); // step 3.b
|
|
};
|