fixed Object.prototype.toParams

master 2.1.1
yutent 2023-02-17 12:29:23 +08:00
parent 1dfd6baf72
commit e5097d0b7b
2 changed files with 19 additions and 9 deletions

View File

@ -1,17 +1,24 @@
{ {
"name": "es.shim", "name": "es.shim",
"version": "2.1.0", "version": "2.1.1",
"description": "实现部分新API, 以及一些常用的扩展方法", "description": "实现部分新API, 以及一些常用的扩展方法",
"keyworks": ["es5", "es6", "es7", "es2015", "lodash", "polyfill", "extend", "shim"], "keyworks": [
"es5",
"es6",
"es7",
"es2015",
"lodash",
"polyfill",
"extend",
"shim"
],
"main": "dist/index.js", "main": "dist/index.js",
"files": ["dist/*"], "files": [
"dist/*"
],
"scripts": { "scripts": {
"start": "node ./build.js" "start": "node ./build.js"
}, },
"exports": {
"require": "./dist/index.js",
"import": "./dist/index.mjs"
},
"repository": "https://github.com/bytedo/es.shim.git", "repository": "https://github.com/bytedo/es.shim.git",
"author": "yutent", "author": "yutent",
"license": "MIT" "license": "MIT"

View File

@ -10,7 +10,7 @@
*/ */
if (!Object.empty) { if (!Object.empty) {
Object.defineProperty(Object, 'empty', { Object.defineProperty(Object, 'empty', {
value: function(obj) { value: function (obj) {
try { try {
for (let i in obj) { for (let i in obj) {
return false return false
@ -27,9 +27,12 @@ if (!Object.empty) {
*/ */
if (!Object.prototype.toParams) { if (!Object.prototype.toParams) {
Object.defineProperty(Object.prototype, 'toParams', { Object.defineProperty(Object.prototype, 'toParams', {
value: function() { value: function () {
var params = '' var params = ''
for (let k in this) { for (let k in this) {
if (this[k] === void 0) {
continue
}
params += `&${k}=${this[k]}` params += `&${k}=${this[k]}`
} }
return params.slice(1) return params.slice(1)