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

jet-paths

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jet-paths - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

2

package.json
{
"name": "jet-paths",
"version": "1.0.5",
"version": "1.0.6",
"description": "Preprend strings in an object with the value from a base-key.",

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

# About jet-paths
Recursively formats an object containing strings, so that each string value is prepended with its containing objects prefix property.
```typescript
console.log(jetPaths({
Base: '/api',
Users: {
Base: '/users',
Get: '/all',
},
}));
// Outputs
{
Base: '/api',
Users: {
Base: '/api/users',
Get: '/api/users/all',
},
};
```
In my expressJS server, I would generally store my routes in an object like so

@@ -12,3 +33,2 @@ and pass them to express `Router()` objects:

Base: '/users',
Get: '/all',
Add: '/add',

@@ -39,3 +59,3 @@ ...

#### How it works
The default import provides the function `jetPaths(obj, prefix (optional, default is 'BASE'))`. An object with the same keys is return with the prefix added for the parent object and all nested objects.
The default import provides the function `jetPaths(obj, prefix (optional, default is 'Base'))`. An object with the same keys is returned with the prefix added for the parent object and all nested objects.

@@ -46,3 +66,3 @@

```typescript
import jetPaths from '../src';
import jetPaths from 'jet-paths';

@@ -102,2 +122,4 @@ const PREFIX = 'Root';

Oh yeah, whole thing is fully typesafe!
Happy web-deving :)
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