1.0.1 • Published 2 years ago

@adaptably/to v1.0.1

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

@adaptably/to

Get the absolute path to a file in an ES6 module.

Installation

npm install @adaptably/to

Usage

import to from '@adaptably/to'

const path = to(target, source)

Arguments

NameTypeDescription
targetStringThe relative path to the target file.
sourceObjectAn object with one key (from) which contains the 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 pathTo from '@adaptably/to'

const path = pathTo('../folder2/2.js', { from: import.meta.url })
// => /absolute/path/to/folder2/2.js