1.2.6 • Published 3 years ago

@ninggure/utils v1.2.6

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

axiosRequest

axios请求封装

  • GET
import {get} from "@ninggure/utils/axiosRequest";
// 请求链接
const url = "http://xxxx.com";
// 参数
const params = {
    a: 1
}
// 请求头, 可以不设置
const headers = {}
// 响应内容格式, 可以不设置,默认为json
const responseType = "json";
get(url, params, headers, responseType)
  • POST
import {post} from "@ninggure/utils/axiosRequest";
// 请求链接
const url = "http://xxxx.com";
// 参数
const data = {
    a: 1
}
// 请求头, 可以不设置
const headers = {}
// 响应内容格式, 可以不设置,默认为json
const responseType = "json";
post(url, params, headers, responseType)
  • 上传文件(POST)
import {uploadFile} from "@ninggure/utils/axiosRequest";
// 请求链接
const url = "http://xxxx.com";
// 参数
const data = {
    file
}
// 请求头, 可以不设置
const headers = {}
// 响应内容格式, 可以不设置,默认为json
const responseType = "json";
uploadFile(url, params, headers, responseType)

deepClone

深拷贝对象或数组

  • depthDeepClone(深度遍历深拷贝)
import {depthDeepClone} from "@ninggure/utils/deepClone";

const a = {test: 1, test2: 2, test3: {
    test: 1
}}
// 深拷贝一个a对象
const newA = depthDeepClone(a);
console.log(a === newA) // false
  • breadthDeepClone(广度遍历深拷贝)
import {breadthDeepClone} from "@ninggure/utils/deepClone";
const a = {test: 1, test2: 2, test3: {
    test: 1
}}
// 深拷贝一个a对象
const newA = breadthDeepClone(a);
console.log(a === newA) // false

fileList

遍历目录里面的所有内容

  • getDepthFileList(深度遍历)
const {getDepthFileList} = require("@ninggure/utils/fileList");
const dirPath = "xxxx";
getDepthFileList(dirPath)
  • getBreadthFileList(广度遍历)
const {getBreadthFileList} = require("@ninggure/utils/fileList");
const dirPath = "xxxx";
getBreadthFileList(dirPath)
1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.1.2

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.3

3 years ago

1.0.0

3 years ago