better-path-join
TypeScript icon, indicating that this package has built-in type declarations

0.0.3 • Public • Published

Better path.join

Like path.join but takes absolute path into account.

What is wrong with built-in path.join?

It does not produce accurate path when non-first argument is an absolute path.

Usage

APIs

declare function createJoinFunction (pathModule: {
  isAbsolute (): boolean
  join (left: string, right: string): string
}): (left: string, right: string) => string

Example

import path from 'path'
import createJoinFunction from 'better-path-join'
const join = createJoinFunction(path)
console.log('relative', join('abc/def', 'foo/bar'))
console.log('absolute', join('abc/def', '/foo/bar'))

Output:

relative abc/def/foo/bar
absolute /foo/bar

License

MIT © Hoàng Văn Khải

/better-path-join/

    Package Sidebar

    Install

    npm i better-path-join

    Weekly Downloads

    4

    Version

    0.0.3

    License

    MIT

    Unpacked Size

    3.01 kB

    Total Files

    5

    Last publish

    Collaborators

    • khai96_