Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

typed-path

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

typed-path - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

2

index.d.ts

@@ -0,3 +1,5 @@

export declare type TypedPathKey = string | symbol | number;
export declare type TypedPathNode<T> = {
$path: string;
$raw: TypedPathKey[];
};

@@ -4,0 +6,0 @@ export declare type TypedPathFunction<T> = (...args: any[]) => T;

@@ -33,2 +33,5 @@ "use strict";

}
if (name === '$raw') {
return path;
}
if (toStringMethods.includes(name)) {

@@ -35,0 +38,0 @@ return function () { return pathToString(path); };

@@ -0,3 +1,6 @@

export type TypedPathKey = string | symbol | number;
export type TypedPathNode<T> = {
$path: string;
$raw: TypedPathKey[];
};

@@ -42,3 +45,3 @@

return <TypedPathWrapper<T>>new Proxy({}, {
get(target: T, name: string | symbol | number) {
get(target: T, name: TypedPathKey) {
if (name === '$path') {

@@ -48,2 +51,6 @@ return pathToString(path);

if (name === '$raw') {
return path;
}
if (toStringMethods.includes(name)) {

@@ -50,0 +57,0 @@ return () => pathToString(path);

2

package.json
{
"name": "typed-path",
"version": "2.0.1",
"version": "2.0.2",
"description": "Type safe object string paths for typescript.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -23,2 +23,15 @@ # Typed Path

Also you can get access to the path string using `$path` special field. [@m-abboud](https://github.com/m-abboud)
Like this:
```js
console.log(tp<TestType>().a.b.c.d.$path); // this will output "a.b.c.d"
```
If you need a raw path, which is of type `string[]` - you can get it using `$raw` special field. [dcbrwn](https://github.com/dcbrwn)
```js
console.log(tp<TestType>().a.b.c.d.$raw); // this will output ["a", "b", "c", "d"]
```
### Suggestions

@@ -25,0 +38,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc