path-to-prop
Advanced tools
Comparing version 2.0.2 to 2.0.3
{ | ||
"name": "path-to-prop", | ||
"version": "2.0.2", | ||
"version": "2.0.3", | ||
"sideEffects": false, | ||
@@ -12,5 +12,5 @@ "type": "module", | ||
".": { | ||
"types": "./dist/types/index.d.ts", | ||
"import": "./dist/index.es.js", | ||
"require": "./dist/index.cjs", | ||
"types": "./dist/types/index.d.ts" | ||
"require": "./dist/index.cjs" | ||
} | ||
@@ -27,3 +27,3 @@ }, | ||
"lint": "tsc --noEmit && eslint ./src --ext .ts", | ||
"build": "rollup -c ./scripts/build.js", | ||
"build": "rollup --bundleConfigAsCjs -c ./scripts/build.js", | ||
"release": "npm run lint && del dist && npm run build && np" | ||
@@ -50,14 +50,14 @@ }, | ||
"devDependencies": { | ||
"@typescript-eslint/eslint-plugin": "^5.10.1", | ||
"@typescript-eslint/parser": "^5.10.1", | ||
"@typescript-eslint/eslint-plugin": "^5.59.2", | ||
"@typescript-eslint/parser": "^5.59.2", | ||
"del-cli": "^4.0.1", | ||
"eslint": "^8.7.0", | ||
"eslint-config-prettier": "^8.3.0", | ||
"eslint": "^8.40.0", | ||
"eslint-config-prettier": "^8.8.0", | ||
"eslint-plugin-tree-shaking": "^1.10.0", | ||
"np": "^7.6.0", | ||
"prettier": "^2.5.1", | ||
"rollup": "^2.66.1", | ||
"rollup-plugin-typescript2": "^0.31.1", | ||
"typescript": "^4.5.5", | ||
"vitest": "^0.2.3" | ||
"np": "^7.7.0", | ||
"prettier": "^2.8.8", | ||
"rollup": "^3.21.5", | ||
"rollup-plugin-typescript2": "^0.34.1", | ||
"typescript": "^4.9.5", | ||
"vitest": "^0.31.0" | ||
}, | ||
@@ -64,0 +64,0 @@ "bugs": { |
@@ -20,9 +20,17 @@ # Path to prop 🛤 | ||
const target = {a: {b: {c: {d: {e: 1}}}}} | ||
getProp({ nested: { prop: 1 } }, 'nested.prop') // 1 | ||
getProp({ nested: { prop: 1 } }, 'nested') // { prop: 1 } | ||
``` | ||
You can use `/` or `.` to access nested props: | ||
```js | ||
const obj = {a: {b: {c: {d: {e: 1}}}}} | ||
const path = 'a/b/c.d.e' | ||
getProp(target, path) | ||
getProp(obj, path) | ||
// returns 1 | ||
getProp(target, 'nonexistent.prop') | ||
getProp(obj, 'nonexistent.prop') | ||
// returns undefined | ||
@@ -34,6 +42,6 @@ ``` | ||
```js | ||
const target = {'a/b': {'c.d': 1}} | ||
const obj = {'a/b': {'c.d': 1}} | ||
getProp(target, ['a/b', 'c.d']) | ||
getProp(obj, ['a/b', 'c.d']) | ||
// returns 1 | ||
``` |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
7304
46
71