From 1d00a4ab4f776cd9d64866ee1d7ead7a7c740244 Mon Sep 17 00:00:00 2001 From: sttk Date: Thu, 13 Apr 2017 21:47:19 +0900 Subject: [PATCH] Allow top level objects not to be plain objects --- index.js | 8 ++++++-- web/copy-props.js | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 2cf9f0d..d7c9d68 100644 --- a/index.js +++ b/index.js @@ -5,11 +5,11 @@ var isPlainObject = require('is-plain-object'); module.exports = function(src, dst, fromto, converter, reverse) { - if (!isPlainObject(src)) { + if (!isObject(src)) { src = {}; } - if (!isPlainObject(dst)) { + if (!isObject(dst)) { dst = {}; } @@ -214,3 +214,7 @@ function setParentEmptyObject(obj, fromto) { function newUndefined() { return undefined; } + +function isObject(v) { + return Object.prototype.toString.call(v) === '[object Object]'; +} diff --git a/web/copy-props.js b/web/copy-props.js index a028641..5a78460 100644 --- a/web/copy-props.js +++ b/web/copy-props.js @@ -1 +1 @@ -!function(r){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.copyProps=r()}}(function(){return function r(t,e,n){function o(f,a){if(!e[f]){if(!t[f]){var u="function"==typeof require&&require;if(!a&&u)return u(f,!0);if(i)return i(f,!0);var c=new Error("Cannot find module '"+f+"'");throw c.code="MODULE_NOT_FOUND",c}var p=e[f]={exports:{}};t[f][0].call(p.exports,function(r){var e=t[f][1][r];return o(e||r)},p,p.exports,r,t,e,n)}return e[f].exports}for(var i="function"==typeof require&&require,f=0;f