1
This commit is contained in:
21
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/LICENSE
Normal file
21
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Xu Liangzhan
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
123
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/README.md
Normal file
123
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/README.md
Normal file
@@ -0,0 +1,123 @@
|
||||
# xe-utils
|
||||
|
||||
[](https://gitee.com/x-extends/xe-utils/stargazers)
|
||||
[](https://www.npmjs.com/package/xe-utils)
|
||||
[](https://travis-ci.com/x-extends/xe-utils)
|
||||
[](http://npm-stat.com/charts.html?package=xe-utils)
|
||||
[](https://unpkg.com/xe-utils/dist/xe-utils.umd.min.js)
|
||||
[](LICENSE)
|
||||
|
||||
JavaScript 函数库、工具类
|
||||
|
||||
## Browser Support
|
||||
|
||||
 |  |  |  |  | 
|
||||
--- | --- | --- | --- | --- | --- |
|
||||
7+ ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 6+ ✔ |
|
||||
|
||||
## Docs
|
||||
|
||||
[To view the document](https://x-extends.github.io/xe-utils/) [查看文档](https://vxetable.cn/xe-utils)
|
||||
|
||||
## Installing
|
||||
|
||||
```shell
|
||||
npm install xe-utils
|
||||
```
|
||||
|
||||
Using nodejs
|
||||
|
||||
```javascript
|
||||
const XEUtils = require('xe-utils')
|
||||
```
|
||||
|
||||
Get on [unpkg](https://unpkg.com/xe-utils/) and [cdnjs](https://cdn.jsdelivr.net/npm/xe-utils/)
|
||||
|
||||
```HTML
|
||||
<script src="https://cdn.jsdelivr.net/npm/xe-utils"></script>
|
||||
```
|
||||
|
||||
### Import all methods
|
||||
|
||||
```javascript
|
||||
import _XEUtils_ from 'xe-utils'
|
||||
|
||||
XEUtils.toDateString(Date.now())
|
||||
// 2018-01-01 10:30:28
|
||||
XEUtils.toStringDate('2018-01-01 10:30:00')
|
||||
// Mon Jan 01 2018 10:30:00 GMT+0800 (中国标准时间)
|
||||
```
|
||||
|
||||
## Import on demand
|
||||
|
||||
这样按需引入方法,可以使体积达到最小
|
||||
单个导入,包的大小 gzip >≈ 60B+,按需导入
|
||||
|
||||
```javascript
|
||||
import each from 'xe-utils/each'
|
||||
import toDateString from 'xe-utils/toDateString'
|
||||
|
||||
each({ a: 11, b: 22, c: 33 }, function (item, key){
|
||||
console.log(item)
|
||||
})
|
||||
// 11
|
||||
// 22
|
||||
// 33
|
||||
toDateString(Date.now(), 'yyyy-MM-dd HH:mm:ss')
|
||||
// 2018-01-01 10:30:28
|
||||
```
|
||||
|
||||
```javascript
|
||||
import XEUtils from 'xe-utils/ctor'
|
||||
import each from 'xe-utils/each'
|
||||
import toDateString from 'xe-utils/toDateString'
|
||||
import toFixedNumber from 'xe-utils/toFixedNumber'
|
||||
|
||||
XEUtils.mixin({
|
||||
each,
|
||||
toDateString,
|
||||
toFixedNumber
|
||||
})
|
||||
XEUtils.toDateString(Date.now(), 'yyyy-MM-dd HH:mm:ss')
|
||||
// 2018-01-01 10:30:28
|
||||
```
|
||||
|
||||
按功能导入所有方法
|
||||
|
||||
```javascript
|
||||
import XEUtils from 'xe-utils/ctor'
|
||||
import objectMethods from 'xe-utils/object'
|
||||
import arrayMethods from 'xe-utils/array'
|
||||
import baseMethods from 'xe-utils/base'
|
||||
import numberMethods from 'xe-utils/number'
|
||||
import dateMethods from 'xe-utils/date'
|
||||
import stringMethods from 'xe-utils/string'
|
||||
import functionMethods from 'xe-utils/function'
|
||||
import urlMethods from 'xe-utils/url'
|
||||
import webMethods from 'xe-utils/web'
|
||||
|
||||
XEUtils.mixin(
|
||||
// Object
|
||||
objectMethods,
|
||||
// Array
|
||||
arrayMethods,
|
||||
// Base
|
||||
baseMethods,
|
||||
// Number
|
||||
numberMethods,
|
||||
// Date
|
||||
dateMethods,
|
||||
// String
|
||||
stringMethods,
|
||||
// Function
|
||||
functionMethods,
|
||||
// URL
|
||||
urlMethods,
|
||||
// Web
|
||||
webMethods
|
||||
)
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE) © 2017-present, Xu Liangzhan
|
||||
14
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/add.d.ts
vendored
Normal file
14
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/add.d.ts
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* 加法运算
|
||||
* @param num1 数值1
|
||||
* @param num2 数值2
|
||||
*/
|
||||
export declare function add(num1: number, num2: number): number;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
add: typeof add;
|
||||
}
|
||||
}
|
||||
|
||||
export default add
|
||||
15
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/add.js
Normal file
15
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/add.js
Normal file
@@ -0,0 +1,15 @@
|
||||
var helperNumberAdd = require('./helperNumberAdd')
|
||||
var toNumber = require('./toNumber')
|
||||
|
||||
/**
|
||||
* 加法运算
|
||||
*
|
||||
* @param { Number } num1 被加数
|
||||
* @param { Number } num2 加数
|
||||
* @return {Number}
|
||||
*/
|
||||
function add (num1, num2) {
|
||||
return helperNumberAdd(toNumber(num1), toNumber(num2))
|
||||
}
|
||||
|
||||
module.exports = add
|
||||
15
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/after.d.ts
vendored
Normal file
15
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/after.d.ts
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* 创建一个函数, 调用次数超过 count 次之后执行回调并将所有结果记住后返回
|
||||
* @param count 次数
|
||||
* @param callback 回调
|
||||
* @param context 上下文
|
||||
*/
|
||||
export declare function after<C>(count: number, callback: (this: C, ...args: any[]) => any, context?: C): (this: any,...args: any[]) => any;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
after: typeof after;
|
||||
}
|
||||
}
|
||||
|
||||
export default after
|
||||
25
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/after.js
Normal file
25
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/after.js
Normal file
@@ -0,0 +1,25 @@
|
||||
var slice = require('./slice')
|
||||
|
||||
/**
|
||||
* 创建一个函数, 调用次数超过 count 次之后执行回调并将所有结果记住后返回
|
||||
*
|
||||
* @param {Number} count 调用次数
|
||||
* @param {Function} callback 完成回调
|
||||
* @return {Object}
|
||||
*/
|
||||
function after (count, callback, context) {
|
||||
var runCount = 0
|
||||
var rests = []
|
||||
return function () {
|
||||
var args = arguments
|
||||
runCount++
|
||||
if (runCount <= count) {
|
||||
rests.push(args[0])
|
||||
}
|
||||
if (runCount >= count) {
|
||||
callback.apply(context, [rests].concat(slice(args)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = after
|
||||
35
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/array.d.ts
vendored
Normal file
35
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/array.d.ts
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
export * from './map'
|
||||
export * from './some'
|
||||
export * from './every'
|
||||
export * from './includeArrays'
|
||||
export * from './arrayEach'
|
||||
export * from './lastArrayEach'
|
||||
export * from './uniq'
|
||||
export * from './union'
|
||||
export * from './toArray'
|
||||
export * from './sortBy'
|
||||
export * from './orderBy'
|
||||
export * from './shuffle'
|
||||
export * from './sample'
|
||||
export * from './slice'
|
||||
export * from './filter'
|
||||
export * from './findKey'
|
||||
export * from './includes'
|
||||
export * from './find'
|
||||
export * from './reduce'
|
||||
export * from './copyWithin'
|
||||
export * from './chunk'
|
||||
export * from './zip'
|
||||
export * from './unzip'
|
||||
export * from './zipObject'
|
||||
export * from './pluck'
|
||||
export * from './invoke'
|
||||
export * from './toArrayTree'
|
||||
export * from './toTreeArray'
|
||||
export * from './findTree'
|
||||
export * from './eachTree'
|
||||
export * from './mapTree'
|
||||
export * from './filterTree'
|
||||
export * from './searchTree'
|
||||
export * from './arrayIndexOf'
|
||||
export * from './arrayLastIndexOf'
|
||||
81
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/array.js
Normal file
81
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/array.js
Normal file
@@ -0,0 +1,81 @@
|
||||
'use strict'
|
||||
|
||||
var map = require('./map')
|
||||
var some = require('./some')
|
||||
var every = require('./every')
|
||||
var includeArrays = require('./includeArrays')
|
||||
var arrayEach = require('./arrayEach')
|
||||
var lastArrayEach = require('./lastArrayEach')
|
||||
var uniq = require('./uniq')
|
||||
var union = require('./union')
|
||||
var toArray = require('./toArray')
|
||||
var sortBy = require('./sortBy')
|
||||
var orderBy = require('./orderBy')
|
||||
var shuffle = require('./shuffle')
|
||||
var sample = require('./sample')
|
||||
var slice = require('./slice')
|
||||
var filter = require('./filter')
|
||||
var findKey = require('./findKey')
|
||||
var includes = require('./includes')
|
||||
var find = require('./find')
|
||||
var findLast = require('./findLast')
|
||||
var reduce = require('./reduce')
|
||||
var copyWithin = require('./copyWithin')
|
||||
var chunk = require('./chunk')
|
||||
var zip = require('./zip')
|
||||
var unzip = require('./unzip')
|
||||
var zipObject = require('./zipObject')
|
||||
var flatten = require('./flatten')
|
||||
var pluck = require('./pluck')
|
||||
var invoke = require('./invoke')
|
||||
var toArrayTree = require('./toArrayTree')
|
||||
var toTreeArray = require('./toTreeArray')
|
||||
var findTree = require('./findTree')
|
||||
var eachTree = require('./eachTree')
|
||||
var mapTree = require('./mapTree')
|
||||
var filterTree = require('./filterTree')
|
||||
var searchTree = require('./searchTree')
|
||||
var arrayIndexOf = require('./arrayIndexOf')
|
||||
var arrayLastIndexOf = require('./arrayLastIndexOf')
|
||||
|
||||
var arrayExports = {
|
||||
uniq: uniq,
|
||||
union: union,
|
||||
sortBy: sortBy,
|
||||
orderBy: orderBy,
|
||||
shuffle: shuffle,
|
||||
sample: sample,
|
||||
some: some,
|
||||
every: every,
|
||||
slice: slice,
|
||||
filter: filter,
|
||||
find: find,
|
||||
findLast: findLast,
|
||||
findKey: findKey,
|
||||
includes: includes,
|
||||
arrayIndexOf: arrayIndexOf,
|
||||
arrayLastIndexOf: arrayLastIndexOf,
|
||||
map: map,
|
||||
reduce: reduce,
|
||||
copyWithin: copyWithin,
|
||||
chunk: chunk,
|
||||
zip: zip,
|
||||
unzip: unzip,
|
||||
zipObject: zipObject,
|
||||
flatten: flatten,
|
||||
toArray: toArray,
|
||||
includeArrays: includeArrays,
|
||||
pluck: pluck,
|
||||
invoke: invoke,
|
||||
arrayEach: arrayEach,
|
||||
lastArrayEach: lastArrayEach,
|
||||
toArrayTree: toArrayTree,
|
||||
toTreeArray: toTreeArray,
|
||||
findTree: findTree,
|
||||
eachTree: eachTree,
|
||||
mapTree: mapTree,
|
||||
filterTree: filterTree,
|
||||
searchTree: searchTree
|
||||
}
|
||||
|
||||
module.exports = arrayExports
|
||||
16
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/arrayEach.d.ts
vendored
Normal file
16
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/arrayEach.d.ts
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* 数组迭代器
|
||||
* @param list 对象
|
||||
* @param iterate 回调
|
||||
* @param context 上下文
|
||||
*/
|
||||
export declare function arrayEach<T, C>(list: T[] | ArrayLike<T>, iterate: (this: C, item: T, index: number, list: T[]) => void, context?: C): void;
|
||||
export declare function arrayEach<C>(obj: any[], iterate: (this: C, item: any, index: number, obj: any) => void, context?: C): void;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
arrayEach: typeof arrayEach;
|
||||
}
|
||||
}
|
||||
|
||||
export default arrayEach
|
||||
@@ -0,0 +1,13 @@
|
||||
function arrayEach (list, iterate, context) {
|
||||
if (list) {
|
||||
if (list.forEach) {
|
||||
list.forEach(iterate, context)
|
||||
} else {
|
||||
for (var index = 0, len = list.length; index < len; index++) {
|
||||
iterate.call(context, list[index], index, list)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = arrayEach
|
||||
15
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/arrayIndexOf.d.ts
vendored
Normal file
15
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/arrayIndexOf.d.ts
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* 返回数组第一个索引值
|
||||
* @param list 数组
|
||||
* @param val 值
|
||||
*/
|
||||
export declare function arrayIndexOf<T>(list: ArrayLike<T>, val: any): number;
|
||||
export declare function arrayIndexOf(list: any[], val: any): number;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
arrayIndexOf: typeof arrayIndexOf;
|
||||
}
|
||||
}
|
||||
|
||||
export default arrayIndexOf
|
||||
@@ -0,0 +1,12 @@
|
||||
function arrayIndexOf (list, val) {
|
||||
if (list.indexOf) {
|
||||
return list.indexOf(val)
|
||||
}
|
||||
for (var index = 0, len = list.length; index < len; index++) {
|
||||
if (val === list[index]) {
|
||||
return index
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = arrayIndexOf
|
||||
20
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/arrayLastIndexOf.d.ts
vendored
Normal file
20
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/arrayLastIndexOf.d.ts
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* 从最后开始的索引值,返回数组第一个索引值
|
||||
* @param list 数组
|
||||
* @param val 值
|
||||
*/
|
||||
export declare function arrayLastIndexOf<T>(list: ArrayLike<T>, val: any): number;
|
||||
export declare function arrayLastIndexOf(list: any[], val: any): number;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
/**
|
||||
* 从最后开始的索引值,返回数组第一个索引值
|
||||
* @param list 数组
|
||||
* @param val 值
|
||||
*/
|
||||
arrayLastIndexOf: typeof arrayLastIndexOf;
|
||||
}
|
||||
}
|
||||
|
||||
export default arrayLastIndexOf
|
||||
@@ -0,0 +1,13 @@
|
||||
function arrayLastIndexOf (list, val) {
|
||||
if (list.lastIndexOf) {
|
||||
return list.lastIndexOf(val)
|
||||
}
|
||||
for (var len = list.length - 1; len >= 0; len--) {
|
||||
if (val === list[len]) {
|
||||
return len
|
||||
}
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
module.exports = arrayLastIndexOf
|
||||
38
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/assign.d.ts
vendored
Normal file
38
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/assign.d.ts
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* 将一个或多个源对象复制到目标对象中
|
||||
* @param target 目标对象
|
||||
* @param source1 要从中复制属性的源对象
|
||||
*/
|
||||
export declare function assign<T, U>(target: T, source1: U): T & U;
|
||||
|
||||
/**
|
||||
* 将一个或多个源对象复制到目标对象中
|
||||
* @param target 目标对象
|
||||
* @param source1 要从中复制属性的源对象1
|
||||
* @param source2 要从中复制属性的源对象2
|
||||
*/
|
||||
export declare function assign<T, U, V>(target: T, source1: U, source2: V): T & U & V;
|
||||
|
||||
/**
|
||||
* 将一个或多个源对象复制到目标对象中
|
||||
* @param target 目标对象
|
||||
* @param source1 要从中复制属性的源对象1
|
||||
* @param source2 要从中复制属性的源对象2
|
||||
* @param source3 要从中复制属性的源对象3
|
||||
*/
|
||||
export declare function assign<T, U, V, W>(target: T, source1: U, source2: V, source3: W): T & U & V & W;
|
||||
|
||||
/**
|
||||
* 将一个或多个源对象复制到目标对象中
|
||||
* @param target 目标对象
|
||||
* @param sources 要从中复制属性的一个或多个源对象
|
||||
*/
|
||||
export declare function assign(target: any, ...sources: any[]): any;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
assign: typeof assign;
|
||||
}
|
||||
}
|
||||
|
||||
export default assign
|
||||
43
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/assign.js
Normal file
43
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/assign.js
Normal file
@@ -0,0 +1,43 @@
|
||||
var arrayEach = require('./arrayEach')
|
||||
var keys = require('./keys')
|
||||
var isArray = require('./isArray')
|
||||
var clone = require('./clone')
|
||||
|
||||
var objectAssignFns = Object.assign
|
||||
|
||||
function handleAssign (destination, args, isClone) {
|
||||
var len = args.length
|
||||
for (var source, index = 1; index < len; index++) {
|
||||
source = args[index]
|
||||
arrayEach(keys(args[index]), isClone ? function (key) {
|
||||
destination[key] = clone(source[key], isClone)
|
||||
} : function (key) {
|
||||
destination[key] = source[key]
|
||||
})
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
/**
|
||||
* 将一个或多个源对象复制到目标对象中
|
||||
*
|
||||
* @param {Object} target 目标对象
|
||||
* @param {...Object}
|
||||
* @return {Boolean}
|
||||
*/
|
||||
var assign = function (target) {
|
||||
if (target) {
|
||||
var args = arguments
|
||||
if (target === true) {
|
||||
if (args.length > 1) {
|
||||
target = isArray(target[1]) ? [] : {}
|
||||
return handleAssign(target, args, true)
|
||||
}
|
||||
} else {
|
||||
return objectAssignFns ? objectAssignFns.apply(Object, args) : handleAssign(target, args)
|
||||
}
|
||||
}
|
||||
return target
|
||||
}
|
||||
|
||||
module.exports = assign
|
||||
64
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/base.d.ts
vendored
Normal file
64
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/base.d.ts
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
export * from './hasOwnProp'
|
||||
export * from './isArray'
|
||||
export * from './isNull'
|
||||
export * from './isNaN'
|
||||
export * from './isUndefined'
|
||||
export * from './isFunction'
|
||||
export * from './isObject'
|
||||
export * from './isString'
|
||||
export * from './isPlainObject'
|
||||
export * from './isLeapYear'
|
||||
export * from './isDate'
|
||||
export * from './eqNull'
|
||||
export * from './each'
|
||||
export * from './forOf'
|
||||
export * from './lastForOf'
|
||||
export * from './indexOf'
|
||||
export * from './lastIndexOf'
|
||||
export * from './keys'
|
||||
export * from './values'
|
||||
export * from './clone'
|
||||
export * from './getSize'
|
||||
export * from './lastEach'
|
||||
export * from './remove'
|
||||
export * from './clear'
|
||||
export * from './isFinite'
|
||||
export * from './isFloat'
|
||||
export * from './isInteger'
|
||||
export * from './isBoolean'
|
||||
export * from './isNumber'
|
||||
export * from './isRegExp'
|
||||
export * from './isError'
|
||||
export * from './isTypeError'
|
||||
export * from './isEmpty'
|
||||
export * from './isSymbol'
|
||||
export * from './isArguments'
|
||||
export * from './isElement'
|
||||
export * from './isDocument'
|
||||
export * from './isWindow'
|
||||
export * from './isFormData'
|
||||
export * from './isMap'
|
||||
export * from './isWeakMap'
|
||||
export * from './isSet'
|
||||
export * from './isWeakSet'
|
||||
export * from './isMatch'
|
||||
export * from './isEqual'
|
||||
export * from './isEqualWith'
|
||||
export * from './getType'
|
||||
export * from './uniqueId'
|
||||
export * from './findIndexOf'
|
||||
export * from './findLastIndexOf'
|
||||
export * from './toStringJSON'
|
||||
export * from './toJSONString'
|
||||
export * from './entries'
|
||||
export * from './pick'
|
||||
export * from './omit'
|
||||
export * from './first'
|
||||
export * from './last'
|
||||
export * from './has'
|
||||
export * from './get'
|
||||
export * from './set'
|
||||
export * from './groupBy'
|
||||
export * from './countBy'
|
||||
export * from './range'
|
||||
export * from './destructuring'
|
||||
135
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/base.js
Normal file
135
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/base.js
Normal file
@@ -0,0 +1,135 @@
|
||||
'use strict'
|
||||
|
||||
var hasOwnProp = require('./hasOwnProp')
|
||||
var isArray = require('./isArray')
|
||||
var isNull = require('./isNull')
|
||||
var isNumberNaN = require('./isNaN')
|
||||
var isUndefined = require('./isUndefined')
|
||||
var isFunction = require('./isFunction')
|
||||
var isObject = require('./isObject')
|
||||
var isString = require('./isString')
|
||||
var isPlainObject = require('./isPlainObject')
|
||||
var isLeapYear = require('./isLeapYear')
|
||||
var isDate = require('./isDate')
|
||||
var eqNull = require('./eqNull')
|
||||
var each = require('./each')
|
||||
var forOf = require('./forOf')
|
||||
var lastForOf = require('./lastForOf')
|
||||
var indexOf = require('./indexOf')
|
||||
var lastIndexOf = require('./lastIndexOf')
|
||||
var keys = require('./keys')
|
||||
var values = require('./values')
|
||||
var clone = require('./clone')
|
||||
var getSize = require('./getSize')
|
||||
var lastEach = require('./lastEach')
|
||||
var remove = require('./remove')
|
||||
var clear = require('./clear')
|
||||
var isNumberFinite = require('./isFinite')
|
||||
var isFloat = require('./isFloat')
|
||||
var isInteger = require('./isInteger')
|
||||
var isBoolean = require('./isBoolean')
|
||||
var isNumber = require('./isNumber')
|
||||
var isRegExp = require('./isRegExp')
|
||||
var isError = require('./isError')
|
||||
var isTypeError = require('./isTypeError')
|
||||
var isEmpty = require('./isEmpty')
|
||||
var isSymbol = require('./isSymbol')
|
||||
var isArguments = require('./isArguments')
|
||||
var isElement = require('./isElement')
|
||||
var isDocument = require('./isDocument')
|
||||
var isWindow = require('./isWindow')
|
||||
var isFormData = require('./isFormData')
|
||||
var isMap = require('./isMap')
|
||||
var isWeakMap = require('./isWeakMap')
|
||||
var isSet = require('./isSet')
|
||||
var isWeakSet = require('./isWeakSet')
|
||||
var isMatch = require('./isMatch')
|
||||
var isEqual = require('./isEqual')
|
||||
var isEqualWith = require('./isEqualWith')
|
||||
var getType = require('./getType')
|
||||
var uniqueId = require('./uniqueId')
|
||||
var findIndexOf = require('./findIndexOf')
|
||||
var findLastIndexOf = require('./findLastIndexOf')
|
||||
var toStringJSON = require('./toStringJSON')
|
||||
var toJSONString = require('./toJSONString')
|
||||
var entries = require('./entries')
|
||||
var pick = require('./pick')
|
||||
var omit = require('./omit')
|
||||
var first = require('./first')
|
||||
var last = require('./last')
|
||||
var has = require('./has')
|
||||
var get = require('./get')
|
||||
var set = require('./set')
|
||||
var groupBy = require('./groupBy')
|
||||
var countBy = require('./countBy')
|
||||
var range = require('./range')
|
||||
var destructuring = require('./destructuring')
|
||||
|
||||
var baseExports = {
|
||||
hasOwnProp: hasOwnProp,
|
||||
eqNull: eqNull,
|
||||
isNaN: isNumberNaN,
|
||||
isFinite: isNumberFinite,
|
||||
isUndefined: isUndefined,
|
||||
isArray: isArray,
|
||||
isFloat: isFloat,
|
||||
isInteger: isInteger,
|
||||
isFunction: isFunction,
|
||||
isBoolean: isBoolean,
|
||||
isString: isString,
|
||||
isNumber: isNumber,
|
||||
isRegExp: isRegExp,
|
||||
isObject: isObject,
|
||||
isPlainObject: isPlainObject,
|
||||
isDate: isDate,
|
||||
isError: isError,
|
||||
isTypeError: isTypeError,
|
||||
isEmpty: isEmpty,
|
||||
isNull: isNull,
|
||||
isSymbol: isSymbol,
|
||||
isArguments: isArguments,
|
||||
isElement: isElement,
|
||||
isDocument: isDocument,
|
||||
isWindow: isWindow,
|
||||
isFormData: isFormData,
|
||||
isMap: isMap,
|
||||
isWeakMap: isWeakMap,
|
||||
isSet: isSet,
|
||||
isWeakSet: isWeakSet,
|
||||
isLeapYear: isLeapYear,
|
||||
isMatch: isMatch,
|
||||
isEqual: isEqual,
|
||||
isEqualWith: isEqualWith,
|
||||
getType: getType,
|
||||
uniqueId: uniqueId,
|
||||
getSize: getSize,
|
||||
indexOf: indexOf,
|
||||
lastIndexOf: lastIndexOf,
|
||||
findIndexOf: findIndexOf,
|
||||
findLastIndexOf: findLastIndexOf,
|
||||
toStringJSON: toStringJSON,
|
||||
toJSONString: toJSONString,
|
||||
keys: keys,
|
||||
values: values,
|
||||
entries: entries,
|
||||
pick: pick,
|
||||
omit: omit,
|
||||
first: first,
|
||||
last: last,
|
||||
each: each,
|
||||
forOf: forOf,
|
||||
lastForOf: lastForOf,
|
||||
lastEach: lastEach,
|
||||
has: has,
|
||||
get: get,
|
||||
set: set,
|
||||
groupBy: groupBy,
|
||||
countBy: countBy,
|
||||
clone: clone,
|
||||
clear: clear,
|
||||
remove: remove,
|
||||
range: range,
|
||||
destructuring: destructuring
|
||||
}
|
||||
|
||||
module.exports = baseExports
|
||||
15
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/before.d.ts
vendored
Normal file
15
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/before.d.ts
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* 创建一个函数, 调用次数不超过 count 次之前执行回调并将所有结果记住后返回
|
||||
* @param count 次数
|
||||
* @param callback 回调
|
||||
* @param context 上下文
|
||||
*/
|
||||
export declare function before<C>(count: number, callback: (this: C, rests: any[], ...args: any[]) => any, context?: C): (this: any, ...args: any[]) => any;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
before: typeof before;
|
||||
}
|
||||
}
|
||||
|
||||
export default before
|
||||
24
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/before.js
Normal file
24
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/before.js
Normal file
@@ -0,0 +1,24 @@
|
||||
var slice = require('./slice')
|
||||
|
||||
/**
|
||||
* 创建一个函数, 调用次数不超过 count 次之前执行回调并将所有结果记住后返回
|
||||
*
|
||||
* @param {Number} count 调用次数
|
||||
* @param {Function} callback 完成回调
|
||||
* @return {Object}
|
||||
*/
|
||||
function before (count, callback, context) {
|
||||
var runCount = 0
|
||||
var rests = []
|
||||
context = context || this
|
||||
return function () {
|
||||
var args = arguments
|
||||
runCount++
|
||||
if (runCount < count) {
|
||||
rests.push(args[0])
|
||||
callback.apply(context, [rests].concat(slice(args)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = before
|
||||
15
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/bind.d.ts
vendored
Normal file
15
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/bind.d.ts
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* 创建一个绑定上下文的函数
|
||||
* @param callback 回调
|
||||
* @param context 上下文
|
||||
* @param params 额外的参数
|
||||
*/
|
||||
export declare function bind<C>(callback: (this: C, ...args: any[]) => any, context?: C, ...params: any[]): (this: any, ...args: any[]) => any;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
bind: typeof bind;
|
||||
}
|
||||
}
|
||||
|
||||
export default bind
|
||||
18
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/bind.js
Normal file
18
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/bind.js
Normal file
@@ -0,0 +1,18 @@
|
||||
var slice = require('./slice')
|
||||
|
||||
/**
|
||||
* 创建一个绑定上下文的函数
|
||||
*
|
||||
* @param {Function} callback 函数
|
||||
* @param {Object} context 上下文
|
||||
* @param {*} args 额外的参数
|
||||
* @return {Object}
|
||||
*/
|
||||
function bind (callback, context) {
|
||||
var args = slice(arguments, 2)
|
||||
return function () {
|
||||
return callback.apply(context, slice(arguments).concat(args))
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = bind
|
||||
71
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/browse.d.ts
vendored
Normal file
71
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/browse.d.ts
vendored
Normal file
@@ -0,0 +1,71 @@
|
||||
export interface XEBrowse {
|
||||
/**
|
||||
* 判断是否 NodeJs 环境
|
||||
*/
|
||||
isNode: boolean;
|
||||
/**
|
||||
* 判断是否有 document 元素
|
||||
*/
|
||||
isDoc: boolean;
|
||||
/**
|
||||
* 判断是否 Edge 浏览器
|
||||
*/
|
||||
edge: boolean;
|
||||
/**
|
||||
* 判断是否 Firefox 浏览器
|
||||
*/
|
||||
firefox: boolean;
|
||||
/**
|
||||
* 判断是否 IE 浏览器
|
||||
*/
|
||||
msie: boolean;
|
||||
/**
|
||||
* 判断是否 Safari 浏览器
|
||||
*/
|
||||
safari: boolean;
|
||||
/**
|
||||
* 判断是否移动端
|
||||
*/
|
||||
isMobile: boolean;
|
||||
/**
|
||||
* 判断是否 PC 端
|
||||
*/
|
||||
isPC: boolean;
|
||||
/**
|
||||
* 判断浏览器是否支持 LocalStorage
|
||||
*/
|
||||
isLocalStorage: boolean;
|
||||
/**
|
||||
* 判断浏览器是否支持 SessionStorage
|
||||
*/
|
||||
isSessionStorage: boolean;
|
||||
/**
|
||||
* 判断浏览器是否 -webkit 内核
|
||||
*/
|
||||
'-webkit': boolean;
|
||||
/**
|
||||
* 判断浏览器是否 -moz 内核
|
||||
*/
|
||||
'-moz': boolean;
|
||||
/**
|
||||
* 判断浏览器是否 -ms 内核
|
||||
*/
|
||||
'-ms': boolean;
|
||||
/**
|
||||
* 判断浏览器是否 -o 内核
|
||||
*/
|
||||
'-o': boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取浏览器信息
|
||||
*/
|
||||
export declare function browse(): XEBrowse;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
browse: typeof browse;
|
||||
}
|
||||
}
|
||||
|
||||
export default browse
|
||||
63
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/browse.js
Normal file
63
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/browse.js
Normal file
@@ -0,0 +1,63 @@
|
||||
var staticStrUndefined = require('./staticStrUndefined')
|
||||
var staticDocument = require('./staticDocument')
|
||||
var staticWindow = require('./staticWindow')
|
||||
|
||||
var assign = require('./assign')
|
||||
var arrayEach = require('./arrayEach')
|
||||
|
||||
/* eslint-disable valid-typeof */
|
||||
function isBrowseStorage (storage) {
|
||||
try {
|
||||
var testKey = '__xe_t'
|
||||
storage.setItem(testKey, 1)
|
||||
storage.removeItem(testKey)
|
||||
return true
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
function isBrowseType (type) {
|
||||
return navigator.userAgent.indexOf(type) > -1
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取浏览器内核
|
||||
* @return Object
|
||||
*/
|
||||
function browse () {
|
||||
var $body, isChrome, isEdge
|
||||
var isMobile = false
|
||||
var result = {
|
||||
isNode: false,
|
||||
isMobile: isMobile,
|
||||
isPC: false,
|
||||
isDoc: !!staticDocument
|
||||
}
|
||||
if (!staticWindow && typeof process !== staticStrUndefined) {
|
||||
result.isNode = true
|
||||
} else {
|
||||
isEdge = isBrowseType('Edge')
|
||||
isChrome = isBrowseType('Chrome')
|
||||
isMobile = /(Android|webOS|iPhone|iPad|iPod|SymbianOS|BlackBerry|Windows Phone)/.test(navigator.userAgent)
|
||||
if (result.isDoc) {
|
||||
$body = staticDocument.body || staticDocument.documentElement
|
||||
arrayEach(['webkit', 'khtml', 'moz', 'ms', 'o'], function (core) {
|
||||
result['-' + core] = !!$body[core + 'MatchesSelector']
|
||||
})
|
||||
}
|
||||
assign(result, {
|
||||
edge: isEdge,
|
||||
firefox: isBrowseType('Firefox'),
|
||||
msie: !isEdge && result['-ms'],
|
||||
safari: !isChrome && !isEdge && isBrowseType('Safari'),
|
||||
isMobile: isMobile,
|
||||
isPC: !isMobile,
|
||||
isLocalStorage: isBrowseStorage(staticWindow.localStorage),
|
||||
isSessionStorage: isBrowseStorage(staticWindow.sessionStorage)
|
||||
})
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
module.exports = browse
|
||||
13
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/camelCase.d.ts
vendored
Normal file
13
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/camelCase.d.ts
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* 将带字符串转成驼峰字符串,例如: project-name 转为 projectName
|
||||
* @param str 字符串
|
||||
*/
|
||||
export declare function camelCase(str: string): string;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
camelCase: typeof camelCase;
|
||||
}
|
||||
}
|
||||
|
||||
export default camelCase
|
||||
@@ -0,0 +1,45 @@
|
||||
var toValueString = require('./toValueString')
|
||||
var helperStringSubstring = require('./helperStringSubstring')
|
||||
var helperStringUpperCase = require('./helperStringUpperCase')
|
||||
var helperStringLowerCase = require('./helperStringLowerCase')
|
||||
|
||||
var camelCacheMaps = {}
|
||||
|
||||
/**
|
||||
* 将带字符串转成驼峰字符串,例如: project-name 转为 projectName
|
||||
*
|
||||
* @param {String} str 字符串
|
||||
* @return {String}
|
||||
*/
|
||||
function camelCase (str) {
|
||||
str = toValueString(str)
|
||||
if (camelCacheMaps[str]) {
|
||||
return camelCacheMaps[str]
|
||||
}
|
||||
var strLen = str.length
|
||||
var rest = str.replace(/([-]+)/g, function (text, flag, index) {
|
||||
return index && index + flag.length < strLen ? '-' : ''
|
||||
})
|
||||
strLen = rest.length
|
||||
rest = rest.replace(/([A-Z]+)/g, function (text, upper, index) {
|
||||
var upperLen = upper.length
|
||||
upper = helperStringLowerCase(upper)
|
||||
if (index) {
|
||||
if (upperLen > 2 && index + upperLen < strLen) {
|
||||
return helperStringUpperCase(helperStringSubstring(upper, 0, 1)) + helperStringSubstring(upper, 1, upperLen - 1) + helperStringUpperCase(helperStringSubstring(upper, upperLen - 1, upperLen))
|
||||
}
|
||||
return helperStringUpperCase(helperStringSubstring(upper, 0, 1)) + helperStringSubstring(upper, 1, upperLen)
|
||||
} else {
|
||||
if (upperLen > 1 && index + upperLen < strLen) {
|
||||
return helperStringSubstring(upper, 0, upperLen - 1) + helperStringUpperCase(helperStringSubstring(upper, upperLen - 1, upperLen))
|
||||
}
|
||||
}
|
||||
return upper
|
||||
}).replace(/(-[a-zA-Z])/g, function (text, upper) {
|
||||
return helperStringUpperCase(helperStringSubstring(upper, 1, upper.length))
|
||||
})
|
||||
camelCacheMaps[str] = rest
|
||||
return rest
|
||||
}
|
||||
|
||||
module.exports = camelCase
|
||||
20
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/ceil.d.ts
vendored
Normal file
20
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/ceil.d.ts
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* 将数值向上舍入
|
||||
* @param num 数值/字符串
|
||||
*/
|
||||
export declare function ceil(num: string | number): number;
|
||||
|
||||
/**
|
||||
* 将数值向上舍入
|
||||
* @param num 数值/字符串
|
||||
* @param digits 小数保留位数
|
||||
*/
|
||||
export declare function ceil(num: string | number, digits: number): number;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
ceil: typeof ceil;
|
||||
}
|
||||
}
|
||||
|
||||
export default ceil
|
||||
12
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/ceil.js
Normal file
12
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/ceil.js
Normal file
@@ -0,0 +1,12 @@
|
||||
var helperCreateMathNumber = require('./helperCreateMathNumber')
|
||||
|
||||
/**
|
||||
* 将数值向上舍入
|
||||
*
|
||||
* @param {string|number} num 数值
|
||||
* @param {number} digits 小数保留位数
|
||||
* @return {number}
|
||||
*/
|
||||
var ceil = helperCreateMathNumber('ceil')
|
||||
|
||||
module.exports = ceil
|
||||
14
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/chunk.d.ts
vendored
Normal file
14
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/chunk.d.ts
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* 将一个数组分割成大小的组。如果数组不能被平均分配,那么最后一块将是剩下的元素
|
||||
* @param array 数组
|
||||
* @param size 每组大小
|
||||
*/
|
||||
export declare function chunk<T>(array: T[], size: number): T[][];
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
chunk: typeof chunk;
|
||||
}
|
||||
}
|
||||
|
||||
export default chunk
|
||||
28
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/chunk.js
Normal file
28
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/chunk.js
Normal file
@@ -0,0 +1,28 @@
|
||||
var isArray = require('./isArray')
|
||||
|
||||
/**
|
||||
* 将一个数组分割成大小的组。如果数组不能被平均分配,那么最后一块将是剩下的元素
|
||||
*
|
||||
* @param {Array} array 数组
|
||||
* @param {Number} size 每组大小
|
||||
* @return {Array}
|
||||
*/
|
||||
function chunk (array, size) {
|
||||
var index
|
||||
var result = []
|
||||
var arrLen = size >> 0 || 1
|
||||
if (isArray(array)) {
|
||||
if (arrLen >= 0 && array.length > arrLen) {
|
||||
index = 0
|
||||
while (index < array.length) {
|
||||
result.push(array.slice(index, index + arrLen))
|
||||
index += arrLen
|
||||
}
|
||||
} else {
|
||||
result = array.length ? [array] : array
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
module.exports = chunk
|
||||
28
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/clear.d.ts
vendored
Normal file
28
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/clear.d.ts
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* 清空对象; defs如果不传(清空所有属性)、如果传对象(清空并继承)、如果传值(给所有赋值)
|
||||
* @param obj 对象
|
||||
*/
|
||||
export declare function clear<T>(obj: T): T;
|
||||
|
||||
/**
|
||||
* 清空对象; defs如果不传(清空所有属性)、如果传对象(清空并继承)、如果传值(给所有赋值)
|
||||
* @param obj 对象
|
||||
* @param defs 默认值
|
||||
*/
|
||||
export declare function clear<T>(obj: T, defs: any): T;
|
||||
|
||||
/**
|
||||
* 清空对象; defs如果不传(清空所有属性)、如果传对象(清空并继承)、如果传值(给所有赋值)
|
||||
* @param obj 对象
|
||||
* @param defs 默认值
|
||||
* @param assigns 值
|
||||
*/
|
||||
export declare function clear<T, U>(obj: T, defs: any, assigns: U): T & U;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
clear: typeof clear;
|
||||
}
|
||||
}
|
||||
|
||||
export default clear
|
||||
50
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/clear.js
Normal file
50
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/clear.js
Normal file
@@ -0,0 +1,50 @@
|
||||
var helperDeleteProperty = require('./helperDeleteProperty')
|
||||
|
||||
var isPlainObject = require('./isPlainObject')
|
||||
var isObject = require('./isObject')
|
||||
var isArray = require('./isArray')
|
||||
var isNull = require('./isNull')
|
||||
var assign = require('./assign')
|
||||
var objectEach = require('./objectEach')
|
||||
|
||||
/**
|
||||
* 清空对象
|
||||
*
|
||||
* @param {Object} obj 对象
|
||||
* @param {*} defs 默认值,如果不传(清空所有属性)、如果传对象(清空并继承)、如果传值(给所有赋值)
|
||||
* @param {Object/Array} assigns 默认值
|
||||
* @return {Object}
|
||||
*/
|
||||
function clear (obj, defs, assigns) {
|
||||
if (obj) {
|
||||
var len
|
||||
var isDefs = arguments.length > 1 && (isNull(defs) || !isObject(defs))
|
||||
var extds = isDefs ? assigns : defs
|
||||
if (isPlainObject(obj)) {
|
||||
objectEach(obj, isDefs ? function (val, key) {
|
||||
obj[key] = defs
|
||||
} : function (val, key) {
|
||||
helperDeleteProperty(obj, key)
|
||||
})
|
||||
if (extds) {
|
||||
assign(obj, extds)
|
||||
}
|
||||
} else if (isArray(obj)) {
|
||||
if (isDefs) {
|
||||
len = obj.length
|
||||
while (len > 0) {
|
||||
len--
|
||||
obj[len] = defs
|
||||
}
|
||||
} else {
|
||||
obj.length = 0
|
||||
}
|
||||
if (extds) {
|
||||
obj.push.apply(obj, extds)
|
||||
}
|
||||
}
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
module.exports = clear
|
||||
20
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/clone.d.ts
vendored
Normal file
20
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/clone.d.ts
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* 浅拷贝/深拷贝
|
||||
* @param obj 对象
|
||||
*/
|
||||
export declare function clone<T>(obj: T): T;
|
||||
|
||||
/**
|
||||
* 浅拷贝/深拷贝
|
||||
* @param obj 对象
|
||||
* @param deep 是否深拷贝
|
||||
*/
|
||||
export declare function clone<T>(obj: T, deep: boolean): T;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
clone: typeof clone;
|
||||
}
|
||||
}
|
||||
|
||||
export default clone
|
||||
70
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/clone.js
Normal file
70
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/clone.js
Normal file
@@ -0,0 +1,70 @@
|
||||
var objectToString = require('./staticObjectToString')
|
||||
|
||||
var objectEach = require('./objectEach')
|
||||
var arrayEach = require('./arrayEach')
|
||||
|
||||
function getCativeCtor (val, args) {
|
||||
var Ctor = val.__proto__.constructor
|
||||
return args ? new Ctor(args) : new Ctor()
|
||||
}
|
||||
|
||||
function handleValueClone (item, isDeep) {
|
||||
return isDeep ? copyValue(item, isDeep) : item
|
||||
}
|
||||
|
||||
function copyValue (val, isDeep) {
|
||||
if (val) {
|
||||
switch(objectToString.call(val)) {
|
||||
case "[object Object]": {
|
||||
var restObj = Object.create(val.__proto__)
|
||||
objectEach(val, function (item, key) {
|
||||
restObj[key] = handleValueClone(item, isDeep)
|
||||
})
|
||||
return restObj
|
||||
}
|
||||
case "[object Date]":
|
||||
case "[object RegExp]": {
|
||||
return getCativeCtor(val, val.valueOf())
|
||||
}
|
||||
case "[object Array]":
|
||||
case "[object Arguments]": {
|
||||
var restArr = []
|
||||
arrayEach(val, function (item) {
|
||||
restArr.push(handleValueClone(item, isDeep))
|
||||
})
|
||||
return restArr
|
||||
}
|
||||
case "[object Set]": {
|
||||
var restSet = getCativeCtor(val)
|
||||
restSet.forEach(function (item) {
|
||||
restSet.add(handleValueClone(item, isDeep))
|
||||
})
|
||||
return restSet
|
||||
}
|
||||
case "[object Map]": {
|
||||
var restMap = getCativeCtor(val)
|
||||
restMap.forEach(function (item, key) {
|
||||
restMap.set(key, handleValueClone(item, isDeep))
|
||||
})
|
||||
return restMap
|
||||
}
|
||||
}
|
||||
}
|
||||
return val
|
||||
}
|
||||
|
||||
/**
|
||||
* 浅拷贝/深拷贝
|
||||
*
|
||||
* @param {Object} obj 对象/数组
|
||||
* @param {Boolean} deep 是否深拷贝
|
||||
* @return {Object}
|
||||
*/
|
||||
function clone (obj, deep) {
|
||||
if (obj) {
|
||||
return copyValue(obj, deep)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
module.exports = clone
|
||||
41
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/commafy.d.ts
vendored
Normal file
41
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/commafy.d.ts
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
export interface CommafyOptions {
|
||||
/**
|
||||
* 分割位数,默认3
|
||||
*/
|
||||
spaceNumber?: number;
|
||||
/**
|
||||
* 分隔符,默认','
|
||||
*/
|
||||
separator?: string;
|
||||
/**
|
||||
* 只对 number 类型有效,小数位数,默认null
|
||||
*/
|
||||
digits?: number;
|
||||
/**
|
||||
* 只对 number 类型有效,四舍五入,默认true
|
||||
*/
|
||||
round?: boolean;
|
||||
/**
|
||||
* 只对 number 类型有效,向上舍入
|
||||
*/
|
||||
ceil?: boolean;
|
||||
/**
|
||||
* 只对 number 类型有效,向下舍入
|
||||
*/
|
||||
floor?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数值千分位分隔符、小数点
|
||||
* @param num 数值/字符串
|
||||
* @param options 可选参数
|
||||
*/
|
||||
export declare function commafy(num: string | number, options?: CommafyOptions): string;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
commafy: typeof commafy;
|
||||
}
|
||||
}
|
||||
|
||||
export default commafy
|
||||
@@ -0,0 +1,46 @@
|
||||
var setupDefaults = require('./setupDefaults')
|
||||
|
||||
var round = require('./round')
|
||||
var ceil = require('./ceil')
|
||||
var floor = require('./floor')
|
||||
|
||||
var isNumber = require('./isNumber')
|
||||
var toValueString = require('./toValueString')
|
||||
var toFixed = require('./toFixed')
|
||||
|
||||
var toNumberString = require('./toNumberString')
|
||||
var assign = require('./assign')
|
||||
|
||||
/**
|
||||
* 千分位分隔符、小数点
|
||||
*
|
||||
* @param {String/Number} num 数值
|
||||
* @param {CommafyOptions} options 参数
|
||||
* @return {String}
|
||||
*/
|
||||
function commafy(num, options) {
|
||||
var opts = assign({}, setupDefaults.commafyOptions, options)
|
||||
var optDigits = opts.digits
|
||||
var isNum = isNumber(num)
|
||||
var rest, result, isNegative, intStr, floatStr
|
||||
if (isNum) {
|
||||
rest = (opts.ceil ? ceil : (opts.floor ? floor : round))(num, optDigits)
|
||||
result = toNumberString(optDigits ? toFixed(rest, optDigits) : rest).split('.')
|
||||
intStr = result[0]
|
||||
floatStr = result[1]
|
||||
isNegative = intStr && rest < 0
|
||||
if (isNegative) {
|
||||
intStr = intStr.substring(1, intStr.length)
|
||||
}
|
||||
} else {
|
||||
rest = toValueString(num).replace(/,/g, '')
|
||||
result = rest ? [rest] : []
|
||||
intStr = result[0]
|
||||
}
|
||||
if (result.length) {
|
||||
return (isNegative ? '-' : '') + intStr.replace(new RegExp('(?=(?!(\\b))(.{' + (opts.spaceNumber || 3) + '})+$)', 'g'), (opts.separator || ',')) + (floatStr ? ('.' + floatStr) : '')
|
||||
}
|
||||
return rest
|
||||
}
|
||||
|
||||
module.exports = commafy
|
||||
99
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/cookie.d.ts
vendored
Normal file
99
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/cookie.d.ts
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
export interface CookieOptions {
|
||||
/**
|
||||
* 键
|
||||
*/
|
||||
name?: string;
|
||||
/**
|
||||
* 值
|
||||
*/
|
||||
value?: string;
|
||||
/**
|
||||
* 路径
|
||||
*/
|
||||
path?: string;
|
||||
/**
|
||||
* 作用域
|
||||
*/
|
||||
domain?: string;
|
||||
/**
|
||||
* 设置为安全的,只能用https协议
|
||||
*/
|
||||
secure?: string;
|
||||
/**
|
||||
* 过期时间,可以指定日期或者字符串,默认天
|
||||
*/
|
||||
expires?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cookie 操作函数
|
||||
*/
|
||||
export declare function CookieFunc(): cookie;
|
||||
|
||||
/**
|
||||
* Cookie 操作函数
|
||||
* @param name 键/数组/对象
|
||||
*/
|
||||
export declare function CookieFunc(name: string): cookie;
|
||||
|
||||
/**
|
||||
* Cookie 操作函数
|
||||
* @param name 键/数组/对象
|
||||
* @param value 值
|
||||
*/
|
||||
export declare function CookieFunc(name: string, value: any): cookie;
|
||||
|
||||
/**
|
||||
* Cookie 操作函数
|
||||
* @param name 键/数组/对象
|
||||
* @param value 值
|
||||
* @param options 可选参数
|
||||
*/
|
||||
export declare function CookieFunc(name: string, value: any, options: CookieOptions): cookie;
|
||||
|
||||
export type cookie = typeof CookieFunc & {
|
||||
/**
|
||||
* 根据 name 判断 Cookie 是否存在
|
||||
* @param name 键
|
||||
*/
|
||||
has(name: string): boolean;
|
||||
|
||||
/**
|
||||
* 添加 Cookie
|
||||
* @param name 键
|
||||
* @param value 值
|
||||
* @param options 可选参数
|
||||
*/
|
||||
set(name: string, value: any, options?: CookieOptions): cookie;
|
||||
|
||||
/**
|
||||
* 根据 name 获取 Cookie
|
||||
* @param name 键
|
||||
*/
|
||||
get(name: string): string;
|
||||
|
||||
/**
|
||||
* 根据 name 删除 Cookie
|
||||
* @param name 键
|
||||
* @param options 可选参数
|
||||
*/
|
||||
remove(name: string, options?: CookieOptions): number;
|
||||
|
||||
/**
|
||||
* 获取 Cookie 所有键
|
||||
*/
|
||||
keys(): any[];
|
||||
|
||||
/**
|
||||
* 获取所有 Cookie
|
||||
*/
|
||||
getJSON(): any;
|
||||
}
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
cookie: cookie;
|
||||
}
|
||||
}
|
||||
|
||||
export default cookie
|
||||
150
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/cookie.js
Normal file
150
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/cookie.js
Normal file
@@ -0,0 +1,150 @@
|
||||
var setupDefaults = require('./setupDefaults')
|
||||
var staticDocument = require('./staticDocument')
|
||||
var staticDecodeURIComponent = require('./staticDecodeURIComponent')
|
||||
var staticEncodeURIComponent = require('./staticEncodeURIComponent')
|
||||
|
||||
var isArray = require('./isArray')
|
||||
var isObject = require('./isObject')
|
||||
var isDate = require('./isDate')
|
||||
var isUndefined = require('./isUndefined')
|
||||
var includes = require('./includes')
|
||||
var keys = require('./keys')
|
||||
|
||||
var assign = require('./assign')
|
||||
|
||||
var arrayEach = require('./arrayEach')
|
||||
|
||||
var helperNewDate = require('./helperNewDate')
|
||||
var helperGetDateTime = require('./helperGetDateTime')
|
||||
var getWhatYear = require('./getWhatYear')
|
||||
var getWhatMonth = require('./getWhatMonth')
|
||||
var getWhatDay = require('./getWhatDay')
|
||||
|
||||
function toCookieUnitTime (unit, expires) {
|
||||
var num = parseFloat(expires)
|
||||
var nowdate = helperNewDate()
|
||||
var time = helperGetDateTime(nowdate)
|
||||
switch (unit) {
|
||||
case 'y': return helperGetDateTime(getWhatYear(nowdate, num))
|
||||
case 'M': return helperGetDateTime(getWhatMonth(nowdate, num))
|
||||
case 'd': return helperGetDateTime(getWhatDay(nowdate, num))
|
||||
case 'h':
|
||||
case 'H': return time + num * 60 * 60 * 1000
|
||||
case 'm': return time + num * 60 * 1000
|
||||
case 's': return time + num * 1000
|
||||
}
|
||||
return time
|
||||
}
|
||||
|
||||
function toCookieUTCString (date) {
|
||||
return (isDate(date) ? date : new Date(date)).toUTCString()
|
||||
}
|
||||
|
||||
/**
|
||||
* cookie操作函数
|
||||
* @param {String/Array/Object} name 键/数组/对象
|
||||
* @param {String} value 值
|
||||
* @param {Object} options 参数
|
||||
* @param {String} name: 键
|
||||
* @param {Object} value: 值
|
||||
* @param {String} path: 路径
|
||||
* @param {String} domain: 作用域
|
||||
* @param {Boolean} secure: 设置为安全的,只能用https协议
|
||||
* @param {Number} expires: 过期时间,可以指定日期或者字符串,默认天
|
||||
*/
|
||||
function cookie (name, value, options) {
|
||||
if (staticDocument) {
|
||||
var opts, expires, values, result, cookies, keyIndex
|
||||
var inserts = []
|
||||
var args = arguments
|
||||
if (isArray(name)) {
|
||||
inserts = name
|
||||
} else if (args.length > 1) {
|
||||
inserts = [assign({ name: name, value: value }, options)]
|
||||
} else if (isObject(name)) {
|
||||
inserts = [name]
|
||||
}
|
||||
if (inserts.length > 0) {
|
||||
arrayEach(inserts, function (obj) {
|
||||
opts = assign({}, setupDefaults.cookies, obj)
|
||||
values = []
|
||||
if (opts.name) {
|
||||
expires = opts.expires
|
||||
values.push(staticEncodeURIComponent(opts.name) + '=' + staticEncodeURIComponent(isObject(opts.value) ? JSON.stringify(opts.value) : opts.value))
|
||||
if (expires) {
|
||||
if (isNaN(expires)) {
|
||||
// UTCString || Unit
|
||||
expires = expires.replace(/^([0-9]+)(y|M|d|H|h|m|s)$/, function (text, num, unit) {
|
||||
return toCookieUTCString(toCookieUnitTime(unit, num))
|
||||
})
|
||||
} else if (/^[0-9]{11,13}$/.test(expires) || isDate(expires)) {
|
||||
// Date || now
|
||||
expires = toCookieUTCString(expires)
|
||||
} else {
|
||||
// day
|
||||
expires = toCookieUTCString(toCookieUnitTime('d', expires))
|
||||
}
|
||||
opts.expires = expires
|
||||
}
|
||||
arrayEach(['expires', 'path', 'domain', 'secure'], function (key) {
|
||||
if (!isUndefined(opts[key])) {
|
||||
values.push(opts[key] && key === 'secure' ? key : (key + '=' + opts[key]))
|
||||
}
|
||||
})
|
||||
}
|
||||
staticDocument.cookie = values.join('; ')
|
||||
})
|
||||
return true
|
||||
} else {
|
||||
result = {}
|
||||
cookies = staticDocument.cookie
|
||||
if (cookies) {
|
||||
arrayEach(cookies.split('; '), function (val) {
|
||||
keyIndex = val.indexOf('=')
|
||||
result[staticDecodeURIComponent(val.substring(0, keyIndex))] = staticDecodeURIComponent(val.substring(keyIndex + 1) || '')
|
||||
})
|
||||
}
|
||||
return args.length === 1 ? result[name] : result
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
function hasCookieItem (value) {
|
||||
return includes(cookieKeys(), value)
|
||||
}
|
||||
|
||||
function getCookieItem (name) {
|
||||
return cookie(name)
|
||||
}
|
||||
|
||||
function setCookieItem (name, value, options) {
|
||||
cookie(name, value, options)
|
||||
return cookie
|
||||
}
|
||||
|
||||
function removeCookieItem (name, options) {
|
||||
cookie(name, '', assign({ expires: -1 }, setupDefaults.cookies, options))
|
||||
}
|
||||
|
||||
function cookieKeys () {
|
||||
return keys(cookie())
|
||||
}
|
||||
|
||||
function cookieJson () {
|
||||
return cookie()
|
||||
}
|
||||
|
||||
assign(cookie, {
|
||||
has: hasCookieItem,
|
||||
set: setCookieItem,
|
||||
setItem: setCookieItem,
|
||||
get: getCookieItem,
|
||||
getItem: getCookieItem,
|
||||
remove: removeCookieItem,
|
||||
removeItem: removeCookieItem,
|
||||
keys: cookieKeys,
|
||||
getJSON: cookieJson
|
||||
})
|
||||
|
||||
module.exports = cookie
|
||||
23
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/copyWithin.d.ts
vendored
Normal file
23
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/copyWithin.d.ts
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* 复制数组的一部分到同一数组中的另一个位置,数组大小不变
|
||||
* @param array 数组
|
||||
* @param target 从该位置开始替换数据
|
||||
*/
|
||||
export declare function copyWithin<T>(array: T[], target: number): T[];
|
||||
|
||||
/**
|
||||
* 复制数组的一部分到同一数组中的另一个位置,数组大小不变
|
||||
* @param array 数组
|
||||
* @param target 从该位置开始替换数据
|
||||
* @param start 从该位置开始读取数据,默认为 0 。如果为负值,表示倒数
|
||||
* @param end 到该位置前停止读取数据,默认等于数组长度。如果为负值,表示倒数
|
||||
*/
|
||||
export declare function copyWithin<T>(array: T[], target: number, start: Number, end?: number): T[];
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
copyWithin: typeof copyWithin;
|
||||
}
|
||||
}
|
||||
|
||||
export default copyWithin
|
||||
@@ -0,0 +1,39 @@
|
||||
var isArray = require('./isArray')
|
||||
|
||||
/**
|
||||
* 浅复制数组的一部分到同一数组中的另一个位置,数组大小不变
|
||||
*
|
||||
* @param {Array} array 数组
|
||||
* @param {Number} target 从该位置开始替换数据
|
||||
* @param {Number} start 从该位置开始读取数据,默认为 0 。如果为负值,表示倒数
|
||||
* @param {Number} end 到该位置前停止读取数据,默认等于数组长度。如果为负值,表示倒数
|
||||
* @return {Array}
|
||||
*/
|
||||
function copyWithin (array, target, start, end) {
|
||||
if (isArray(array) && array.copyWithin) {
|
||||
return array.copyWithin(target, start, end)
|
||||
}
|
||||
var replaceIndex, replaceArray
|
||||
var targetIndex = target >> 0
|
||||
var startIndex = start >> 0
|
||||
var len = array.length
|
||||
var endIndex = arguments.length > 3 ? end >> 0 : len
|
||||
if (targetIndex < len) {
|
||||
targetIndex = targetIndex >= 0 ? targetIndex : len + targetIndex
|
||||
if (targetIndex >= 0) {
|
||||
startIndex = startIndex >= 0 ? startIndex : len + startIndex
|
||||
endIndex = endIndex >= 0 ? endIndex : len + endIndex
|
||||
if (startIndex < endIndex) {
|
||||
for (replaceIndex = 0, replaceArray = array.slice(startIndex, endIndex); targetIndex < len; targetIndex++) {
|
||||
if (replaceArray.length <= replaceIndex) {
|
||||
break
|
||||
}
|
||||
array[targetIndex] = replaceArray[replaceIndex++]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return array
|
||||
}
|
||||
|
||||
module.exports = copyWithin
|
||||
23
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/countBy.d.ts
vendored
Normal file
23
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/countBy.d.ts
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* 集合分组统计,返回各组中对象的数量统计
|
||||
* @param list 对象
|
||||
* @param iterate 回调/属性
|
||||
* @param context 上下文
|
||||
*/
|
||||
export declare function countBy<T, C>(list: T[], iterate: string | number | ((this: C, item: T, index: number, list: T[]) => string | number), context?: C): { [key: string]: number };
|
||||
|
||||
/**
|
||||
* 集合分组统计,返回各组中对象的数量统计
|
||||
* @param obj 对象
|
||||
* @param iterate 回调/属性
|
||||
* @param context 上下文
|
||||
*/
|
||||
export declare function countBy<T, C>(obj: T, iterate: string | number | ((this: C, item: any, key: string, obj: T) => string | number), context?: C): { [key: string]: number };
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
countBy: typeof countBy;
|
||||
}
|
||||
}
|
||||
|
||||
export default countBy
|
||||
@@ -0,0 +1,21 @@
|
||||
var groupBy = require('./groupBy')
|
||||
|
||||
var objectEach = require('./objectEach')
|
||||
|
||||
/**
|
||||
* 集合分组统计,返回各组中对象的数量统计
|
||||
*
|
||||
* @param {Array} obj 对象
|
||||
* @param {Function} iterate 回调/对象属性
|
||||
* @param {Object} context 上下文
|
||||
* @return {Object}
|
||||
*/
|
||||
function countBy (obj, iterate, context) {
|
||||
var result = groupBy(obj, iterate, context || this)
|
||||
objectEach(result, function (item, key) {
|
||||
result[key] = item.length
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
module.exports = countBy
|
||||
33
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/ctor.d.ts
vendored
Normal file
33
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/ctor.d.ts
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
import SetupDefaults from './setupDefaults'
|
||||
|
||||
/**
|
||||
* 版本信息
|
||||
*/
|
||||
export const VERSION: string;
|
||||
|
||||
/**
|
||||
* 设置全局参数
|
||||
* @param options 全局参数
|
||||
*/
|
||||
export function setup(options: SetupDefaults): SetupDefaults;
|
||||
|
||||
/**
|
||||
* 将您自己的实用函数扩展到 XEUtils
|
||||
* @param methods 函数集
|
||||
*/
|
||||
export function mixin(...methods: {[key: string]: any}[]): void;
|
||||
|
||||
export interface XEUtilsMethods {
|
||||
VERSION: typeof VERSION;
|
||||
setup: typeof setup;
|
||||
mixin: typeof mixin;
|
||||
|
||||
[propertys: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* JavaScript 函数库、工具类
|
||||
*/
|
||||
declare var XEUtils: XEUtilsMethods
|
||||
|
||||
export default XEUtils
|
||||
33
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/ctor.js
Normal file
33
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/ctor.js
Normal file
@@ -0,0 +1,33 @@
|
||||
'use strict'
|
||||
|
||||
var setupDefaults = require('./setupDefaults')
|
||||
|
||||
var arrayEach = require('./arrayEach')
|
||||
var each = require('./each')
|
||||
var isFunction = require('./isFunction')
|
||||
|
||||
var assign = require('./assign')
|
||||
|
||||
var XEUtils = function () {}
|
||||
|
||||
function mixin () {
|
||||
arrayEach(arguments, function (methods) {
|
||||
each(methods, function (fn, name) {
|
||||
XEUtils[name] = isFunction(fn) ? function () {
|
||||
var result = fn.apply(XEUtils.$context, arguments)
|
||||
XEUtils.$context = null
|
||||
return result
|
||||
} : fn
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function setup (options) {
|
||||
return assign(setupDefaults, options)
|
||||
}
|
||||
|
||||
XEUtils.VERSION = '3.5.11'
|
||||
XEUtils.mixin = mixin
|
||||
XEUtils.setup = setup
|
||||
|
||||
module.exports = XEUtils
|
||||
17
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/date.d.ts
vendored
Normal file
17
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/date.d.ts
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
export * from './getWhatYear'
|
||||
export * from './getWhatQuarter'
|
||||
export * from './getWhatMonth'
|
||||
export * from './getWhatDay'
|
||||
export * from './toStringDate'
|
||||
export * from './toDateString'
|
||||
export * from './now'
|
||||
export * from './timestamp'
|
||||
export * from './isValidDate'
|
||||
export * from './isDateSame'
|
||||
export * from './getWhatWeek'
|
||||
export * from './getYearDay'
|
||||
export * from './getYearWeek'
|
||||
export * from './getMonthWeek'
|
||||
export * from './getDayOfYear'
|
||||
export * from './getDayOfMonth'
|
||||
export * from './getDateDiff'
|
||||
41
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/date.js
Normal file
41
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/date.js
Normal file
@@ -0,0 +1,41 @@
|
||||
'use strict'
|
||||
|
||||
var getWhatYear = require('./getWhatYear')
|
||||
var getWhatQuarter = require('./getWhatQuarter')
|
||||
var getWhatMonth = require('./getWhatMonth')
|
||||
var getWhatDay = require('./getWhatDay')
|
||||
var toStringDate = require('./toStringDate')
|
||||
var toDateString = require('./toDateString')
|
||||
var now = require('./now')
|
||||
var timestamp = require('./timestamp')
|
||||
var isValidDate = require('./isValidDate')
|
||||
var isDateSame = require('./isDateSame')
|
||||
var getWhatWeek = require('./getWhatWeek')
|
||||
var getYearDay = require('./getYearDay')
|
||||
var getYearWeek = require('./getYearWeek')
|
||||
var getMonthWeek = require('./getMonthWeek')
|
||||
var getDayOfYear = require('./getDayOfYear')
|
||||
var getDayOfMonth = require('./getDayOfMonth')
|
||||
var getDateDiff = require('./getDateDiff')
|
||||
|
||||
var dateExports = {
|
||||
now: now,
|
||||
timestamp: timestamp,
|
||||
isValidDate: isValidDate,
|
||||
isDateSame: isDateSame,
|
||||
toStringDate: toStringDate,
|
||||
toDateString: toDateString,
|
||||
getWhatYear: getWhatYear,
|
||||
getWhatQuarter: getWhatQuarter,
|
||||
getWhatMonth: getWhatMonth,
|
||||
getWhatWeek: getWhatWeek,
|
||||
getWhatDay: getWhatDay,
|
||||
getYearDay: getYearDay,
|
||||
getYearWeek: getYearWeek,
|
||||
getMonthWeek: getMonthWeek,
|
||||
getDayOfYear: getDayOfYear,
|
||||
getDayOfMonth: getDayOfMonth,
|
||||
getDateDiff: getDateDiff
|
||||
}
|
||||
|
||||
module.exports = dateExports
|
||||
26
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/debounce.d.ts
vendored
Normal file
26
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/debounce.d.ts
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
export interface DebounceOptions {
|
||||
/**
|
||||
* 是否在之前执行
|
||||
*/
|
||||
leading?: boolean;
|
||||
/**
|
||||
* 是否在之后执行
|
||||
*/
|
||||
trailing?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 函数去抖;当被调用 n 毫秒后才会执行,如果在这时间内又被调用则将重新计算执行时间
|
||||
* @param callback 回调
|
||||
* @param wait 毫秒
|
||||
* @param options 可选参数
|
||||
*/
|
||||
export declare function debounce<C>(callback: (this: C, ...args: any[]) => any, wait: number, options?: DebounceOptions): (this: C, ...args: any[]) => any;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
debounce: typeof debounce;
|
||||
}
|
||||
}
|
||||
|
||||
export default debounce
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* 函数去抖;当被调用 n 毫秒后才会执行,如果在这时间内又被调用则将重新计算执行时间
|
||||
*
|
||||
* @param {Function} callback 回调
|
||||
* @param {Number} wait 多少秒毫
|
||||
* @param {Object} options 参数{leading: 是否在之前执行, trailing: 是否在之后执行}
|
||||
* @return {Function}
|
||||
*/
|
||||
function debounce (callback, wait, options) {
|
||||
var args, context
|
||||
var opts = options || {}
|
||||
var runFlag = false
|
||||
var isDestroy = false
|
||||
var timeout = 0
|
||||
var isLeading = typeof options === 'boolean'
|
||||
var optLeading = 'leading' in opts ? opts.leading : isLeading
|
||||
var optTrailing = 'trailing' in opts ? opts.trailing : !isLeading
|
||||
var runFn = function () {
|
||||
if (!isDestroy) {
|
||||
runFlag = true
|
||||
timeout = 0
|
||||
callback.apply(context, args)
|
||||
}
|
||||
}
|
||||
var endFn = function () {
|
||||
if (optLeading === true) {
|
||||
timeout = 0
|
||||
}
|
||||
if (!isDestroy && !runFlag && optTrailing === true) {
|
||||
runFn()
|
||||
}
|
||||
}
|
||||
var cancelFn = function () {
|
||||
var rest = timeout !== 0
|
||||
clearTimeout(timeout)
|
||||
args = null
|
||||
context = null
|
||||
timeout = 0
|
||||
return rest
|
||||
}
|
||||
var debounced = function () {
|
||||
runFlag = false
|
||||
args = arguments
|
||||
context = this
|
||||
if (timeout === 0) {
|
||||
if (optLeading === true) {
|
||||
runFn()
|
||||
}
|
||||
} else {
|
||||
clearTimeout(timeout)
|
||||
}
|
||||
timeout = setTimeout(endFn, wait)
|
||||
}
|
||||
debounced.cancel = cancelFn
|
||||
return debounced
|
||||
}
|
||||
|
||||
module.exports = debounce
|
||||
15
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/delay.d.ts
vendored
Normal file
15
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/delay.d.ts
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* 该方法和 setTimeout 一样的效果,区别就是支持上下文和额外参数
|
||||
* @param callback 回调
|
||||
* @param wait 延迟毫秒
|
||||
* @param params 额外的参数
|
||||
*/
|
||||
export declare function delay(callback: (...args: any[]) => any, wait: number, ...params: any[]): number;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
delay: typeof delay;
|
||||
}
|
||||
}
|
||||
|
||||
export default delay
|
||||
19
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/delay.js
Normal file
19
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/delay.js
Normal file
@@ -0,0 +1,19 @@
|
||||
var slice = require('./slice')
|
||||
|
||||
/**
|
||||
* 该方法和 setTimeout 一样的效果,区别就是支持上下文和额外参数
|
||||
*
|
||||
* @param {Function} callback 函数
|
||||
* @param {Number} wait 延迟毫秒
|
||||
* @param {*} args 额外的参数
|
||||
* @return {Number}
|
||||
*/
|
||||
function delay (callback, wait) {
|
||||
var args = slice(arguments, 2)
|
||||
var context = this
|
||||
return setTimeout(function () {
|
||||
callback.apply(context, args)
|
||||
}, wait)
|
||||
}
|
||||
|
||||
module.exports = delay
|
||||
14
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/destructuring.d.ts
vendored
Normal file
14
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/destructuring.d.ts
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* 将一个或者多个对象值解构到目标对象
|
||||
* @param obj 对象
|
||||
* @param target 目标
|
||||
*/
|
||||
export declare function destructuring<T>(obj: T, ...target: any[]): T;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
destructuring: typeof destructuring;
|
||||
}
|
||||
}
|
||||
|
||||
export default destructuring
|
||||
@@ -0,0 +1,29 @@
|
||||
var keys = require('./keys')
|
||||
|
||||
var slice = require('./slice')
|
||||
var includes = require('./includes')
|
||||
var arrayEach = require('./arrayEach')
|
||||
|
||||
var assign = require('./assign')
|
||||
|
||||
/**
|
||||
* 将一个或者多个对象值解构到目标对象
|
||||
*
|
||||
* @param {Object} destination 目标对象
|
||||
* @param {...Object}
|
||||
* @return {Boolean}
|
||||
*/
|
||||
function destructuring (destination, sources) {
|
||||
if (destination && sources) {
|
||||
var rest = assign.apply(this, [{}].concat(slice(arguments, 1)))
|
||||
var restKeys = keys(rest)
|
||||
arrayEach(keys(destination), function (key) {
|
||||
if (includes(restKeys, key)) {
|
||||
destination[key] = rest[key]
|
||||
}
|
||||
})
|
||||
}
|
||||
return destination
|
||||
}
|
||||
|
||||
module.exports = destructuring
|
||||
1979
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/dist/xe-utils.d.ts
vendored
Normal file
1979
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/dist/xe-utils.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
4828
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/dist/xe-utils.umd.js
vendored
Normal file
4828
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/dist/xe-utils.umd.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
6
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/dist/xe-utils.umd.min.js
vendored
Normal file
6
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/dist/xe-utils.umd.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
14
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/divide.d.ts
vendored
Normal file
14
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/divide.d.ts
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* 除法运算
|
||||
* @param num1 数值1
|
||||
* @param num2 数值2
|
||||
*/
|
||||
export declare function divide(num1: number, num2: number): number;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
divide: typeof divide;
|
||||
}
|
||||
}
|
||||
|
||||
export default divide
|
||||
15
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/divide.js
Normal file
15
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/divide.js
Normal file
@@ -0,0 +1,15 @@
|
||||
var helperNumberDivide = require('./helperNumberDivide')
|
||||
var toNumber = require('./toNumber')
|
||||
|
||||
/**
|
||||
* 除法运算
|
||||
*
|
||||
* @param { Number } num1 数值1
|
||||
* @param { Number } num2 数值2
|
||||
* @return {Number}
|
||||
*/
|
||||
function divide (num1, num2) {
|
||||
return helperNumberDivide(toNumber(num1), toNumber(num2))
|
||||
}
|
||||
|
||||
module.exports = divide
|
||||
23
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/each.d.ts
vendored
Normal file
23
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/each.d.ts
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* 通用迭代器
|
||||
* @param list 对象
|
||||
* @param iterate 回调
|
||||
* @param context 上下文
|
||||
*/
|
||||
export declare function each<T, C>(list: T[] | ArrayLike<T>, iterate: (this: C, item: T, index: number, list: T[]) => void, context?: CSSKeyframeRule): void;
|
||||
|
||||
/**
|
||||
* 通用迭代器
|
||||
* @param obj 对象
|
||||
* @param iterate 回调
|
||||
* @param context 上下文
|
||||
*/
|
||||
export declare function each<T, C>(obj: T, iterate: (this: C, item: any, key: string, obj: T) => void, context?: C): void;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
each: typeof each;
|
||||
}
|
||||
}
|
||||
|
||||
export default each
|
||||
20
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/each.js
Normal file
20
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/each.js
Normal file
@@ -0,0 +1,20 @@
|
||||
var isArray = require('./isArray')
|
||||
var arrayEach = require('./arrayEach')
|
||||
var objectEach = require('./objectEach')
|
||||
|
||||
/**
|
||||
* 迭代器
|
||||
*
|
||||
* @param {Object} obj 对象/数组
|
||||
* @param {Function} iterate(item, index, obj) 回调
|
||||
* @param {Object} context 上下文
|
||||
* @return {Object}
|
||||
*/
|
||||
function each (obj, iterate, context) {
|
||||
if (obj) {
|
||||
return (isArray(obj) ? arrayEach : objectEach)(obj, iterate, context)
|
||||
}
|
||||
return obj
|
||||
}
|
||||
|
||||
module.exports = each
|
||||
22
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/eachTree.d.ts
vendored
Normal file
22
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/eachTree.d.ts
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
export interface EachTreeOptions {
|
||||
children?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从树结构中遍历数据的键、值、路径
|
||||
* @param {Object} list 数组
|
||||
* @param {Function} iterate(item, index, items, path, parent, nodes) 回调
|
||||
* @param {Object} options {children: 'children'}
|
||||
* @param {Object} context 上下文
|
||||
*/
|
||||
export declare function eachTree<T, C>(list: T[], iterate: (this: C, item: T, index: number, items: T[], path: string[], parent: T, nodes: T[]) => void, options?: EachTreeOptions, context?: C): void;
|
||||
export declare function eachTree<C>(list: any[], iterate: (this: C, item: any, index: number, items: any[], path: string[], parent: any, nodes: any[]) => void, options?: EachTreeOptions, context?: C): void;
|
||||
export declare function eachTree<C>(list: any, iterate: (this: C, item: any, index: number, items: any, path: string[], parent: any, nodes: any) => void, options?: EachTreeOptions, context?: C): void;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
eachTree: typeof eachTree;
|
||||
}
|
||||
}
|
||||
|
||||
export default eachTree
|
||||
@@ -0,0 +1,27 @@
|
||||
var helperCreateTreeFunc = require('./helperCreateTreeFunc')
|
||||
var each = require('./each')
|
||||
|
||||
function eachTreeItem (parent, obj, iterate, context, path, node, parseChildren, opts) {
|
||||
var paths, nodes
|
||||
each(obj, function (item, index) {
|
||||
paths = path.concat(['' + index])
|
||||
nodes = node.concat([item])
|
||||
iterate.call(context, item, index, obj, paths, parent, nodes)
|
||||
if (item && parseChildren) {
|
||||
paths.push(parseChildren)
|
||||
eachTreeItem(item, item[parseChildren], iterate, context, paths, nodes, parseChildren, opts)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 从树结构中遍历数据的键、值、路径
|
||||
*
|
||||
* @param {Object} obj 对象/数组
|
||||
* @param {Function} iterate(item, index, items, path, parent, nodes) 回调
|
||||
* @param {Object} options {children: 'children', mapChildren: 'children}
|
||||
* @param {Object} context 上下文
|
||||
*/
|
||||
var eachTree = helperCreateTreeFunc(eachTreeItem)
|
||||
|
||||
module.exports = eachTree
|
||||
22
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/endsWith.d.ts
vendored
Normal file
22
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/endsWith.d.ts
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
/**
|
||||
* 判断字符串是否在源字符串的头部
|
||||
* @param str 字符串
|
||||
* @param val 值
|
||||
*/
|
||||
export declare function endsWith(str: string, val: string): string;
|
||||
|
||||
/**
|
||||
* 判断字符串是否在源字符串的头部
|
||||
* @param str 字符串
|
||||
* @param val 值
|
||||
* @param startIndex 开始索引
|
||||
*/
|
||||
export declare function endsWith(str: string, val: string, startIndex: number): string;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
endsWith: typeof endsWith;
|
||||
}
|
||||
}
|
||||
|
||||
export default endsWith
|
||||
@@ -0,0 +1,17 @@
|
||||
var toValueString = require('./toValueString')
|
||||
|
||||
/**
|
||||
* 判断字符串是否在源字符串的尾部
|
||||
*
|
||||
* @param {String} str 字符串
|
||||
* @param {String/Number} val 值
|
||||
* @param {Number} startIndex 开始索引
|
||||
* @return {String}
|
||||
*/
|
||||
function endsWith (str, val, startIndex) {
|
||||
var rest = toValueString(str)
|
||||
var argsLen = arguments.length
|
||||
return argsLen > 1 && (argsLen > 2 ? rest.substring(0, startIndex).indexOf(val) === startIndex - 1 : rest.indexOf(val) === rest.length - 1)
|
||||
}
|
||||
|
||||
module.exports = endsWith
|
||||
13
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/entries.d.ts
vendored
Normal file
13
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/entries.d.ts
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* 获取对象所有属性、值
|
||||
* @param obj 对象
|
||||
*/
|
||||
export declare function entries(obj: any): any[];
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
entries: typeof entries;
|
||||
}
|
||||
}
|
||||
|
||||
export default entries
|
||||
@@ -0,0 +1,11 @@
|
||||
var helperCreateGetObjects = require('./helperCreateGetObjects')
|
||||
|
||||
/**
|
||||
* 获取对象所有属性、值
|
||||
*
|
||||
* @param {Object} obj 对象/数组
|
||||
* @return {Array}
|
||||
*/
|
||||
var entries = helperCreateGetObjects('entries', 2)
|
||||
|
||||
module.exports = entries
|
||||
13
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/eqNull.d.ts
vendored
Normal file
13
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/eqNull.d.ts
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* 判断是否 undefined 和 null
|
||||
* @param obj 对象
|
||||
*/
|
||||
export declare function eqNull(obj: any): boolean;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
eqNull: typeof eqNull;
|
||||
}
|
||||
}
|
||||
|
||||
export default eqNull
|
||||
13
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/eqNull.js
Normal file
13
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/eqNull.js
Normal file
@@ -0,0 +1,13 @@
|
||||
var isNull = require('./isNull')
|
||||
var isUndefined = require('./isUndefined')
|
||||
|
||||
/**
|
||||
* 判断是否 undefined 和 null
|
||||
* @param {Object} obj 对象
|
||||
* @return {Boolean}
|
||||
*/
|
||||
function eqNull (obj) {
|
||||
return isNull(obj) || isUndefined(obj)
|
||||
}
|
||||
|
||||
module.exports = eqNull
|
||||
13
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/escape.d.ts
vendored
Normal file
13
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/escape.d.ts
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* 转义HTML字符串,替换&, <, >, ", ', \`字符
|
||||
* @param str 字符串
|
||||
*/
|
||||
export declare function escape(str: string): string;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
escape: typeof escape;
|
||||
}
|
||||
}
|
||||
|
||||
export default escape
|
||||
13
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/escape.js
Normal file
13
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/escape.js
Normal file
@@ -0,0 +1,13 @@
|
||||
var staticEscapeMap = require('./staticEscapeMap')
|
||||
|
||||
var helperFormatEscaper = require('./helperFormatEscaper')
|
||||
|
||||
/**
|
||||
* 转义HTML字符串,替换&, <, >, ", ', `字符
|
||||
*
|
||||
* @param {String} str 字符串
|
||||
* @return {String}
|
||||
*/
|
||||
var escape = helperFormatEscaper(staticEscapeMap)
|
||||
|
||||
module.exports = escape
|
||||
24
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/every.d.ts
vendored
Normal file
24
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/every.d.ts
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
/**
|
||||
* 对象中的值中的每一项运行给定函数,如果该函数对每一项都返回 true,则返回 true,否则返回 false
|
||||
* @param list 数组
|
||||
* @param iterate 回调
|
||||
* @param context 上下文
|
||||
*/
|
||||
export declare function every<T, C>(list: T[], iterate: (this: C, item: T, index: number, list: T[]) => boolean, context?: C): boolean;
|
||||
|
||||
/**
|
||||
* 对象中的值中的每一项运行给定函数,如果该函数对每一项都返回 true,则返回 true,否则返回 false
|
||||
* @param list 数组
|
||||
* @param iterate 回调
|
||||
* @param context 上下文
|
||||
*/
|
||||
export declare function every<T, C>(list: T, iterate: (this: C, item: any, key: string, list: T) => boolean, context?: C): boolean;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
every: typeof every;
|
||||
}
|
||||
}
|
||||
|
||||
export default every
|
||||
13
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/every.js
Normal file
13
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/every.js
Normal file
@@ -0,0 +1,13 @@
|
||||
var helperCreateIterateHandle = require('./helperCreateIterateHandle')
|
||||
|
||||
/**
|
||||
* 对象中的值中的每一项运行给定函数,如果该函数对每一项都返回true,则返回true,否则返回false
|
||||
*
|
||||
* @param {Object} obj 对象/数组
|
||||
* @param {Function} iterate(item, index, obj) 回调
|
||||
* @param {Object} context 上下文
|
||||
* @return {Boolean}
|
||||
*/
|
||||
var every = helperCreateIterateHandle('every', 1, 1, false, true)
|
||||
|
||||
module.exports = every
|
||||
24
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/filter.d.ts
vendored
Normal file
24
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/filter.d.ts
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
|
||||
/**
|
||||
* 查找匹配第一条数据
|
||||
* @param array 数组
|
||||
* @param iterate 回调
|
||||
* @param context 上下文
|
||||
*/
|
||||
export declare function filter<T, C>(array: T[], iterate: (this: C, item: T, index: number, list: T[]) => boolean, context?: C): T[];
|
||||
|
||||
/**
|
||||
* 查找匹配第一条数据
|
||||
* @param obj 数组
|
||||
* @param iterate 回调
|
||||
* @param context 上下文
|
||||
*/
|
||||
export declare function filter<T, C>(obj: T, iterate: (this: C, item: any, key: string, list: T) => boolean, context?: C): any;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
filter: typeof filter;
|
||||
}
|
||||
}
|
||||
|
||||
export default filter
|
||||
26
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/filter.js
Normal file
26
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/filter.js
Normal file
@@ -0,0 +1,26 @@
|
||||
var each = require('./each')
|
||||
|
||||
/**
|
||||
* 根据回调过滤数据
|
||||
*
|
||||
* @param {Object} obj 对象/数组
|
||||
* @param {Function} iterate(item, index, obj) 回调
|
||||
* @param {Object} context 上下文
|
||||
* @return {Object}
|
||||
*/
|
||||
function filter (obj, iterate, context) {
|
||||
var result = []
|
||||
if (obj && iterate) {
|
||||
if (obj.filter) {
|
||||
return obj.filter(iterate, context)
|
||||
}
|
||||
each(obj, function (val, key) {
|
||||
if (iterate.call(context, val, key, obj)) {
|
||||
result.push(val)
|
||||
}
|
||||
})
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
module.exports = filter
|
||||
21
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/filterTree.d.ts
vendored
Normal file
21
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/filterTree.d.ts
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
|
||||
export interface FilterTreeOptions {
|
||||
children?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从树结构中根据回调过滤数据
|
||||
* @param {Object} list 数组
|
||||
* @param {Function} iterate(item, index, items, path, parent) 回调
|
||||
* @param {Object} options {children: 'children'}
|
||||
* @param {Object} context 上下文
|
||||
*/
|
||||
export declare function filterTree<T, C>(list: T[], iterate: (this: C, item: T, index: number, items: T[], path: string[], parent: T, nodes: T[]) => boolean, options?: FilterTreeOptions, context?: C): T[];
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
filterTree: typeof filterTree;
|
||||
}
|
||||
}
|
||||
|
||||
export default filterTree
|
||||
@@ -0,0 +1,24 @@
|
||||
var eachTree = require('./eachTree')
|
||||
|
||||
/**
|
||||
* 从树结构中根据回调过滤数据
|
||||
*
|
||||
* @param {Object} obj 对象/数组
|
||||
* @param {Function} iterate(item, index, items, path, parent) 回调
|
||||
* @param {Object} options {children: 'children'}
|
||||
* @param {Object} context 上下文
|
||||
* @return {Array}
|
||||
*/
|
||||
function filterTree (obj, iterate, options, context) {
|
||||
var result = []
|
||||
if (obj && iterate) {
|
||||
eachTree(obj, function (item, index, items, path, parent, nodes) {
|
||||
if (iterate.call(context, item, index, items, path, parent, nodes)) {
|
||||
result.push(item)
|
||||
}
|
||||
}, options)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
module.exports = filterTree
|
||||
23
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/find.d.ts
vendored
Normal file
23
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/find.d.ts
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* 从左至右遍历,匹配最近的一条数据
|
||||
* @param array 数组
|
||||
* @param iterate 回调
|
||||
* @param context 上下文
|
||||
*/
|
||||
export declare function find<T, C>(list: T[], iterate: (this: C, item: T, index: number, list: T[]) => boolean, context?: C): T;
|
||||
|
||||
/**
|
||||
* 从左至右遍历,匹配最近的一条数据
|
||||
* @param obj 对象
|
||||
* @param iterate 回调
|
||||
* @param context 上下文
|
||||
*/
|
||||
export declare function find<T, C>(obj: T, iterate: (this: C, item: any, key: string, obj: T) => boolean, context?: C): any;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
find: typeof find;
|
||||
}
|
||||
}
|
||||
|
||||
export default find
|
||||
13
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/find.js
Normal file
13
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/find.js
Normal file
@@ -0,0 +1,13 @@
|
||||
var helperCreateIterateHandle = require('./helperCreateIterateHandle')
|
||||
|
||||
/**
|
||||
* 从左至右遍历,匹配最近的一条数据
|
||||
*
|
||||
* @param {Object} obj 对象/数组
|
||||
* @param {Function} iterate(item, index, obj) 回调
|
||||
* @param {Object} context 上下文
|
||||
* @return {Object}
|
||||
*/
|
||||
var find = helperCreateIterateHandle('find', 1, 3, true)
|
||||
|
||||
module.exports = find
|
||||
23
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/findIndexOf.d.ts
vendored
Normal file
23
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/findIndexOf.d.ts
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* 返回对象第一个索引值
|
||||
* @param list 数组
|
||||
* @param iterate 迭代器
|
||||
* @param context 上下文
|
||||
*/
|
||||
export declare function findIndexOf<T, C>(list: T[], iterate: (this: C, item: T, index: any, obj: T[]) => boolean, context?: C): number;
|
||||
|
||||
/**
|
||||
* 返回对象第一个索引值
|
||||
* @param obj 对象
|
||||
* @param iterate 迭代器
|
||||
* @param context 上下文
|
||||
*/
|
||||
export declare function findIndexOf<T, C>(obj: T, iterate: (this: C, item: any, key: string, obj: T) => boolean, context?: C): number;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
findIndexOf: typeof findIndexOf;
|
||||
}
|
||||
}
|
||||
|
||||
export default findIndexOf
|
||||
@@ -0,0 +1,20 @@
|
||||
var helperCreateiterateIndexOf = require('./helperCreateiterateIndexOf')
|
||||
|
||||
/**
|
||||
* 返回对象第一个索引值
|
||||
*
|
||||
* @param {Object} obj 对象/数组
|
||||
* @param {Function} iterate(item, index, obj) 回调
|
||||
* @param {Object} context 上下文
|
||||
* @return {Object}
|
||||
*/
|
||||
var findIndexOf = helperCreateiterateIndexOf(function (obj, iterate, context) {
|
||||
for (var index = 0, len = obj.length; index < len; index++) {
|
||||
if (iterate.call(context, obj[index], index, obj)) {
|
||||
return index
|
||||
}
|
||||
}
|
||||
return -1
|
||||
})
|
||||
|
||||
module.exports = findIndexOf
|
||||
23
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/findKey.d.ts
vendored
Normal file
23
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/findKey.d.ts
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* 查找匹配第一条数据的键
|
||||
* @param list 数组
|
||||
* @param iterate 回调
|
||||
* @param context 上下文
|
||||
*/
|
||||
export declare function findKey<T, C>(list: T[], iterate: (this: C, item: T, index: number, list: T[])=> boolean, context?: C): number;
|
||||
|
||||
/**
|
||||
* 查找匹配第一条数据的键
|
||||
* @param obj 对象
|
||||
* @param iterate 回调
|
||||
* @param context 上下文
|
||||
*/
|
||||
export declare function findKey<T, C>(obj: T, iterate: (this: C, item: any, key: string, obj: T)=> boolean, context?: C): any;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
findKey: typeof findKey;
|
||||
}
|
||||
}
|
||||
|
||||
export default findKey
|
||||
@@ -0,0 +1,13 @@
|
||||
var helperCreateIterateHandle = require('./helperCreateIterateHandle')
|
||||
|
||||
/**
|
||||
* 查找匹配第一条数据的键
|
||||
*
|
||||
* @param {Object} obj 对象/数组
|
||||
* @param {Function} iterate(item, index, obj) 回调
|
||||
* @param {Object} context 上下文
|
||||
* @return {Object}
|
||||
*/
|
||||
var findKey = helperCreateIterateHandle('', 0, 2, true)
|
||||
|
||||
module.exports = findKey
|
||||
23
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/findLast.d.ts
vendored
Normal file
23
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/findLast.d.ts
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* 从右至左遍历,匹配最近的一条数据
|
||||
* @param array 数组
|
||||
* @param iterate 回调
|
||||
* @param context 上下文
|
||||
*/
|
||||
export declare function findLast<T, C>(array: T[], iterate: (this: C, item: T, index: number, list: T[]) => boolean, context?: C): T;
|
||||
|
||||
/**
|
||||
* 从右至左遍历,匹配最近的一条数据
|
||||
* @param obj 对象
|
||||
* @param iterate 回调
|
||||
* @param context 上下文
|
||||
*/
|
||||
export declare function findLast<T, C>(obj: T, iterate: (this: C, item: any, key: string, obj: T) => boolean, context?: C): any;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
findLast: typeof findLast;
|
||||
}
|
||||
}
|
||||
|
||||
export default findLast
|
||||
@@ -0,0 +1,25 @@
|
||||
var isArray = require('./isArray')
|
||||
var values = require('./values')
|
||||
|
||||
/**
|
||||
* 从右至左遍历,匹配最近的一条数据
|
||||
*
|
||||
* @param {Object} obj 对象/数组
|
||||
* @param {Function} iterate(item, index, obj) 回调
|
||||
* @param {Object} context 上下文
|
||||
* @return {Object}
|
||||
*/
|
||||
function findLast (obj, iterate, context) {
|
||||
if (obj) {
|
||||
if (!isArray(obj)) {
|
||||
obj = values(obj)
|
||||
}
|
||||
for (var len = obj.length - 1; len >= 0; len--) {
|
||||
if (iterate.call(context, obj[len], len, obj)) {
|
||||
return obj[len]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = findLast
|
||||
23
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/findLastIndexOf.d.ts
vendored
Normal file
23
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/findLastIndexOf.d.ts
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
/**
|
||||
* 从最后开始的索引值,返回对象第一个索引值
|
||||
* @param list 数组
|
||||
* @param iterate 迭代器
|
||||
* @param context 上下文
|
||||
*/
|
||||
export declare function findLastIndexOf<T, C>(list: T[], iterate: (this: C, item: T, index: number, list: T[]) => boolean, context?: C): number;
|
||||
|
||||
/**
|
||||
* 从最后开始的索引值,返回对象第一个索引值
|
||||
* @param obj 对象
|
||||
* @param iterate 迭代器
|
||||
* @param context 上下文
|
||||
*/
|
||||
export declare function findLastIndexOf<C>(obj: any, iterate: (this: C, item: any, key: string, obj: any) => boolean, context?: C): number;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
findLastIndexOf: typeof findLastIndexOf;
|
||||
}
|
||||
}
|
||||
|
||||
export default findLastIndexOf
|
||||
@@ -0,0 +1,20 @@
|
||||
var helperCreateiterateIndexOf = require('./helperCreateiterateIndexOf')
|
||||
|
||||
/**
|
||||
* 从最后开始的索引值,返回对象第一个索引值
|
||||
*
|
||||
* @param {Object} obj 对象/数组
|
||||
* @param {Function} iterate(item, index, obj) 回调
|
||||
* @param {Object} context 上下文
|
||||
* @return {Object}
|
||||
*/
|
||||
var findLastIndexOf = helperCreateiterateIndexOf(function (obj, iterate, context) {
|
||||
for (var len = obj.length - 1; len >= 0; len--) {
|
||||
if (iterate.call(context, obj[len], len, obj)) {
|
||||
return len
|
||||
}
|
||||
}
|
||||
return -1
|
||||
})
|
||||
|
||||
module.exports = findLastIndexOf
|
||||
29
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/findTree.d.ts
vendored
Normal file
29
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/findTree.d.ts
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
export interface FindTerrResult<T = any> {
|
||||
index: number;
|
||||
item: T;
|
||||
path: Array<string>;
|
||||
items: T[];
|
||||
parent: T;
|
||||
nodes: T[];
|
||||
}
|
||||
|
||||
export interface FindTreeOptions {
|
||||
children?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从树结构中查找匹配第一条数据的键、值、路径
|
||||
* @param {Object} list 数组
|
||||
* @param {Function} iterate(item, index, items, path, parent, nodes) 回调
|
||||
* @param {Object} options {children: 'children'}
|
||||
* @param {Object} context 上下文
|
||||
*/
|
||||
export declare function findTree<T, C>(list: T[], iterate: (this: C, item: T, index: number, items: T[], path: string[], parent: T, nodes: T[]) => boolean, options?: FindTreeOptions, context?: C): FindTerrResult<T>;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
findTree: typeof findTree;
|
||||
}
|
||||
}
|
||||
|
||||
export default findTree
|
||||
@@ -0,0 +1,34 @@
|
||||
var helperCreateTreeFunc = require('./helperCreateTreeFunc')
|
||||
|
||||
function findTreeItem (parent, obj, iterate, context, path, node, parseChildren, opts) {
|
||||
if (obj) {
|
||||
var item, index, len, paths, nodes, match
|
||||
for (index = 0, len = obj.length; index < len; index++) {
|
||||
item = obj[index]
|
||||
paths = path.concat(['' + index])
|
||||
nodes = node.concat([item])
|
||||
if (iterate.call(context, item, index, obj, paths, parent, nodes)) {
|
||||
return { index: index, item: item, path: paths, items: obj, parent: parent, nodes: nodes }
|
||||
}
|
||||
if (parseChildren && item) {
|
||||
match = findTreeItem(item, item[parseChildren], iterate, context, paths.concat([parseChildren]), nodes, parseChildren, opts)
|
||||
if (match) {
|
||||
return match
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从树结构中查找匹配第一条数据的键、值、路径
|
||||
*
|
||||
* @param {Object} obj 对象/数组
|
||||
* @param {Function} iterate(item, index, items, path, parent, nodes) 回调
|
||||
* @param {Object} options {children: 'children'}
|
||||
* @param {Object} context 上下文
|
||||
* @return {Object} { item, index, items, path, parent, nodes }
|
||||
*/
|
||||
var findTree = helperCreateTreeFunc(findTreeItem)
|
||||
|
||||
module.exports = findTree
|
||||
14
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/first.d.ts
vendored
Normal file
14
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/first.d.ts
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* 获取对象第一个值
|
||||
* @param list 数组
|
||||
*/
|
||||
export declare function first<T>(list: T[] | ArrayLike<T>): T;
|
||||
export declare function first(obj: any): any;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
first: typeof first;
|
||||
}
|
||||
}
|
||||
|
||||
export default first
|
||||
13
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/first.js
Normal file
13
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/first.js
Normal file
@@ -0,0 +1,13 @@
|
||||
var values = require('./values')
|
||||
|
||||
/**
|
||||
* 获取对象第一个值
|
||||
*
|
||||
* @param {Object} obj 对象/数组
|
||||
* @return {Object}
|
||||
*/
|
||||
function first (obj) {
|
||||
return values(obj)[0]
|
||||
}
|
||||
|
||||
module.exports = first
|
||||
21
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/flatten.d.ts
vendored
Normal file
21
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/flatten.d.ts
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* 将一个多维数组铺平
|
||||
* @param list 数组
|
||||
* @param deep 是否深层
|
||||
*/
|
||||
export declare function flatten<T>(list: T[][], deep?: boolean): T[];
|
||||
|
||||
/**
|
||||
* 将一个多维数组铺平
|
||||
* @param list 数组
|
||||
* @param deep 是否深层
|
||||
*/
|
||||
export declare function flatten(list: any[], deep?: boolean): any[];
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
flatten: typeof flatten;
|
||||
}
|
||||
}
|
||||
|
||||
export default flatten
|
||||
@@ -0,0 +1,25 @@
|
||||
var isArray = require('./isArray')
|
||||
var arrayEach = require('./arrayEach')
|
||||
|
||||
function flattenDeep (array, deep) {
|
||||
var result = []
|
||||
arrayEach(array, function (vals) {
|
||||
result = result.concat(isArray(vals) ? (deep ? flattenDeep(vals, deep) : vals) : [vals])
|
||||
})
|
||||
return result
|
||||
}
|
||||
|
||||
/**
|
||||
* 将一个多维数组铺平
|
||||
* @param {Array} array 数组
|
||||
* @param {Boolean} deep 是否深层
|
||||
* @return {Array}
|
||||
*/
|
||||
function flatten (array, deep) {
|
||||
if (isArray(array)) {
|
||||
return flattenDeep(array, deep)
|
||||
}
|
||||
return []
|
||||
}
|
||||
|
||||
module.exports = flatten
|
||||
14
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/floor.d.ts
vendored
Normal file
14
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/floor.d.ts
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
/**
|
||||
* 将数值向下舍入
|
||||
* @param num 数值/字符串
|
||||
* @param digits 小数保留位数
|
||||
*/
|
||||
export declare function floor(num: string | number, digits?: number): number;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
floor: typeof floor;
|
||||
}
|
||||
}
|
||||
|
||||
export default floor
|
||||
12
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/floor.js
Normal file
12
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/floor.js
Normal file
@@ -0,0 +1,12 @@
|
||||
var helperCreateMathNumber = require('./helperCreateMathNumber')
|
||||
|
||||
/**
|
||||
* 将数值向下舍入
|
||||
*
|
||||
* @param {string|number} num 数值
|
||||
* @param {number} digits 小数保留位数
|
||||
* @return {number}
|
||||
*/
|
||||
var floor = helperCreateMathNumber('floor')
|
||||
|
||||
module.exports = floor
|
||||
13
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/forOf.d.ts
vendored
Normal file
13
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/forOf.d.ts
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* 已废弃,被 some, every 替换
|
||||
* @deprecated
|
||||
*/
|
||||
export declare function forOf<C>(obj: any, iterate: (this: C, item: any, index: any, obj: any) => boolean, context?: C): void;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
forOf: typeof forOf;
|
||||
}
|
||||
}
|
||||
|
||||
export default forOf
|
||||
28
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/forOf.js
Normal file
28
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/forOf.js
Normal file
@@ -0,0 +1,28 @@
|
||||
var isArray = require('./isArray')
|
||||
var hasOwnProp = require('./hasOwnProp')
|
||||
|
||||
/**
|
||||
* 已废弃,被 some, every 替换
|
||||
* @deprecated
|
||||
*/
|
||||
function forOf (obj, iterate, context) {
|
||||
if (obj) {
|
||||
if (isArray(obj)) {
|
||||
for (var index = 0, len = obj.length; index < len; index++) {
|
||||
if (iterate.call(context, obj[index], index, obj) === false) {
|
||||
break
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (var key in obj) {
|
||||
if (hasOwnProp(obj, key)) {
|
||||
if (iterate.call(context, obj[key], key, obj) === false) {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = forOf
|
||||
9
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/function.d.ts
vendored
Normal file
9
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/function.d.ts
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
export * from './noop'
|
||||
export * from './property'
|
||||
export * from './bind'
|
||||
export * from './once'
|
||||
export * from './after'
|
||||
export * from './before'
|
||||
export * from './throttle'
|
||||
export * from './debounce'
|
||||
export * from './delay'
|
||||
@@ -0,0 +1,25 @@
|
||||
'use strict'
|
||||
|
||||
var noop = require('./noop')
|
||||
var property = require('./property')
|
||||
var bind = require('./bind')
|
||||
var once = require('./once')
|
||||
var after = require('./after')
|
||||
var before = require('./before')
|
||||
var throttle = require('./throttle')
|
||||
var debounce = require('./debounce')
|
||||
var delay = require('./delay')
|
||||
|
||||
var functionExports = {
|
||||
noop: noop,
|
||||
property: property,
|
||||
bind: bind,
|
||||
once: once,
|
||||
after: after,
|
||||
before: before,
|
||||
throttle: throttle,
|
||||
debounce: debounce,
|
||||
delay: delay
|
||||
}
|
||||
|
||||
module.exports = functionExports
|
||||
16
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/get.d.ts
vendored
Normal file
16
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/get.d.ts
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* 获取对象的属性的值,如果值为 undefined,则返回默认值
|
||||
* @param obj 对象
|
||||
* @param property 键、路径
|
||||
* @param defaultValue 默认值
|
||||
*/
|
||||
export declare function get<T extends object, K extends keyof T>(obj: T, property: string | string[], defaultValue?: any): T[K];
|
||||
export declare function get(obj: any, property: string | string[], defaultValue?: any): any;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
get: typeof get;
|
||||
}
|
||||
}
|
||||
|
||||
export default get
|
||||
53
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/get.js
Normal file
53
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/get.js
Normal file
@@ -0,0 +1,53 @@
|
||||
var staticHGKeyRE = require('./staticHGKeyRE')
|
||||
|
||||
var helperGetHGSKeys = require('./helperGetHGSKeys')
|
||||
var hasOwnProp = require('./hasOwnProp')
|
||||
var isUndefined = require('./isUndefined')
|
||||
var eqNull = require('./eqNull')
|
||||
|
||||
/**
|
||||
* 获取对象的属性的值,如果值为 undefined,则返回默认值
|
||||
* @param {Object/Array} obj 对象
|
||||
* @param {String/Function} property 键、路径
|
||||
* @param {Object} defaultValue 默认值
|
||||
* @return {Object}
|
||||
*/
|
||||
function get (obj, property, defaultValue) {
|
||||
if (eqNull(obj)) {
|
||||
return defaultValue
|
||||
}
|
||||
var result = getValueByPath(obj, property)
|
||||
return isUndefined(result) ? defaultValue : result
|
||||
}
|
||||
|
||||
function getDeepProps (obj, key) {
|
||||
var matchs = key ? key.match(staticHGKeyRE) : ''
|
||||
return matchs ? (matchs[1] ? (obj[matchs[1]] ? obj[matchs[1]][matchs[2]] : undefined) : obj[matchs[2]]) : obj[key]
|
||||
}
|
||||
|
||||
function getValueByPath (obj, property) {
|
||||
if (obj) {
|
||||
var rest, props, len
|
||||
var index = 0
|
||||
if (obj[property] || hasOwnProp(obj, property)) {
|
||||
return obj[property]
|
||||
} else {
|
||||
props = helperGetHGSKeys(property)
|
||||
len = props.length
|
||||
if (len) {
|
||||
for (rest = obj; index < len; index++) {
|
||||
rest = getDeepProps(rest, props[index])
|
||||
if (eqNull(rest)) {
|
||||
if (index === len - 1) {
|
||||
return rest
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
return rest
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = get
|
||||
12
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/getBaseURL.d.ts
vendored
Normal file
12
20220330_Vote/Ewide.Web.Entry/wwwroot/lib/xe-utils/getBaseURL.d.ts
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
/**
|
||||
* 获取上下文路径
|
||||
*/
|
||||
export declare function getBaseURL(): string;
|
||||
|
||||
declare module './ctor' {
|
||||
interface XEUtilsMethods {
|
||||
getBaseURL: typeof getBaseURL;
|
||||
}
|
||||
}
|
||||
|
||||
export default getBaseURL
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user