@ajaxjs/util 1.1.3 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,41 +1,41 @@
1
- {
2
- "name": "@ajaxjs/util",
3
- "version": "1.1.3",
4
- "description": "Core JS Utils",
5
- "scripts": {
6
- "dev": "rollup -w -c",
7
- "build": "rollup -c"
8
- },
9
- "main": "dist/index.umd.js",
10
- "module": "dist/index.esm.js",
11
- "types": "dist/src/index.d.ts",
12
- "type": "module",
13
- "files": [
14
- "dist/"
15
- ],
16
- "repository": {
17
- "type": "git",
18
- "url": "https://github.com/lightweight-component/js/tree/main/util"
19
- },
20
- "bugs": {
21
- "url": "https://github.com/lightweight-component/js/issues"
22
- },
23
- "keywords": [
24
- "ajaxjs",
25
- "util"
26
- ],
27
- "author": "Frank Cheung <frank@ajaxjs.com>",
28
- "license": "Apache License 2.0",
29
- "devDependencies": {
30
- "@eslint/js": "^9.9.1",
31
- "@rollup/plugin-commonjs": "^26.0.1",
32
- "@rollup/plugin-node-resolve": "^15.2.3",
33
- "@rollup/plugin-typescript": "^11.1.6",
34
- "eslint": "^9.9.1",
35
- "globals": "^15.9.0",
36
- "rollup": "^4.21.2",
37
- "tslib": "^2.7.0",
38
- "typescript": "^5.5.4",
39
- "typescript-eslint": "^8.4.0"
40
- }
41
- }
1
+ {
2
+ "name": "@ajaxjs/util",
3
+ "version": "1.2.0",
4
+ "description": "Core JS Utils",
5
+ "scripts": {
6
+ "dev": "rollup -w -c",
7
+ "build": "rollup -c"
8
+ },
9
+ "main": "dist/index.umd.js",
10
+ "module": "dist/index.esm.js",
11
+ "types": "dist/src/index.d.ts",
12
+ "type": "module",
13
+ "files": [
14
+ "dist/"
15
+ ],
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "https://github.com/lightweight-component/js/tree/main/util"
19
+ },
20
+ "bugs": {
21
+ "url": "https://github.com/lightweight-component/js/issues"
22
+ },
23
+ "keywords": [
24
+ "ajaxjs",
25
+ "util"
26
+ ],
27
+ "author": "Frank Cheung <frank@ajaxjs.com>",
28
+ "license": "Apache License 2.0",
29
+ "devDependencies": {
30
+ "@eslint/js": "^9.9.1",
31
+ "@rollup/plugin-commonjs": "^26.0.1",
32
+ "@rollup/plugin-node-resolve": "^15.2.3",
33
+ "@rollup/plugin-typescript": "^11.1.6",
34
+ "eslint": "^9.9.1",
35
+ "globals": "^15.9.0",
36
+ "rollup": "^4.21.2",
37
+ "tslib": "^2.7.0",
38
+ "typescript": "^5.5.4",
39
+ "typescript-eslint": "^8.4.0"
40
+ }
41
+ }
@@ -1,18 +0,0 @@
1
- /**
2
- * 获取某个 Cookie
3
- *
4
- * @param name 键名称
5
- * @returns 值
6
- */
7
- export declare function getCookie(name: string): string | null;
8
- /**
9
- * 设置某个 Cookie
10
- *
11
- * @param name 键名称
12
- * @param value 值
13
- */
14
- export declare function setCookie(name: string, value: string): void;
15
- /**
16
- * 清空 Cookie
17
- */
18
- export declare function delCookie(): void;
@@ -1,17 +0,0 @@
1
- /**
2
- * 向父级元素递归搜索
3
- *
4
- * @param _el 当前所在元素
5
- * @param tagName 目标标签名称
6
- * @param className 目标元素样式类
7
- * @returns 目标元素,找不到为 null
8
- */
9
- export declare function up(_el: Element, tagName: string, className: string): Element | null;
10
- /**
11
- * 加载脚本
12
- *
13
- * @param url 脚本地址
14
- * @param id 脚本元素 id,可选的
15
- * @param cb 回调函数,可选的
16
- */
17
- export declare function loadScript(url: string, id?: string, cb?: (ev: Event) => any): void;
@@ -1,51 +0,0 @@
1
- /**
2
- * 通用工具类
3
- */
4
- /**
5
- * 是否调试模式中
6
- *
7
- * 打包成组件之后不能用
8
- *
9
- * @returns
10
- */
11
- export declare function isDebug(): boolean;
12
- export declare function isDev(): boolean;
13
- /**
14
- * 日期格式化。详见博客文章:http://blog.csdn.net/zhangxin09/archive/2011/01/01/6111294.aspx
15
- * e.g: new Date().format("yyyy-MM-dd hh:mm:ss")
16
- *
17
- * @param {String} format
18
- * @return {String}
19
- */
20
- export declare function dateFormat(this: Date, format: string): string;
21
- /**
22
- * 日期格式化
23
- * @author meizz
24
- * @param date 日期,必须为 Date 类型
25
- * @param fmt 格式模板
26
- * @returns 格式化后的字符串
27
- */
28
- export declare function dateFormat2(date: Date, fmt: string): string;
29
- /**
30
- * 并行和串行任务
31
- *
32
- * @author https://segmentfault.com/a/1190000013265925
33
- * @param arr
34
- * @param finnaly
35
- */
36
- export declare function parallel(arr: [], _finally: Function): void;
37
- /**
38
- * 函数节流
39
- *
40
- * @author https://www.cnblogs.com/moqiutao/p/6875955.html
41
- * @param fn
42
- * @param delay
43
- * @param mustRunDelay
44
- */
45
- export declare function throttle(fn: Function, delay: number, mustRunDelay: number): Function;
46
- /**
47
- * 复制文字到剪切板
48
- *
49
- * @param {string} text
50
- */
51
- export declare function copyToClipboard(text: string): void;
@@ -1,22 +0,0 @@
1
- /**
2
- * XHR 请求配置
3
- */
4
- export interface XhrConfig {
5
- /**
6
- * 请求头里面的 Content-Type 字段
7
- */
8
- contentType?: string;
9
- /**
10
- * XHR 响应结果的类型
11
- */
12
- parseContentType?: 'text' | 'xml' | 'json';
13
- /**
14
- * 超时时间,单位是毫秒
15
- * 设为 0 适合不控制超时
16
- */
17
- timeout?: number;
18
- /**
19
- * 是否跨域
20
- */
21
- withCredentials?: boolean;
22
- }
@@ -1,71 +0,0 @@
1
- import { XhrConfig } from './xhr-config';
2
- /**
3
- * 处理响应的回调函数
4
- */
5
- type XhrCallback = (json: {}, text: string) => void;
6
- /**
7
- * 设置全局请求的 head 参数
8
- *
9
- * @param param
10
- */
11
- export declare function setBaseHeadParams(params: any): void;
12
- /**
13
- *
14
- * @param url
15
- * @param cb
16
- * @param params
17
- * @param cfg
18
- */
19
- export declare function xhr_post_upload(url: string, cb: XhrCallback, params: Document | XMLHttpRequestBodyInit, cfg?: XhrConfig): void;
20
- /**
21
- * XHR GET 请求
22
- *
23
- * @param url 请求地址
24
- * @param cb 回调函数 @example (json: {}, text: string) => void;
25
- * @param params 参数,必填,如无填空字符串 "";参数类型是json;参数值会进行 URL 编码,最后附加到 QueryString 中
26
- * @param cfg 配置,可选的
27
- */
28
- export declare function xhr_get(url: string, cb: XhrCallback, params?: {}, cfg?: XhrConfig): void;
29
- /**
30
- * XHR DELETE 请求
31
- *
32
- * @param url 请求地址
33
- * @param cb 回调函数 @example (json: {}, text: string) => void;
34
- * @param params 参数,必填,如无填空字符串 "";参数类型是json;参数值会进行 URL 编码,最后附加到 QueryString 中
35
- * @param cfg 配置,可选的
36
- */
37
- export declare function xhr_del(url: string, cb: XhrCallback, params?: {}, cfg?: XhrConfig): void;
38
- /**
39
- * XHR POST 请求
40
- *
41
- * @param url 请求地址
42
- * @param cb 回调函数 @example (json: {}, text: string) => void;
43
- * @param params 参数,必填,如无填空字符串 "";参数类型可以是字符串或 json;参数值会进行 URL 编码
44
- * @param cfg 配置,可选的
45
- */
46
- export declare function xhr_post(url: string, cb: XhrCallback, params: string | {}, cfg?: XhrConfig): void;
47
- /**
48
- * XHR PUT 请求
49
- *
50
- * @param url 请求地址
51
- * @param cb 回调函数 @example (json: {}, text: string) => void;
52
- * @param params 参数,必填,如无填空字符串 "";参数类型可以是字符串或 json;参数值会进行 URL 编码
53
- * @param cfg 配置,可选的
54
- */
55
- export declare function xhr_put(url: string, cb: XhrCallback, params: string | {}, cfg?: XhrConfig): void;
56
- /**
57
- * 对象转换为 URL 参数列表,用 & 分隔
58
- *
59
- * @param {Object} param JSON 对象
60
- * @returns URL 参数列表
61
- */
62
- export declare function toParams(param: any): string;
63
- /**
64
- * 获取 QueryString 的某个参数
65
- *
66
- * @param val
67
- * @returns
68
- */
69
- export declare function getQuery(val: string): string;
70
- export declare function getPageList(self: any, listArray: any, callback?: Function): XhrCallback;
71
- export {};