0 Star 0 Fork 0

gaozh1024 / js-utils

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

js-utils

npm install @gaozh1024/js-utils

使用说明

utils 工具

import {utils} from '@gaozh1024/js-utils'

utils.isArray(data)
// => boolean
utils.isJson(data)
// => boolean
utils.isNumber(data)
// => boolean
utils.isInteger(data)
// => boolean
utils.isAmount(data, params)
// => boolean
utils.isStrFirst(data, params)
// => boolean
utils.isStrLast(data, params)
// => boolean

utils.toMD5(data)
// => string
utils.toEncrypt(data, key, iv)
// => string
utils.toDecrypt(data, key, iv)
// => string
utils.toStrFirst(data, length)
// => string
utils.toStrLast(data.length)
// => string
utils.toStrCut(data, params)
// => string
utils.toNumber(data)
// => number
utils.toAmount(data, params)
// => string
utils.toAmountConvert(data)
// => string
utils.toScientificCount(data)
// => string
utils.toRandom(count)
// => string
utils.toShuffle<T>(arr)
// => T[]
utils.toCopyDeepJson<T>(data)
// => T
utils.toSearchByJson(data)
// => string
utils.toJsonBySearch<T>(data)
// => T

utils.replaceStrByJson(data, json)
//  => string
utils.replaceOrSpliceToUrlByJson(url, json)
//  => string

utils.formatDate(data, params)
//  => string
utils.formatDateTimezoneOffset(data, params)
//  => string
utils.formatDateToJson(data, params)
//  => FormatDataResult

utils.contrastJson<T>(jsonOne, jsonTwo)
//  => boolean
utils.contrastJsonToDiff<T>(oldJson, newJson)
//  => T
utils.contrastArrayToDiff<T>(oldJson, newJson, contrastFields)
//  => { oldArrDiff: T[], newArrDiff: T[] }
utils.contrastVersion(serverVersion, localVersion, serverBuild, localBuild)
//  => boolean

XmlHttpRequest 数据请求

//  header 类型
import {XmlHttpRequest} from "@gaozh1024/js-utils";

XmlHttpRequest.header

//  contentType 类型
XmlHttpRequest.contentType

//  responseType 类型
XmlHttpRequest.responseType

//  method 类型
XmlHttpRequest.method

//  请求数据
const http = new XmlHttpRequest();
//  GET 方法
http.get(url, body)
//  POST 方法
http.post(url, body)
//  PUT 方法
http.put(url, body)
//  DELETE 方法
http.delete(url, body)

//  设置异步,默认为异步
http.setAsync(data);

//  设置 header
http.setHeader(name, value);

//  设置 HeaderBasic
http.setHeaderBasic(value);

//  设置 HeaderBasicBy
http.setHeaderBasicBy(account, password);

//  设置 HeaderBearer
http.setHeaderBearer(value);

//  设置 ResponseType
http.setResponseType(data);

//  设置 过期时间
http.setTimeout(name, value);

reduxTools

import {reduxTools} from "@gaozh1024/js-utils";

reduxTools.all();
//  => any
reduxTools.get<T>(name)
//  => T
reduxTools.create<T>(name, params, isInit)
//  => T
reduxTools.update<T>(name, params)
//  => T
reduxTools.remove(name)
//  => void
reduxTools.removeAndInit(name)
//  => void
MIT License Copyright (c) 2023 gaozh1215 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.

简介

TS封装实现基础通用功能 展开 收起
TypeScript
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
TypeScript
1
https://gitee.com/gaozh1215/js-utils.git
git@gitee.com:gaozh1215/js-utils.git
gaozh1215
js-utils
js-utils
master

搜索帮助