1.0.0 • Published 3 years ago

@jrh/to v1.0.0

Weekly downloads
-
License
-
Repository
github
Last release
3 years ago

@jrh/to

Tiny utility to get an absolute path to a target file using a relative path from a source file in an ES6 module.

Installation

npm install @jrh/to

Usage

import to from '@jrh/to'

const path = to(target, source)

Arguments

NameTypeDescription
targetStringThe relative path to the target file.
sourceStringThe absolute path to the source file (usually import.meta.url).

Example

Given the file structure:

source/
  folder1/
    1.js
  folder2/
    2.js

1.js

import to from '@jrh/to'

const path = to('../folder2/2.js', import.meta.url)
// => /absolute/path/to/folder2/2.js