1. relative-path-map
Configure a map of paths that may refer to each other
relative-path-map
Package: relative-path-map
Created by: akim-mcmath
Last modified: Sun, 26 Jun 2022 10:53:54 GMT
Version: 1.0.1
License: MIT
Downloads: 20
Repository: https://github.com/akim-mcmath/relative-path-map

Install

npm install relative-path-map
yarn add relative-path-map

relative-path-map

Version
License
Build
Coverage
Dependencies

Resolves a map of paths where some paths are relative to others in the same
object. Useful for describing directory structures and for project
configuration.

Install

Install via npm:

 npm install --save-dev relative-path-map

Examples

Simple example

 var relativePathMap = require('relative-path-map');

relativePathMap({
  root: 'root/path',
  sub: '[root]/sub' // => 'root/path/sub'
});

Sub-object with relative paths

 relativePathMap({
  root: 'root/path',
  obj: {
    sub: '[root]/sub', // => 'root/path/sub'
    file: '[sub]/file.js' // => 'root/path/sub/file.js'
  }
});

Array with relative paths

 relativePathMap({
  root: 'root/path',
  arr: [
    '[root]/sub', // => 'root/path/sub'
    '[0]/file.js' // => 'root/path/sub/file.js'
  ]
});

Placeholder with sub-property

 relativePathMap({
  obj: {
    sub: 'some/path',
  },
  dot: '[obj.sub]/dot-notation.js' // => // 'some/path/dot-notation.js'
});

API

relativePathMap(map)

Params

map object

An object containing strings representing paths. Paths beginning with a
placeholder [<prop>] are relative to some other path in the same object, where
<prop> is a property name, e.g. [root], or a sub-property name, e.g
[root.src].

Returns

Type: object

Returns an object whose relative paths have been resolved.

License

Copyright © 2016 Akim McMath. Licensed under the MIT License.

Dependencies

RELATED POST

10 Must-Know Windows Shortcuts That Will Save You Time

10 Must-Know Windows Shortcuts That Will Save You Time

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Arrays vs Linked Lists: Which is Better for Memory Management in Data Structures?

Navigating AWS Networking: Essential Hacks for Smooth Operation

Navigating AWS Networking: Essential Hacks for Smooth Operation

Achieving Stunning Visuals with Unity's Global Illumination

Achieving Stunning Visuals with Unity's Global Illumination

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code

Nim's Hidden Gems: Lesser-known Features for Writing Efficient Code