|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.2 KB
|
| Rev | Line | |
|---|
| [9af201e] | 1 | 'use strict';
|
|---|
| 2 |
|
|---|
| 3 | var $TypeError = require('es-errors/type');
|
|---|
| 4 | var isObject = require('es-object-atoms/isObject');
|
|---|
| 5 |
|
|---|
| 6 | var isPropertyKey = require('../helpers/isPropertyKey');
|
|---|
| 7 | var SameValue = require('./SameValue');
|
|---|
| 8 |
|
|---|
| 9 | // IE 9 does not throw in strict mode when writability/configurability/extensibility is violated
|
|---|
| 10 | var noThrowOnStrictViolation = (function () {
|
|---|
| 11 | try {
|
|---|
| 12 | delete [].length;
|
|---|
| 13 | return true;
|
|---|
| 14 | } catch (e) {
|
|---|
| 15 | return false;
|
|---|
| 16 | }
|
|---|
| 17 | }());
|
|---|
| 18 |
|
|---|
| 19 | // https://262.ecma-international.org/6.0/#sec-set-o-p-v-throw
|
|---|
| 20 |
|
|---|
| 21 | module.exports = function Set(O, P, V, Throw) {
|
|---|
| 22 | if (!isObject(O)) {
|
|---|
| 23 | throw new $TypeError('Assertion failed: `O` must be an Object');
|
|---|
| 24 | }
|
|---|
| 25 | if (!isPropertyKey(P)) {
|
|---|
| 26 | throw new $TypeError('Assertion failed: `P` must be a Property Key');
|
|---|
| 27 | }
|
|---|
| 28 | if (typeof Throw !== 'boolean') {
|
|---|
| 29 | throw new $TypeError('Assertion failed: `Throw` must be a Boolean');
|
|---|
| 30 | }
|
|---|
| 31 | if (Throw) {
|
|---|
| 32 | O[P] = V; // eslint-disable-line no-param-reassign
|
|---|
| 33 | if (noThrowOnStrictViolation && !SameValue(O[P], V)) {
|
|---|
| 34 | throw new $TypeError('Attempted to assign to readonly property.');
|
|---|
| 35 | }
|
|---|
| 36 | return true;
|
|---|
| 37 | }
|
|---|
| 38 | try {
|
|---|
| 39 | O[P] = V; // eslint-disable-line no-param-reassign
|
|---|
| 40 | return noThrowOnStrictViolation ? SameValue(O[P], V) : true;
|
|---|
| 41 | } catch (e) {
|
|---|
| 42 | return false;
|
|---|
| 43 | }
|
|---|
| 44 |
|
|---|
| 45 | };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.