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