Gathering detailed insights and metrics for proxy-object-path
Gathering detailed insights and metrics for proxy-object-path
Gathering detailed insights and metrics for proxy-object-path
Gathering detailed insights and metrics for proxy-object-path
How to connect types with names / how to get a path of an object
npm install proxy-object-path
Typescript
Module System
Node Version
NPM Version
JavaScript (73.98%)
TypeScript (25.3%)
HTML (0.72%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
2 Stars
6 Commits
1 Watchers
1 Branches
1 Contributors
Updated on May 11, 2022
Latest Version
1.1.1
Package Id
proxy-object-path@1.1.1
Unpacked Size
7.95 kB
Size
3.17 kB
File Count
5
NPM Version
7.6.3
Node Version
14.16.0
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1npm install proxy-object-path 2yarn add proxy-object-path
This micro project was inspired by ts-object-path
and its solution. My solution is simpler and a major idea was to make the code safer. Instead of using strings in inputs, i18next, etc. we would like to connect them with names generated from a Type (because of typescript checking = less mistakes).
Let's say we have an object which is declared as type ExampleType and then a function, component, etc. This function accepts a parameter 'key' and will pass a value into the object with this expression object[key] = value
. Providing string as a name is not good practice in TypeScript, because programmers can easily make a typo. See a React example.
1type ExampleType = {
2 username: string;
3 password: string;
4}
5
6const example: ExampleType = {} as ExampleType;
7
8function passValue(key: string, value: string) {
9 example[key] = value;
10}
11
12passValue("username", "martin");
This example is not very safe, safer will be this:
1type ExampleType = {
2 username: string;
3 password: string;
4}
5
6const exampleProxy = createProxy<ExampleType>();
7const example: ExampleType = {} as ExampleType;
8
9function passValue(key: string, value: string) {
10 example[key] = value;
11}
12
13passValue(fullObjectPath(exampleProxy.username), "martin");
Because fullObjectPath(exampleProxy.username)
will be checked by typescript and you can't make a mistake in the name "username".
Note: This is a very dumb example. Of course, nobody is going to approach this problem like above, the major thing is the idea, that when some components, functions or whatever receive a name and by this name pass a value to your existing object, it gives you full control, which is better.
1type ExampleType = { 2 property: string; 3 secret: { 4 password: string; 5 } 6} 7 8const exampleProxy = createProxy<ExampleType>(); 9 10const last = lastObjectProperty(exampleProxy.secret.password) 11// last = "password" 12 13const full = fullObjectPath(exampleProxy.secret.password) 14// full = "secret.password" 15 16const i18 = i18ObjectPath(exampleProxy.secret.password) 17// i18 = "secret:password"
If you want to use the full potential of object path, you can use functions set
and get
from lodash
.
MIT © MartinTichovsky
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 0/6 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
100 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More