source: imaps-frontend/node_modules/es-abstract/2024/Set.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

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