path-to-prop 2.0.1 → 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.
Files changed (3) hide show
  1. package/README.md +13 -5
  2. package/dist/index.cjs +0 -2
  3. 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
- const target = {a: {b: {c: {d: {e: 1}}}}}
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(target, path)
31
+ getProp(obj, path)
24
32
  // returns 1
25
33
 
26
- getProp(target, 'nonexistent.prop')
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 target = {'a/b': {'c.d': 1}}
41
+ const obj = {'a/b': {'c.d': 1}}
34
42
 
35
- getProp(target, ['a/b', 'c.d'])
43
+ getProp(obj, ['a/b', 'c.d'])
36
44
  // returns 1
37
45
  ```
package/dist/index.cjs CHANGED
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
3
  /**
6
4
  * Returns the keys of a path
7
5
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "path-to-prop",
3
- "version": "2.0.1",
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.10.1",
49
- "@typescript-eslint/parser": "^5.10.1",
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.7.0",
52
- "eslint-config-prettier": "^8.3.0",
51
+ "eslint": "^8.40.0",
52
+ "eslint-config-prettier": "^8.8.0",
53
53
  "eslint-plugin-tree-shaking": "^1.10.0",
54
- "np": "^7.6.0",
55
- "prettier": "^2.5.1",
56
- "rollup": "^2.66.0",
57
- "rollup-plugin-typescript2": "^0.31.1",
58
- "typescript": "^4.5.5",
59
- "vitest": "^0.2.1"
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"