summaryrefslogtreecommitdiffstats
path: root/node_modules/es-abstract/test/helpers/defineProperty.js
blob: 8f925bea831e4deab03c3c99c1369f63208c3e27 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
'use strict';

var oDP = Object.defineProperty;
try {
	oDP({}, 'a', { value: 1 });
} catch (e) {
	// IE 8
	oDP = null;
}

module.exports = function defineProperty(O, P, Desc) {
	if (oDP) {
		return oDP(O, P, Desc);
	}
	if ((Desc.enumerable && Desc.configurable && Desc.writable) || !(P in O)) {
		O[P] = Desc.value; // eslint-disable-line no-param-reassign
		return O;
	}

	throw new SyntaxError('helper does not yet support this configuration');
};
module.exports.oDP = oDP;