Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/es-abstract/2017/OrdinarySetPrototypeOf.js')
-rw-r--r--node_modules/es-abstract/2017/OrdinarySetPrototypeOf.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/node_modules/es-abstract/2017/OrdinarySetPrototypeOf.js b/node_modules/es-abstract/2017/OrdinarySetPrototypeOf.js
new file mode 100644
index 000000000..3541331ca
--- /dev/null
+++ b/node_modules/es-abstract/2017/OrdinarySetPrototypeOf.js
@@ -0,0 +1,53 @@
+'use strict';
+
+var GetIntrinsic = require('../GetIntrinsic');
+
+var $TypeError = GetIntrinsic('%TypeError%');
+
+var $setProto = require('../helpers/setProto');
+
+var OrdinaryGetPrototypeOf = require('./OrdinaryGetPrototypeOf');
+var Type = require('./Type');
+
+// https://ecma-international.org/ecma-262/7.0/#sec-ordinarysetprototypeof
+
+module.exports = function OrdinarySetPrototypeOf(O, V) {
+ if (Type(V) !== 'Object' && Type(V) !== 'Null') {
+ throw new $TypeError('Assertion failed: V must be Object or Null');
+ }
+ /*
+ var extensible = IsExtensible(O);
+ var current = OrdinaryGetPrototypeOf(O);
+ if (SameValue(V, current)) {
+ return true;
+ }
+ if (!extensible) {
+ return false;
+ }
+ */
+ try {
+ $setProto(O, V);
+ } catch (e) {
+ return false;
+ }
+ return OrdinaryGetPrototypeOf(O) === V;
+ /*
+ var p = V;
+ var done = false;
+ while (!done) {
+ if (p === null) {
+ done = true;
+ } else if (SameValue(p, O)) {
+ return false;
+ } else {
+ if (wat) {
+ done = true;
+ } else {
+ p = p.[[Prototype]];
+ }
+ }
+ }
+ O.[[Prototype]] = V;
+ return true;
+ */
+};