upath

  • Version 3.0.6
  • Published
  • 65 kB
  • No dependencies
  • MIT license

Install

npm i upath
yarn add upath
pnpm add upath

Overview

A drop-in replacement / proxy to Node.js path, replacing \\ with / for all results & adding file extension functions.

Index

Variables

variable _default

const _default: UPath;

    variable delimiter

    const delimiter: string;

      variable matchesGlob

      const matchesGlob: (p: string, pattern: string) => boolean;

        variable posix

        const posix: path.PlatformPath;

          variable sep

          const sep: string;

            variable VERSION

            const VERSION: string;

              variable win32

              const win32: path.PlatformPath;

                Functions

                function addExt

                addExt: (file: string, ext: string) => string;
                • Add an extension to file if it doesn't already end with it.

                function basename

                basename: (p: string, suffix?: string) => string;

                  function changeExt

                  changeExt: (
                  filename: string,
                  ext: string,
                  ignoreExts?: string[],
                  maxSize?: number
                  ) => string;
                  • Change the extension of filename. The old extension is trimmed first (subject to ignoreExts / maxSize), then ext is appended.

                  function defaultExt

                  defaultExt: (
                  filename: string,
                  ext: string,
                  ignoreExts?: string[],
                  maxSize?: number
                  ) => string;
                  • Add ext to filename only when it doesn't already have a valid extension (not in ignoreExts and not longer than maxSize).

                  function dirname

                  dirname: (p: string) => string;

                    function extname

                    extname: (p: string) => string;

                      function format

                      format: (pathObject: path.FormatInputPathObject) => string;

                        function isAbsolute

                        isAbsolute: (p: string) => boolean;

                          function join

                          join: (...paths: string[]) => string;

                            function joinSafe

                            joinSafe: (...segments: string[]) => string;
                            • Like path.join but preserves a leading ./ from the first segment and preserves UNC // or `//./' prefixes.

                            function normalize

                            normalize: (p: string) => string;

                              function normalizeSafe

                              normalizeSafe: (p: string) => string;
                              • Normalize a path, preserving a leading ./ if the original had one, and preserving UNC // or `//./' prefixes.

                              function normalizeTrim

                              normalizeTrim: (p: string) => string;
                              • Like normalizeSafe but also trims a trailing slash (unless the path is root /).

                              function parse

                              parse: (p: string) => path.ParsedPath;

                                function relative

                                relative: (from: string, to: string) => string;

                                  function removeExt

                                  removeExt: (filename: string, ext: string) => string;
                                  • Remove a specific extension from filename. If the file doesn't have that extension, return it unchanged.

                                  function resolve

                                  resolve: (...paths: string[]) => string;

                                    function toNamespacedPath

                                    toNamespacedPath: (p: string) => string;

                                      function toUnix

                                      toUnix: (p: string) => string;
                                      • Convert all backslashes to forward slashes and collapse duplicate slashes (except a leading double-slash for UNC paths).

                                      function trimExt

                                      trimExt: (filename: string, ignoreExts?: string[], maxSize?: number) => string;
                                      • Trim the extension from filename if it's a valid extension (not in ignoreExts and not longer than maxSize).

                                      Interfaces

                                      interface UPath

                                      interface UPath extends path.PlatformPath {}

                                        property sep

                                        sep: '/';

                                          property VERSION

                                          VERSION: string;

                                            method addExt

                                            addExt: (file: string, ext: string) => string;

                                              method changeExt

                                              changeExt: (
                                              filename: string,
                                              ext: string,
                                              ignoreExts?: string[],
                                              maxSize?: number
                                              ) => string;

                                                method defaultExt

                                                defaultExt: (
                                                filename: string,
                                                ext: string,
                                                ignoreExts?: string[],
                                                maxSize?: number
                                                ) => string;

                                                  method joinSafe

                                                  joinSafe: (...paths: string[]) => string;

                                                    method normalizeSafe

                                                    normalizeSafe: (p: string) => string;

                                                      method normalizeTrim

                                                      normalizeTrim: (p: string) => string;

                                                        method removeExt

                                                        removeExt: (filename: string, ext: string) => string;

                                                          method toUnix

                                                          toUnix: (p: string) => string;

                                                            method trimExt

                                                            trimExt: (filename: string, ignoreExts?: string[], maxSize?: number) => string;

                                                              Package Files (1)

                                                              Dependencies (0)

                                                              No dependencies.

                                                              Dev Dependencies (10)

                                                              Peer Dependencies (0)

                                                              No peer dependencies.

                                                              Badge

                                                              To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                              You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/upath.

                                                              • Markdown
                                                                [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/upath)
                                                              • HTML
                                                                <a href="https://www.jsdocs.io/package/upath"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>