diff --git a/build.js b/build.js index f62df39..c28062b 100644 --- a/build.js +++ b/build.js @@ -6,20 +6,10 @@ const Es = require('esbuild') -Es.build({ - entryPoints: ['src/index.mjs'], - outfile: 'dist/index.mjs', - platform: 'node', - bundle: true, - minify: true, - format: 'esm' -}) - Es.build({ entryPoints: ['src/index.mjs'], outfile: 'dist/index.js', - platform: 'node', minify: true, bundle: true, - target: 'node8' + target: 'es6' }) diff --git a/package.json b/package.json index 65f5bfc..5095307 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "es.shim", - "version": "2.1.1", + "version": "2.2.0", "description": "实现部分新API, 以及一些常用的扩展方法", "keyworks": [ "es5", diff --git a/src/lib/date.js b/src/lib/date.js index 3375e7a..07f7077 100644 --- a/src/lib/date.js +++ b/src/lib/date.js @@ -6,7 +6,7 @@ //获取当天是本月第几周 if (!Date.isDate) { Object.defineProperty(Date, 'isDate', { - value: function(obj) { + value: function (obj) { return obj && typeof obj === 'object' && obj.getTime ? true : false }, writable: true @@ -16,7 +16,7 @@ if (!Date.isDate) { if (!Date.prototype.getFullWeek) { //获取当天是本年度第几周 Object.defineProperty(Date.prototype, 'getFullWeek', { - value: function() { + value: function () { let thisYear = this.getFullYear() let that = new Date(thisYear, 0, 1) let firstDay = that.getDay() @@ -27,7 +27,7 @@ if (!Date.prototype.getFullWeek) { //获取当天是本月第几周 Object.defineProperty(Date.prototype, 'getWeek', { - value: function() { + value: function () { let today = this.getDate() let thisMonth = this.getMonth() let thisYear = this.getFullYear() @@ -40,8 +40,8 @@ if (!Date.prototype.getFullWeek) { //时间格式化 if (!Date.prototype.format) { Object.defineProperty(Date.prototype, 'format', { - value: function(str) { - var dt = { + value: function (str) { + let dt = { fullyear: this.getFullYear(), year: this.getYear(), fullweek: this.getFullWeek(), @@ -53,7 +53,7 @@ if (!Date.prototype.format) { minutes: this.getMinutes(), seconds: this.getSeconds() } - var reg = null + let reg = null str = str || 'Y-m-d H:i:s' dt.g = dt.hours > 12 ? dt.hours - 12 : dt.hours diff --git a/src/lib/object.js b/src/lib/object.js index 8482d85..293935c 100644 --- a/src/lib/object.js +++ b/src/lib/object.js @@ -28,7 +28,7 @@ if (!Object.empty) { if (!Object.prototype.toParams) { Object.defineProperty(Object.prototype, 'toParams', { value: function () { - var params = '' + let params = '' for (let k in this) { if (this[k] === void 0) { continue diff --git a/src/lib/string.js b/src/lib/string.js index edd0c34..a450cd7 100644 --- a/src/lib/string.js +++ b/src/lib/string.js @@ -127,7 +127,7 @@ if (!String.prototype.escape) { if (!String.prototype.at) { Object.defineProperty(String.prototype, 'at', { value: function (num) { - var n = +num + let n = +num if (n < 0) { n += this.length } @@ -144,12 +144,12 @@ if (!String.prototype.at) { if (!String.prototype.toJson) { Object.defineProperty(String.prototype, 'toJson', { value: function () { - var str = this.replace(/^\?/, '') - var params = decodeURIComponent(str) + let str = this.replace(/^\?/, '') + let params = decodeURIComponent(str) .split('&') .filter(_ => _) .map(_ => _.split('=')) - var obj = {} + let obj = {} for (let it of params) { obj[it[0]] = it[1] || '' }