parent
c89fff71d9
commit
1285c266c6
12
build.js
12
build.js
|
@ -6,20 +6,10 @@
|
||||||
|
|
||||||
const Es = require('esbuild')
|
const Es = require('esbuild')
|
||||||
|
|
||||||
Es.build({
|
|
||||||
entryPoints: ['src/index.mjs'],
|
|
||||||
outfile: 'dist/index.mjs',
|
|
||||||
platform: 'node',
|
|
||||||
bundle: true,
|
|
||||||
minify: true,
|
|
||||||
format: 'esm'
|
|
||||||
})
|
|
||||||
|
|
||||||
Es.build({
|
Es.build({
|
||||||
entryPoints: ['src/index.mjs'],
|
entryPoints: ['src/index.mjs'],
|
||||||
outfile: 'dist/index.js',
|
outfile: 'dist/index.js',
|
||||||
platform: 'node',
|
|
||||||
minify: true,
|
minify: true,
|
||||||
bundle: true,
|
bundle: true,
|
||||||
target: 'node8'
|
target: 'es6'
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "es.shim",
|
"name": "es.shim",
|
||||||
"version": "2.1.1",
|
"version": "2.2.0",
|
||||||
"description": "实现部分新API, 以及一些常用的扩展方法",
|
"description": "实现部分新API, 以及一些常用的扩展方法",
|
||||||
"keyworks": [
|
"keyworks": [
|
||||||
"es5",
|
"es5",
|
||||||
|
|
|
@ -41,7 +41,7 @@ if (!Date.prototype.getFullWeek) {
|
||||||
if (!Date.prototype.format) {
|
if (!Date.prototype.format) {
|
||||||
Object.defineProperty(Date.prototype, 'format', {
|
Object.defineProperty(Date.prototype, 'format', {
|
||||||
value: function (str) {
|
value: function (str) {
|
||||||
var dt = {
|
let dt = {
|
||||||
fullyear: this.getFullYear(),
|
fullyear: this.getFullYear(),
|
||||||
year: this.getYear(),
|
year: this.getYear(),
|
||||||
fullweek: this.getFullWeek(),
|
fullweek: this.getFullWeek(),
|
||||||
|
@ -53,7 +53,7 @@ if (!Date.prototype.format) {
|
||||||
minutes: this.getMinutes(),
|
minutes: this.getMinutes(),
|
||||||
seconds: this.getSeconds()
|
seconds: this.getSeconds()
|
||||||
}
|
}
|
||||||
var reg = null
|
let reg = null
|
||||||
|
|
||||||
str = str || 'Y-m-d H:i:s'
|
str = str || 'Y-m-d H:i:s'
|
||||||
dt.g = dt.hours > 12 ? dt.hours - 12 : dt.hours
|
dt.g = dt.hours > 12 ? dt.hours - 12 : dt.hours
|
||||||
|
|
|
@ -28,7 +28,7 @@ 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 = ''
|
let params = ''
|
||||||
for (let k in this) {
|
for (let k in this) {
|
||||||
if (this[k] === void 0) {
|
if (this[k] === void 0) {
|
||||||
continue
|
continue
|
||||||
|
|
|
@ -127,7 +127,7 @@ if (!String.prototype.escape) {
|
||||||
if (!String.prototype.at) {
|
if (!String.prototype.at) {
|
||||||
Object.defineProperty(String.prototype, 'at', {
|
Object.defineProperty(String.prototype, 'at', {
|
||||||
value: function (num) {
|
value: function (num) {
|
||||||
var n = +num
|
let n = +num
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
n += this.length
|
n += this.length
|
||||||
}
|
}
|
||||||
|
@ -144,12 +144,12 @@ if (!String.prototype.at) {
|
||||||
if (!String.prototype.toJson) {
|
if (!String.prototype.toJson) {
|
||||||
Object.defineProperty(String.prototype, 'toJson', {
|
Object.defineProperty(String.prototype, 'toJson', {
|
||||||
value: function () {
|
value: function () {
|
||||||
var str = this.replace(/^\?/, '')
|
let str = this.replace(/^\?/, '')
|
||||||
var params = decodeURIComponent(str)
|
let params = decodeURIComponent(str)
|
||||||
.split('&')
|
.split('&')
|
||||||
.filter(_ => _)
|
.filter(_ => _)
|
||||||
.map(_ => _.split('='))
|
.map(_ => _.split('='))
|
||||||
var obj = {}
|
let obj = {}
|
||||||
for (let it of params) {
|
for (let it of params) {
|
||||||
obj[it[0]] = it[1] || ''
|
obj[it[0]] = it[1] || ''
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue