.gitignore added
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-prettier / node_modules / define-property / index.js
1 /*!
2  * define-property <https://github.com/jonschlinkert/define-property>
3  *
4  * Copyright (c) 2015-2018, Jon Schlinkert.
5  * Released under the MIT License.
6  */
7
8 'use strict';
9
10 var isobject = require('isobject');
11 var isDescriptor = require('is-descriptor');
12 var define = (typeof Reflect !== 'undefined' && Reflect.defineProperty)
13   ? Reflect.defineProperty
14   : Object.defineProperty;
15
16 module.exports = function defineProperty(obj, key, val) {
17   if (!isobject(obj) && typeof obj !== 'function' && !Array.isArray(obj)) {
18     throw new TypeError('expected an object, function, or array');
19   }
20
21   if (typeof key !== 'string') {
22     throw new TypeError('expected "key" to be a string');
23   }
24
25   if (isDescriptor(val)) {
26     define(obj, key, val);
27     return obj;
28   }
29
30   define(obj, key, {
31     configurable: true,
32     enumerable: false,
33     writable: true,
34     value: val
35   });
36
37   return obj;
38 };