1.0.0 • Published 4 years ago

frontend-path v1.0.0

Weekly downloads
4
License
-
Repository
-
Last release
4 years ago

browserpath

The same of NodeJS path, maybe resolve function (win32 and posix) doesn't work as expect. This functions require process.cwd() and browser doesn't have. To try to fix this:

const app = navigator.appVersion;
const isWindows = app.indexOf("Win") != -1;
const isUnix = app.indexOf("X11") != -1 || app.indexOf("Linux") != -1 || app.indexOf("Mac") != -1;

// If is unix based, use the root path
// If windows, try to use the most common root path
const processCwdEmulate = isUnix ? "/" : isWindows ? "c:\\" : "";

Install

Simple

npm i browserpath
yarn add browserpath

How to use

As I said, the same NodeJS API