@daysnap/utils 0.0.42 → 0.0.44
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/README.md +7 -4
- package/es/parsePath.js +7 -4
- package/lib/parsePath.js +7 -4
- package/package.json +9 -2
- package/docs/README.md +0 -34
package/README.md
CHANGED
|
@@ -4,12 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
<h1 align="center">@daysnap/utils</h1>
|
|
6
6
|
|
|
7
|
-
<p align="center"
|
|
7
|
+
<p align="center">日常工作中常用的工具函数</p>
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
<a href="https://www.npmjs.org/package/@daysnap/utils">
|
|
11
|
+
<img src="https://img.shields.io/npm/v/@daysnap/utils.svg" alt="npm version" />
|
|
12
|
+
</a>
|
|
13
|
+
<a href="https://npmcharts.com/compare/@daysnap/utils">
|
|
14
|
+
<img src="https://img.shields.io/npm/dm/@daysnap/utils.svg">
|
|
15
|
+
</a>
|
|
13
16
|
</p>
|
|
14
17
|
|
|
15
18
|
|
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/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/package.json
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@daysnap/utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.44",
|
|
4
4
|
"description": "通用的工具库",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
7
|
-
"
|
|
7
|
+
"types": "es/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": "./es/index.js",
|
|
11
|
+
"require": "./lib/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./*": "./*"
|
|
14
|
+
},
|
|
8
15
|
"scripts": {
|
|
9
16
|
"gen": "plop --plopfile ./scripts/gen.js --force",
|
|
10
17
|
"del": "plop --plopfile ./scripts/del.js --force",
|
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)
|