moltres-utils
Version:
Utils for Moltres apps
53 lines (44 loc) • 1.21 kB
JavaScript
require("core-js/modules/es6.object.define-property");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _isFunction = _interopRequireDefault(require("./isFunction"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Converts `value` to a plain object flattening inherited enumerable string keyed properties of `value` to own properties of the plain object.
*
* @function
* @since v0.0.9
* @category lang
* @param {*} value The value to convert.
* @returns {Object} Returns the converted plain object.
* @example
*
* function Foo() {
* this.b = 2
* }
*
* Foo.prototype.c = 3
*
* assign({ 'a': 1 }, new Foo)
* // => { 'a': 1, 'b': 2 }
*
* assign({ 'a': 1 }, toObject(new Foo))
* // => { 'a': 1, 'b': 2, 'c': 3 }
*/
var toObject = function toObject(value) {
if (value != null && (0, _isFunction.default)(value.toObject)) {
return value.toObject();
}
value = Object(value);
var result = {};
for (var key in value) {
result[key] = value[key];
}
return result;
};
var _default = toObject;
exports.default = _default;
//# sourceMappingURL=toObject.js.map
;