This is a port of node's path module to alow the use of Buffer
and URL
in paths instead of only string
.
Because until node v17 at leats it isn't possible to use Buffer or URL in path module, but it's possible to make call's to the methods in the filesystem module using Buffer, URL or string, and with this module it's already possible to for example join 2 buffer's and send it to fs.readFile
.
You can use this module as a cjs module by making:
const path = require("path-extender").default;
But you can also use this module as an esm be making:
import path from "path-extender";
or
import { default as pathExtender } from "path-extender";
after this you only have to follow the node path documentation Node Path and remember that where in the original module you'll have to pass a string in this module you can pass a Buffer, an URL instance or a string, you can even mix them.
import path from "path-extender";
const buf = Buffer.from("a/b/c/d.js");
const dir = "/root/dir";
const joinedPath = path.join(dir, buf);
//will result in: /root/dir/a/b/c/d.js
If you only use strings or URL to work with path this module will default to use Node Path.
npm run lint
: runs the linternpm run unit
: run unit testsnpm test
: run both lint and unit tests
If you find a problem with the package you can
or even make a
Node Team - Obviously, for having created the path module in the first place.
bcoe - Creator of path-buffer
a partial implementation of node's path with buffers, ad from where the basis of this module come from.
Licensed under MIT
Copyright (c) 2021 João Parreira