parent
c89fff71d9
commit
1285c266c6
12
build.js
12
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'
|
||||
})
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "es.shim",
|
||||
"version": "2.1.1",
|
||||
"version": "2.2.0",
|
||||
"description": "实现部分新API, 以及一些常用的扩展方法",
|
||||
"keyworks": [
|
||||
"es5",
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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] || ''
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue