@daysnap/utils 0.0.43 → 0.0.45
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/es/parsePath.js +7 -4
- package/es/throttle.d.ts +1 -1
- package/lib/parsePath.js +7 -4
- package/lib/throttle.d.ts +1 -1
- package/package.json +1 -1
- package/docs/README.md +0 -34
package/es/parsePath.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
import { isObject } from './isObject';
|
|
1
2
|
/**
|
|
2
3
|
* 根据路径解析值
|
|
3
4
|
*/
|
|
4
5
|
export function parsePath(obj, path) {
|
|
5
6
|
const segments = path ? path.split('.') : [];
|
|
6
|
-
segments.
|
|
7
|
-
|
|
8
|
-
obj
|
|
9
|
-
|
|
7
|
+
for (let i = 0, len = segments.length; i < len; i++) {
|
|
8
|
+
obj = obj[segments[i]];
|
|
9
|
+
if (!isObject(obj)) {
|
|
10
|
+
break;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
10
13
|
return obj;
|
|
11
14
|
}
|
package/es/throttle.d.ts
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* 节流函数
|
|
3
3
|
* 减少事件执行次数,有规律的执行
|
|
4
4
|
*/
|
|
5
|
-
export declare function throttle<T extends (...args: []) => any>(fn: T, ms: number): (this: unknown, ...args: Parameters<T>) => void;
|
|
5
|
+
export declare function throttle<T extends (...args: any[]) => any>(fn: T, ms: number): (this: unknown, ...args: Parameters<T>) => void;
|
package/lib/parsePath.js
CHANGED
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parsePath = void 0;
|
|
4
|
+
const isObject_1 = require("./isObject");
|
|
4
5
|
/**
|
|
5
6
|
* 根据路径解析值
|
|
6
7
|
*/
|
|
7
8
|
function parsePath(obj, path) {
|
|
8
9
|
const segments = path ? path.split('.') : [];
|
|
9
|
-
segments.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
for (let i = 0, len = segments.length; i < len; i++) {
|
|
11
|
+
obj = obj[segments[i]];
|
|
12
|
+
if (!(0, isObject_1.isObject)(obj)) {
|
|
13
|
+
break;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
13
16
|
return obj;
|
|
14
17
|
}
|
|
15
18
|
exports.parsePath = parsePath;
|
package/lib/throttle.d.ts
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
* 节流函数
|
|
3
3
|
* 减少事件执行次数,有规律的执行
|
|
4
4
|
*/
|
|
5
|
-
export declare function throttle<T extends (...args: []) => any>(fn: T, ms: number): (this: unknown, ...args: Parameters<T>) => void;
|
|
5
|
+
export declare function throttle<T extends (...args: any[]) => any>(fn: T, ms: number): (this: unknown, ...args: Parameters<T>) => void;
|
package/package.json
CHANGED
package/docs/README.md
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
@daysnap/utils / [Exports](modules.md)
|
|
2
|
-
|
|
3
|
-
<p align="center">
|
|
4
|
-
<img alt="logo" src="https://avatars.githubusercontent.com/u/96568061?s=200&v=4" width="120" height="120" style="margin-bottom: 10px;">
|
|
5
|
-
</p>
|
|
6
|
-
|
|
7
|
-
<h1 align="center">@daysnap/utils</h1>
|
|
8
|
-
|
|
9
|
-
<p align="center">包含日常工作中常用的工具函数。</p>
|
|
10
|
-
|
|
11
|
-
<p align="center">
|
|
12
|
-
<img src="https://img.shields.io/npm/v/@daysnap/utils?style=flat-square" alt="npm version" />
|
|
13
|
-
<img src="https://img.shields.io/codecov/c/github/vant-ui/vant/dev.svg?style=flat-square&color=#4fc08d" alt="Coverage Status" />
|
|
14
|
-
<img src="https://img.shields.io/npm/dm/@daysnap/utils.svg?style=flat-square&color=#4fc08d" alt="downloads" />
|
|
15
|
-
</p>
|
|
16
|
-
|
|
17
|
-
## 使用
|
|
18
|
-
|
|
19
|
-
- 安装
|
|
20
|
-
```shell
|
|
21
|
-
npm install @daysnap/utils
|
|
22
|
-
|
|
23
|
-
# or
|
|
24
|
-
yarn add @daysnap/utils
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
- 引入
|
|
28
|
-
```js
|
|
29
|
-
import { debounce } from '@daysnap/utils'
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
## 详情 API 文档
|
|
33
|
-
|
|
34
|
-
[点我查看](./docs/modules.md)
|