From d5aa98b716711873528db5bd7fbe7bfdbee7fb5e Mon Sep 17 00:00:00 2001 From: coding Date: Sun, 13 May 2018 16:16:01 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9EObject.values?= =?UTF-8?q?=E5=9E=AB=E7=89=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/core/patch/Object.js | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/main/resources/core/patch/Object.js b/src/main/resources/core/patch/Object.js index 78a675d..eac63e2 100644 --- a/src/main/resources/core/patch/Object.js +++ b/src/main/resources/core/patch/Object.js @@ -28,16 +28,37 @@ } }); } - - // // JSON快捷方法 + + if (!Object.values) { + Object.defineProperty(Object, "values", { + enumerable: false, + configurable: true, + writable: true, + value: function(target) { + "use strict"; + var vals = []; + for (var key in target) { + var desc = Object.getOwnPropertyDescriptor(target, key); + if (desc !== undefined && desc.enumerable) vals.push(target[key]); + } + return vals; + } + }); + } + + // JSON快捷方法 if(!Object.toJson){ Object.defineProperty(Object.prototype, "toJson", { enumerable: false, + configurable: true, + writable: true, value: function() { return JSON.stringify(this); } }); } + + // Object.prototype.toJson = function () { // return JSON.stringify(this); // };