New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

xe-utils

Package Overview
Dependencies
Maintainers
1
Versions
305
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

xe-utils - npm Package Compare versions

Comparing version 1.1.1 to 1.2.0

2

package.json
{
"name": "xe-utils",
"version": "1.1.1",
"version": "1.2.0",
"description": "XEUtils 是一个轻量级的函数库,提供一套实用丰富函数",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -13,4 +13,4 @@ # XEUtils 是一个轻量级的函数库,提供一套实用丰富函数

const dateStr = dateToString(new Date())
const date = stringToDate(dateStr)
const dateStr = dateToString(new Date(), 'yyyy-MM-dd')
const date = stringToDate(dateStr, 'yyyy-MM-dd')
```

@@ -22,39 +22,6 @@

const dateStr = XEUtils.dateToString(new Date())
const date = XEUtils.stringToDate(dateStr)
const dateStr = XEUtils.dateToString(new Date(), 'yyyy-MM-dd')
const date = XEUtils.stringToDate(dateStr, 'yyyy-MM-dd')
```
### Vue全局安装
``` shell
import Vue from 'vue'
import XEUtils from 'xe-utils'
import VXEUtils from 'vxe-utils'
Vue.use(VXEUtils, XEUtils)
// 通过vue实例的调用方式
var date = this.$utils.stringToDate('2017-12-20', 'yyyy-MM-dd')
```
### 混合函数
#### 文件 ./customs.js
``` shell
export function custom1 () {
console.log('自定义函数')
}
```
#### 代码
``` shell
import Vue from 'vue'
import XEUtils from 'xe-utils'
import VXEUtils from 'vxe-utils'
import customs from './customs'
XEUtils.mixin(customs)
Vue.use(VXEUtils, XEUtils)
// 调用自定义扩展函数
this.$utils.custom1()
```
## 'xe-utils' 函数库

@@ -375,7 +342,2 @@ #### isNaN (val) 判断是否非数值

}) // [22]
this.$utils.each({a: 11, b: 22}, (item, key) => {
if (key === 'b') {
result.push(item)
}
}) // [22]
```

@@ -390,6 +352,2 @@ #### groupBy ( obj, iteratee, context ) 集合分组,默认使用键值分组,如果有iteratee则使用结果进行分组

}) // {a: [{a: 'a'}], b: [{b: 'b'}]}
var result3 = this.$utils.groupBy([{type: 'a'}, {type: 'b'}]], (item, key) => {
return item.type
}) // {a: [{a: 'a'}], b: [{b: 'b'}]}
```

@@ -404,6 +362,2 @@ #### mapObject ( obj, iteratee, context ) 指定方法后的返回值组成的新对象

}) // {a: {type: 'a', b: {type: 'b'}}}
this.$utils.mapObject([{type: 'a'}, {type: 'b'}]], (item, key) => {
return item.type
}) // {a: {type: 'a', b: {type: 'b'}}}
```

@@ -446,5 +400,2 @@ #### clone (obj, deep) 浅拷贝/深拷贝

this.$utils.sort([{a: 9}, {a: 4}, {a: 5}], (v1, v2) => {
return v1.a > v2.a ? 1 : -1
}) // [{a: 4}, {a: 5}, {a: 9}]
```

@@ -473,6 +424,2 @@ #### shuffle ( array ) 将一个数组随机打乱,返回一个新的数组

}) // true
this.$utils.some([{a: 11}, {a: 22}]], (item, key) => {
return item.a === 11
}) // true
```

@@ -489,6 +436,2 @@ #### every ( obj, iteratee, context ) 对象中的值中的每一项运行给定函数,如果该函数对每一项都返回true,则返回true,否则返回false

}) // true
this.$utils.every([{a: 11}, {a: 22}]], (item, key) => {
return item.a === 11 || item.a === 22
}) // true
```

@@ -502,6 +445,2 @@ #### filter ( obj, iteratee, context ) 根据回调过滤数据

}) // [{a: 22}]
this.$utils.filter([{a: 11}, {a: 22}]], (item, key) => {
return item.a > 11
}) // [{a: 22}]
```

@@ -518,6 +457,2 @@ #### find ( obj, iteratee, context ) 查找匹配第一条数据

}) // {a: 22}
this.$utils.find([{a: 11}, {a: 22}]], (item, key) => {
return item.a === 22
}) // {a: 22}
```

@@ -531,6 +466,2 @@ #### map ( obj, iteratee, context ) 指定方法后的返回值组成的新数组

}) // [11, 22]
this.$utils.map([{a: 11}, {a: 22}]], (item, key) => {
return item.a
}) // [11, 22]
```

@@ -634,6 +565,2 @@

}) // {a: 11}
this.$utils.min([{a: 11}, {a: 44}], (item) => {
return item.a
}) // {a: 11}
```

@@ -649,6 +576,2 @@ #### max ( arr, iteratee ) 获取最大值

}) // {a: 44}
this.$utils.max([{a: 11}, {a: 44}], (item) => {
return item.a
}) // {a: 44}
```

@@ -655,0 +578,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc