From e5097d0b7bb614c95ffb7c0c66a257846989f54c Mon Sep 17 00:00:00 2001 From: yutent Date: Fri, 17 Feb 2023 12:29:23 +0800 Subject: [PATCH] fixed Object.prototype.toParams --- package.json | 21 ++++++++++++++------- src/lib/object.js | 7 +++++-- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index be7fd07..65f5bfc 100644 --- a/package.json +++ b/package.json @@ -1,17 +1,24 @@ { "name": "es.shim", - "version": "2.1.0", + "version": "2.1.1", "description": "实现部分新API, 以及一些常用的扩展方法", - "keyworks": ["es5", "es6", "es7", "es2015", "lodash", "polyfill", "extend", "shim"], + "keyworks": [ + "es5", + "es6", + "es7", + "es2015", + "lodash", + "polyfill", + "extend", + "shim" + ], "main": "dist/index.js", - "files": ["dist/*"], + "files": [ + "dist/*" + ], "scripts": { "start": "node ./build.js" }, - "exports": { - "require": "./dist/index.js", - "import": "./dist/index.mjs" - }, "repository": "https://github.com/bytedo/es.shim.git", "author": "yutent", "license": "MIT" diff --git a/src/lib/object.js b/src/lib/object.js index 010b9cd..8482d85 100644 --- a/src/lib/object.js +++ b/src/lib/object.js @@ -10,7 +10,7 @@ */ if (!Object.empty) { Object.defineProperty(Object, 'empty', { - value: function(obj) { + value: function (obj) { try { for (let i in obj) { return false @@ -27,9 +27,12 @@ if (!Object.empty) { */ if (!Object.prototype.toParams) { Object.defineProperty(Object.prototype, 'toParams', { - value: function() { + value: function () { var params = '' for (let k in this) { + if (this[k] === void 0) { + continue + } params += `&${k}=${this[k]}` } return params.slice(1)