JSPM

try-resolve

1.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 213532
  • Score
    100M100P100Q9337F
  • License MIT

Try and resolve a filename

Package Exports

  • try-resolve

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (try-resolve) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

try-resolve

Installation

$ npm install try-resolve

Usage

var resolve = require("try-resolve");

resolve(filename, [require])

  • filename is a filename to be resolved.
  • require is an optional instance of the require function from any file.

Returns null if the file can't be required, otherwise it returns an absolute filename string.

Example

if (require("try-resolve")("/home/sebastian/file")) {
  // this file can be required
} else {
  // it can't
}

resolve.relative(filename)

Resolve a filename relative to the cwd.