2 * define-property <https://github.com/jonschlinkert/define-property>
4 * Copyright (c) 2015, Jon Schlinkert.
5 * Licensed under the MIT License.
10 var isDescriptor = require('is-descriptor');
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.');
17 if (typeof prop !== 'string') {
18 throw new TypeError('expected `prop` to be a string.');
21 if (isDescriptor(val) && ('set' in val || 'get' in val)) {
22 return Object.defineProperty(obj, prop, val);
25 return Object.defineProperty(obj, prop, {