path-to-prop 2.0.2 → 2.0.3
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 +13 -5
- package/dist/index.cjs +0 -2
- package/package.json +14 -14
package/README.md
CHANGED
|
@@ -17,21 +17,29 @@ Retrieves a property from an object based on a `'path/to.that.prop'`
|
|
|
17
17
|
```js
|
|
18
18
|
import { getProp } from 'path-to-prop'
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
getProp({ nested: { prop: 1 } }, 'nested.prop') // 1
|
|
21
|
+
|
|
22
|
+
getProp({ nested: { prop: 1 } }, 'nested') // { prop: 1 }
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
You can use `/` or `.` to access nested props:
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
const obj = {a: {b: {c: {d: {e: 1}}}}}
|
|
21
29
|
const path = 'a/b/c.d.e'
|
|
22
30
|
|
|
23
|
-
getProp(
|
|
31
|
+
getProp(obj, path)
|
|
24
32
|
// returns 1
|
|
25
33
|
|
|
26
|
-
getProp(
|
|
34
|
+
getProp(obj, 'nonexistent.prop')
|
|
27
35
|
// returns undefined
|
|
28
36
|
```
|
|
29
37
|
|
|
30
38
|
When you have `/` or `.` in your prop names, use an array:
|
|
31
39
|
|
|
32
40
|
```js
|
|
33
|
-
const
|
|
41
|
+
const obj = {'a/b': {'c.d': 1}}
|
|
34
42
|
|
|
35
|
-
getProp(
|
|
43
|
+
getProp(obj, ['a/b', 'c.d'])
|
|
36
44
|
// returns 1
|
|
37
45
|
```
|
package/dist/index.cjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "path-to-prop",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Retrieves a property from an object based on a 'path/to.that.prop'",
|
|
@@ -9,9 +9,9 @@
|
|
|
9
9
|
"types": "./dist/types/index.d.ts",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
|
+
"types": "./dist/types/index.d.ts",
|
|
12
13
|
"import": "./dist/index.es.js",
|
|
13
|
-
"require": "./dist/index.cjs"
|
|
14
|
-
"types": "./dist/types/index.d.ts"
|
|
14
|
+
"require": "./dist/index.cjs"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"scripts": {
|
|
24
24
|
"test": "vitest run",
|
|
25
25
|
"lint": "tsc --noEmit && eslint ./src --ext .ts",
|
|
26
|
-
"build": "rollup -c ./scripts/build.js",
|
|
26
|
+
"build": "rollup --bundleConfigAsCjs -c ./scripts/build.js",
|
|
27
27
|
"release": "npm run lint && del dist && npm run build && np"
|
|
28
28
|
},
|
|
29
29
|
"keywords": [
|
|
@@ -45,18 +45,18 @@
|
|
|
45
45
|
"license": "MIT",
|
|
46
46
|
"homepage": "https://github.com/mesqueeb/path-to-prop#readme",
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
49
|
-
"@typescript-eslint/parser": "^5.
|
|
48
|
+
"@typescript-eslint/eslint-plugin": "^5.59.2",
|
|
49
|
+
"@typescript-eslint/parser": "^5.59.2",
|
|
50
50
|
"del-cli": "^4.0.1",
|
|
51
|
-
"eslint": "^8.
|
|
52
|
-
"eslint-config-prettier": "^8.
|
|
51
|
+
"eslint": "^8.40.0",
|
|
52
|
+
"eslint-config-prettier": "^8.8.0",
|
|
53
53
|
"eslint-plugin-tree-shaking": "^1.10.0",
|
|
54
|
-
"np": "^7.
|
|
55
|
-
"prettier": "^2.
|
|
56
|
-
"rollup": "^
|
|
57
|
-
"rollup-plugin-typescript2": "^0.
|
|
58
|
-
"typescript": "^4.
|
|
59
|
-
"vitest": "^0.
|
|
54
|
+
"np": "^7.7.0",
|
|
55
|
+
"prettier": "^2.8.8",
|
|
56
|
+
"rollup": "^3.21.5",
|
|
57
|
+
"rollup-plugin-typescript2": "^0.34.1",
|
|
58
|
+
"typescript": "^4.9.5",
|
|
59
|
+
"vitest": "^0.31.0"
|
|
60
60
|
},
|
|
61
61
|
"bugs": {
|
|
62
62
|
"url": "https://github.com/mesqueeb/path-to-prop/issues"
|