
Product
Introducing Tier 1 Reachability: Precision CVE Triage for Enterprise Teams
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
dotpath-strict
Advanced tools
I couldn't find one that distinguishes between a property that is unset and one that is set to undefined so I made this. It throws an error when attempting to access a nonexisting property. Supports basic dot notation and numeric brackets.
Example
var dotPath = require("dotpath-strict");
var post = { title: "Readme", author: { firstName: "Hugh", lastName: "Mungus" } };
dotPath(post, "author.firstName");
//"Hugh"
npm i dotpath-strict
*
⏏Kind: Exported function
Throws:
ReferenceError
TypeError
Params
Object
string
string
- Set property to this valueExample
var obj = { a: { aa: 1, ab: [ "1", "2" ] }, b: undefined, c: null };
dotPath(obj, "a.aa");
//1
dotPath(obj, "a.ab[1]");
//"2"
dotPath(obj, "b");
//undefined
dotPath(obj, "c");
//null
dotPath(obj, "d");
//ReferenceError: d is not defined
dotPath(obj, "d", "2");
//"2"
dotPath(obj, "d.e", 3);
//TypeError: d is not an object
dotPath(obj, "d", { e: 3 });
//{ e: 3 }
dotPath(obj, "d.e");
//3
MPL 2.0
FAQs
Get or set property value by dotpath string, throws on failure.
We found that dotpath-strict demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.
Research
/Security News
Ongoing npm supply chain attack spreads to DuckDB: multiple packages compromised with the same wallet-drainer malware.
Security News
The MCP Steering Committee has launched the official MCP Registry in preview, a central hub for discovering and publishing MCP servers.