main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
979 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 | var isCallable = require('../internals/is-callable');
|
---|
3 | var definePropertyModule = require('../internals/object-define-property');
|
---|
4 | var makeBuiltIn = require('../internals/make-built-in');
|
---|
5 | var defineGlobalProperty = require('../internals/define-global-property');
|
---|
6 |
|
---|
7 | module.exports = function (O, key, value, options) {
|
---|
8 | if (!options) options = {};
|
---|
9 | var simple = options.enumerable;
|
---|
10 | var name = options.name !== undefined ? options.name : key;
|
---|
11 | if (isCallable(value)) makeBuiltIn(value, name, options);
|
---|
12 | if (options.global) {
|
---|
13 | if (simple) O[key] = value;
|
---|
14 | else defineGlobalProperty(key, value);
|
---|
15 | } else {
|
---|
16 | try {
|
---|
17 | if (!options.unsafe) delete O[key];
|
---|
18 | else if (O[key]) simple = true;
|
---|
19 | } catch (error) { /* empty */ }
|
---|
20 | if (simple) O[key] = value;
|
---|
21 | else definePropertyModule.f(O, key, {
|
---|
22 | value: value,
|
---|
23 | enumerable: false,
|
---|
24 | configurable: !options.nonConfigurable,
|
---|
25 | writable: !options.nonWritable
|
---|
26 | });
|
---|
27 | } return O;
|
---|
28 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.