![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
npm install vxe-utils --save
import { dateToString, stringToDate } from 'xe-utils/core'
let dateStr = dateToString(new Date())
let date = stringToDate(dateStr)
import Vue from 'vue'
import XEUtils from 'xe-utils'
import VXEUtils from 'vxe-utils'
Vue.use(VXEUtils, XEUtils)
// 在Vue实例中使用
let date = this.$utils.stringToDate('2017-12-20', 'yyyy-MM-dd')
this.$utils.isNaN(undefined) // true
this.$utils.isNaN({}) // true
this.$utils.isNaN('num') // true
this.$utils.isNaN(true) // false
this.$utils.isNaN(null) // false
this.$utils.isNaN('') // false
this.$utils.isFinite(NaN) // false
this.$utils.isFinite(0) // true
this.$utils.isFinite(2e64) // true
this.$utils.isArray(null) // false
this.$utils.isArray({}) // false
this.$utils.isArray([1,2,3]) // true
this.$utils.isFloat(null) // false
this.$utils.isFloat(0) // false
this.$utils.isFloat(3) // false
this.$utils.isFloat(3.3) // true
this.$utils.isInteger(null) // false
this.$utils.isInteger(3.3) // false
this.$utils.isInteger(3) // true
this.$utils.isInteger(0) // true
this.$utils.isFunction({}) // false
this.$utils.isFunction(function(){}) // true
this.$utils.isBoolean('false') // false
this.$utils.isBoolean(true) // true
this.$utils.isString(1) // false
this.$utils.isString(true) // false
this.$utils.isString('') // true
this.$utils.isString('abc') // true
this.$utils.isNumber(null) // false
this.$utils.isNumber('1') // false
this.$utils.isNumber(1) // true
this.$utils.isRegExp(null) // false
this.$utils.isRegExp('a') // false
this.$utils.isRegExp(new RegExp('a')) // true
this.$utils.isRegExp(/\a/) // true
this.$utils.isObject(null) // true
this.$utils.isObject([]) // true
this.$utils.isObject({}) // true
this.$utils.isObject(123) // false
this.$utils.isPlainObject(null) // false
this.$utils.isPlainObject([]) // false
this.$utils.isPlainObject(123) // false
this.$utils.isPlainObject({}) // true
this.$utils.isDate('2017-12-20') // false
this.$utils.isDate({}) // false
this.$utils.isDate(1514096716800) // false
this.$utils.isDate(new Date()) // true
this.$utils.isError(null) // false
this.$utils.isError({}) // false
this.$utils.isError(new Error('error')) // true
this.$utils.isTypeError(null) // false
this.$utils.isTypeError({}) // false
this.$utils.isTypeError(new TypeError('error')) // true
this.$utils.isEmpty(0) // true
this.$utils.isEmpty('') // true
this.$utils.isEmpty(null) // true
this.$utils.isEmpty({}) // true
this.$utils.isEmpty([]]) // true
this.$utils.isNull(0) // false
this.$utils.isNull('') // false
this.$utils.isNull(null) // true
this.$utils.isSymbol('a') // false
this.$utils.isSymbol(Symbol('a')) // true
this.$utils.isArguments([]) // false
this.$utils.isArguments(arguments) // true
this.$utils.isElement({}) // false
this.$utils.isElement(document.createElement('div')) // true
this.$utils.isDocument(document.createElement('div')) // false
this.$utils.isDocument(document) // true
this.$utils.isWindow(document) // false
this.$utils.isWindow(window) // true
this.$utils.isFormData({}) // false
this.$utils.isFormData(new FormData()) // true
this.$utils.isLeapYear('2018-12-01') // false
this.$utils.isLeapYear('2020-12-01') // true
this.$utils.isLeapYear(new Date('2020/12/01')) // true
this.$utils.getType() // 'undefined'
this.$utils.getType(null) // 'null'
this.$utils.getType('') // 'string'
this.$utils.getType(1) // 'number'
this.$utils.getType([]) // 'array'
this.$utils.getType({}) // 'object'
this.$utils.getType(function(){}) // 'function'
this.$utils.uniqueId() // 1
this.$utils.uniqueId() // 2
this.$utils.size('123') // 3
this.$utils.size([1, 3]) // 2
this.$utils.size({a: 2, b: 5}) // 2
this.$utils.indexOf([11], 22) // -1
this.$utils.indexOf([11, 22], 22) // 1
this.$utils.lastIndexOf([11], 22) // -1
this.$utils.lastIndexOf([11, 22], 22) // 1
this.$utils.includes([11], 22) // false
this.$utils.includes([11, 22], 22) // true
let obj1 = {a: null}
this.$utils.assign(obj1, {a: 11}) // {a: 11}
this.$utils.extend(obj1, {a: 11}) // {a: 11}
let obj2 = {c: null}
this.$utils.assign(obj2, {a: 11}, {b: 22}) // {a: 11, b: 22, c: null}
this.$utils.extend(obj2, {a: 11}, {b: 22}) // {a: 11, b: 22, c: null}
this.$utils.stringToJson('{"a":1}') // {a: 1}
this.$utils.stringToJson('[11,22]') // [11, 22]
this.$utils.jsonToString({a: 1}) // '{"a":1}'
this.$utils.jsonToString([11, 22]) // '[11,22]'
this.$utils.keys({a: 11}) // ['a']
this.$utils.keys([11, 22]) // [0, 1]
this.$utils.values({a: 11}) // [11]
this.$utils.values([11, 22]) // [11, 22]
this.$utils.entries({a: 11}) // [['a', 11]]
this.$utils.entries([11, 22]) // [[0, 11], [1, 22]]
this.$utils.first({a: 11, b : 22}) // 11
this.$utils.first([11, 22]) // 11
this.$utils.last({a: 11, b: 22}) // 22
this.$utils.last([11, 22]) // 22
let result = []
this.$utils.each({a: 11, b: 22}, (item, key) => {
// // this 指向当前vue实例
if (key === 'b') {
result.push(item)
}
}) // [22]
let result1 = this.$utils.groupBy([{type: 'a'}, {type: 'b'}]], 'type') // {a: [{a: 'a'}], b: [{b: 'b'}]}
let result2 = this.$utils.groupBy([{type: 'a'}, {type: 'b'}]], (item, key) => {
// // this 指向当前vue实例
return item.type
}) // {a: [{a: 'a'}], b: [{b: 'b'}]}
let result = []
this.$utils.mapObject([{type: 'a'}, {type: 'b'}]], (item, key) => {
// // this 指向当前vue实例
return item.type
}) // {a: {type: 'a', b: {type: 'b'}}}
let v1 = {a: 11, b: {b1: 22}
let v2 = this.$utils.clone({a: 11, b: 22})
if (v1.b === v2.b) {
// true
}
let v3 = this.$utils.clone(v1, true)
if (v1.b === v3.b) {
// false
}
this.$utils.uniq([11, 22, 33, 33, 22, 55]) // [11, 22, 33, 55]
this.$utils.union([11, 22], [33, 22], [44, 11]) // [11, 22, 33, 44]
this.$utils.sort([{a: 9}, {a: 4}, {a: 5}], 'a') // [{a: 4}, {a: 5}, {a: 9}]
this.$utils.sort([{a: 9}, {a: 4}, {a: 5}], (v1, v2) => {
// // this 指向当前vue实例
return v1.a > v2.a ? 1 : -1
}) // [{a: 4}, {a: 5}, {a: 9}]
this.$utils.shuffle([11, 22, 33, 44, 55]) // [22, 33, 55, 11, 44]
this.$utils.sample([11, 22, 33, 44, 55], 3) // [22, 33, 55]
this.$utils.some([{a: 11}, {a: 22}]], (item, key) => {
// // this 指向当前vue实例
return item.a === 55
}) // false
this.$utils.some([{a: 11}, {a: 22}]], (item, key) => {
// // this 指向当前vue实例
return item.a === 11
}) // true
this.$utils.every([{a: 11}, {a: 22}]], (item, key) => {
// // this 指向当前vue实例
return item.a === 11
}) // false
this.$utils.every([{a: 11}, {a: 22}]], (item, key) => {
// // this 指向当前vue实例
return item.a === 11 || item.a === 22
}) // true
this.$utils.filter([{a: 11}, {a: 22}]], (item, key) => {
// // this 指向当前vue实例
return item.a > 11
}) // [{a: 22}]
this.$utils.find([{a: 11}, {a: 22}]], (item, key) => {
// // this 指向当前vue实例
return item.a === 55
}) // null
this.$utils.find([{a: 11}, {a: 22}]], (item, key) => {
// // this 指向当前vue实例
return item.a === 22
}) // {a: 22}
this.$utils.map([{a: 11}, {a: 22}]], (item, key) => {
// // this 指向当前vue实例
return item.a
}) // [11, 22]
this.$utils.now() // 1514096716800
this.$utils.stringToDate('2017-12-20') // Wed Dec 20 2017 00:00:00 GMT+0800 (中国标准时间)
this.$utils.stringToDate('2017-12-20 10:10:30') // Wed Dec 20 2017 10:10:30 GMT+0800 (中国标准时间)
this.$utils.stringToDate('12/20/2017', 'MM/dd/yyyy') // Wed Dec 20 2017 00:00:00 GMT+0800 (中国标准时间)
this.$utils.stringToDate('12/20/2017 10:10:30.100', 'MM/dd/yyyy HH:mm') // Wed Dec 20 2017 10:10:00 GMT+0800 (中国标准时间)
this.$utils.stringToDate('12/20/2017 10:10:30.100', 'MM/dd/yyyy HH:mm:ss.SSS') // Wed Dec 20 2017 10:10:30 GMT+0800 (中国标准时间)
this.$utils.dateToString(1513735830000) // '2017-12-20 10:10:30'
this.$utils.dateToString(new Date()) // '2017-12-20 10:10:30'
this.$utils.dateToString('2017-12-20 10:10:30', 'MM/dd/yyyy') // '12/20/2017'
this.$utils.dateToString(new Date(), 'yyyy-MM-dd') // '2017-12-20'
this.$utils.dateToString(new Date(), 'yyyy-MM-dd HH:mm:ss.S') // '2017-12-20 10:10:30.100'
this.$utils.dateToString(new Date(), 'yyyy年MM月dd日 HH时mm分ss秒S毫秒,星期E 第q季度') // '2017年12月20日 10时10分30秒100毫秒,星期三 第四季度'
this.$utils.getWhatMonth(new Date(), -1) // Mon Nov 20 2017 00:00:00 GMT+0800 (中国标准时间)
this.$utils.getWhatMonth(1513735830000, -1) // Mon Nov 20 2017 00:00:00 GMT+0800 (中国标准时间)
this.$utils.getWhatMonth('2017-12-20', -1) // Mon Nov 20 2017 00:00:00 GMT+0800 (中国标准时间)
this.$utils.getWhatMonth('2017-12-20', 1) // Sat Jan 20 2018 00:00:00 GMT+0800 (中国标准时间)
this.$utils.getWhatMonth('2017-12-20', -1, 'first') // Wed Nov 01 2017 00:00:00 GMT+0800 (中国标准时间)
this.$utils.getWhatMonth('2017-12-20', 1, 'last') // Wed Jan 31 2018 00:00:00 GMT+0800 (中国标准时间)
this.$utils.getWhatWeek(new Date(), -1) // Sun Dec 17 2017 00:00:00 GMT+0800 (中国标准时间)
this.$utils.getWhatWeek(1513735830000, -1) // Sun Dec 17 2017 00:00:00 GMT+0800 (中国标准时间)
this.$utils.getWhatWeek('2017-12-20', -1) // Sun Dec 17 2017 00:00:00 GMT+0800 (中国标准时间)
this.$utils.getWhatWeek('2017-12-20', 1) // Sun Dec 31 2017 00:00:00 GMT+0800 (中国标准时间)
this.$utils.getWhatWeek('2017-12-20', -1, 5) // Fri Dec 15 2017 00:00:00 GMT+0800 (中国标准时间)
this.$utils.getWhatWeek('2017-12-20', 1, 0) // Sun Dec 31 2017 00:00:00 GMT+0800 (中国标准时间)
this.$utils.getWhatDay(new Date(), -1) // Tue Dec 19 2017 00:00:00 GMT+0800 (中国标准时间)
this.$utils.getWhatDay(1513735830000, -1) // Tue Dec 19 2017 00:00:00 GMT+0800 (中国标准时间)
this.$utils.getWhatDay('2017-12-20', -1) // Tue Dec 19 2017 00:00:00 GMT+0800 (中国标准时间)
this.$utils.getWhatDay('2017-12-20', 1) // Tue Dec 21 2017 00:00:00 GMT+0800 (中国标准时间)
this.$utils.getDaysOfMonth(new Date()) // 31
this.$utils.getDaysOfMonth(1513735830000) // 31
this.$utils.getDaysOfMonth('2017-12-20') // 31
this.$utils.getDaysOfMonth('2017-12-20', -1) // 30
this.$utils.getDaysOfMonth('2017-12-20', 1) // 31
this.$utils.getDateDiff('2017-11-20', '2017-12-21') // {MM: 1, dd: 1}
this.$utils.getDateDiff('2017-12-20', '2017-12-21') // {dd: 1}
this.$utils.getDateDiff('2017-12-20', '2017-12-21') // {dd: 1, ss: 30}
let dateDiff = this.$utils.getDateDiff('2017-12-20 10:10:30', '2017-12-21 10:15:00')
let content = `${dateDiff.mm}分${dateDiff.ss}秒` // '4分30秒'
this.$utils.random() // 0 ~ 9
this.$utils.random(3, 6) // 3 ~ 6
this.$utils.random(10, 100) // 10 ~ 100
this.$utils.min([22, 66, 77, 11]) // 11
this.$utils.min([{a: 11}, {a: 44}], 'a') // 11
this.$utils.min([{a: 11}, {a: 44}], (item) => {
// // this 指向当前vue实例
return item.a
}) // {a: 11}
this.$utils.max([22, 66, 77, 11]) // 77
this.$utils.max([{a: 11}, {a: 44}], 'a') // 44
this.$utils.max([{a: 11}, {a: 44}], (item) => {
// // this 指向当前vue实例
return item.a
}) // {a: 44}
this.$utils.escape('<a>link</a>') // '<a>link</a>'
this.$utils.escape('<a>link</a>') // '<a>link</a>'
this.$utils.browse() // {-khtml: false, -moz: false, -ms: fasle, -o: false, -webkit: true}
this.$utils.locat() // {hash: '', host: '', hostname: '', href: '', protocol: '', port: '', origin: '', query: {...}, params: {...}, ...}
this.$utils.cookie() // 获取所有
this.$utils.cookie('name') // 根据name获取
this.$utils.cookie('name', null, {expires: -1}) // 删除
this.$utils.cookie([{name: 'name', expires: -1}]) // 批量删除
this.$utils.cookie('name', 'value') // 添加/修改
this.$utils.cookie([{name: 'name', value: 'value'}]) // 批量添加/修改
this.$utils.cookie('name', 'value', {domain: 'xxx.com', path: '/', expires: 7, secure: true}) // 添加并设置domain/path/secure/expires 7天后过期
this.$utils.cookie([{name: 'name', value: 'value', domain: 'xxx.com', path: '/', expires: 7, secure: true}]) // 批量添加并设置domain/path/secure/expires 7天后过期
Copyright (c) 2017-present, Xu Liangzhan
FAQs
JavaScript 函数库、工具类
The npm package xe-utils receives a total of 3,751 weekly downloads. As such, xe-utils popularity was classified as popular.
We found that xe-utils demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.