Socket
Socket
Sign inDemoInstall

@file-services/path

Package Overview
Dependencies
Maintainers
4
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@file-services/path - npm Package Compare versions

Comparing version 8.3.3 to 9.0.0

178

browser-path.js

@@ -13,3 +13,3 @@ const CHAR_UPPERCASE_A = 65; /* A */

cwd: function () {
return '/';
return "/";
},

@@ -21,9 +21,9 @@ env: {},

const valueType = typeof value;
return valueType === 'object' && value === null ? 'null' : valueType;
return valueType === "object" && value === null ? "null" : valueType;
}
function validateString(value, paramName) {
if (typeof value !== 'string') {
if (typeof value !== "string") {
throw new TypeError(
`[ERR_INVALID_ARG_TYPE]: The "${paramName}" argument must be of type string. Received ${valueType(value)}`
`[ERR_INVALID_ARG_TYPE]: The "${paramName}" argument must be of type string. Received ${valueType(value)}`,
);

@@ -49,3 +49,3 @@ }

function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
let res = '';
let res = "";
let lastSegmentLength = 0;

@@ -73,3 +73,3 @@ let lastSlash = -1;

if (lastSlashIndex === -1) {
res = '';
res = "";
lastSegmentLength = 0;

@@ -84,3 +84,3 @@ } else {

} else if (res.length !== 0) {
res = '';
res = "";
lastSegmentLength = 0;

@@ -93,3 +93,3 @@ lastSlash = i;

if (allowAboveRoot) {
res += res.length > 0 ? `${separator}..` : '..';
res += res.length > 0 ? `${separator}..` : "..";
lastSegmentLength = 2;

@@ -114,9 +114,9 @@ }

function _format(sep, pathObject) {
if (pathObject === null || typeof pathObject !== 'object') {
if (pathObject === null || typeof pathObject !== "object") {
throw new TypeError(
`[ERR_INVALID_ARG_TYPE]: The "pathObject" argument must be of type object. Received ${valueType(pathObject)}`
`[ERR_INVALID_ARG_TYPE]: The "pathObject" argument must be of type object. Received ${valueType(pathObject)}`,
);
}
const dir = pathObject.dir || pathObject.root;
const base = pathObject.base || `${pathObject.name || ''}${pathObject.ext || ''}`;
const base = pathObject.base || `${pathObject.name || ""}${pathObject.ext || ""}`;
if (!dir) {

@@ -131,4 +131,4 @@ return base;

resolve(...args) {
let resolvedDevice = '';
let resolvedTail = '';
let resolvedDevice = "";
let resolvedTail = "";
let resolvedAbsolute = false;

@@ -140,3 +140,3 @@

path = args[i];
validateString(path, 'path');
validateString(path, "path");

@@ -170,3 +170,3 @@ // Skip empty entries

let rootEnd = 0;
let device = '';
let device = "";
let isAbsolute = false;

@@ -260,11 +260,11 @@ const code = path.charCodeAt(0);

// Normalize the tail path
resolvedTail = normalizeString(resolvedTail, !resolvedAbsolute, '\\', isPathSeparator);
resolvedTail = normalizeString(resolvedTail, !resolvedAbsolute, "\\", isPathSeparator);
return resolvedAbsolute ? `${resolvedDevice}\\${resolvedTail}` : `${resolvedDevice}${resolvedTail}` || '.';
return resolvedAbsolute ? `${resolvedDevice}\\${resolvedTail}` : `${resolvedDevice}${resolvedTail}` || ".";
},
normalize(path) {
validateString(path, 'path');
validateString(path, "path");
const len = path.length;
if (len === 0) return '.';
if (len === 0) return ".";
let rootEnd = 0;

@@ -279,3 +279,3 @@ let device;

// unnecessary work
return isPosixPathSeparator(code) ? '\\' : path;
return isPosixPathSeparator(code) ? "\\" : path;
}

@@ -340,5 +340,5 @@ if (isPathSeparator(code)) {

let tail = rootEnd < len ? normalizeString(path.slice(rootEnd), !isAbsolute, '\\', isPathSeparator) : '';
if (tail.length === 0 && !isAbsolute) tail = '.';
if (tail.length > 0 && isPathSeparator(path.charCodeAt(len - 1))) tail += '\\';
let tail = rootEnd < len ? normalizeString(path.slice(rootEnd), !isAbsolute, "\\", isPathSeparator) : "";
if (tail.length === 0 && !isAbsolute) tail = ".";
if (tail.length > 0 && isPathSeparator(path.charCodeAt(len - 1))) tail += "\\";
if (device === undefined) {

@@ -351,3 +351,3 @@ return isAbsolute ? `\\${tail}` : tail;

isAbsolute(path) {
validateString(path, 'path');
validateString(path, "path");
const len = path.length;

@@ -365,3 +365,3 @@ if (len === 0) return false;

join(...args) {
if (args.length === 0) return '.';
if (args.length === 0) return ".";

@@ -372,3 +372,3 @@ let joined;

const arg = args[i];
validateString(arg, 'path');
validateString(arg, "path");
if (arg.length > 0) {

@@ -380,3 +380,3 @@ if (joined === undefined) joined = firstPart = arg;

if (joined === undefined) return '.';
if (joined === undefined) return ".";

@@ -430,6 +430,6 @@ // Make sure that the joined path doesn't start with two slashes, because

relative(from, to) {
validateString(from, 'from');
validateString(to, 'to');
validateString(from, "from");
validateString(to, "to");
if (from === to) return '';
if (from === to) return "";

@@ -439,3 +439,3 @@ const fromOrig = win32.resolve(from);

if (fromOrig === toOrig) return '';
if (fromOrig === toOrig) return "";

@@ -445,3 +445,3 @@ from = fromOrig.toLowerCase();

if (from === to) return '';
if (from === to) return "";

@@ -513,3 +513,3 @@ // Trim any leading backslashes

let out = '';
let out = "";
// Generate the relative path based on the path difference between `to` and

@@ -519,3 +519,3 @@ // `from`

if (i === fromEnd || from.charCodeAt(i) === CHAR_BACKWARD_SLASH) {
out += out.length === 0 ? '..' : '\\..';
out += out.length === 0 ? ".." : "\\..";
}

@@ -536,6 +536,6 @@ }

// Note: this will *probably* throw somewhere.
if (typeof path !== 'string') return path;
if (typeof path !== "string") return path;
if (path.length === 0) {
return '';
return "";
}

@@ -569,5 +569,5 @@

dirname(path) {
validateString(path, 'path');
validateString(path, "path");
const len = path.length;
if (len === 0) return '.';
if (len === 0) return ".";
let rootEnd = -1;

@@ -580,3 +580,3 @@ let offset = 0;

// unnecessary work or a dot.
return isPathSeparator(code) ? path : '.';
return isPathSeparator(code) ? path : ".";
}

@@ -647,3 +647,3 @@

if (end === -1) {
if (rootEnd === -1) return '.';
if (rootEnd === -1) return ".";

@@ -656,4 +656,4 @@ end = rootEnd;

basename(path, ext) {
if (ext !== undefined) validateString(ext, 'ext');
validateString(path, 'path');
if (ext !== undefined) validateString(ext, "ext");
validateString(path, "path");
let start = 0;

@@ -671,3 +671,3 @@ let end = -1;

if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
if (ext === path) return '';
if (ext === path) return "";
let extIdx = ext.length - 1;

@@ -729,3 +729,3 @@ let firstNonSlashEnd = -1;

if (end === -1) return '';
if (end === -1) return "";
return path.slice(start, end);

@@ -735,3 +735,3 @@ },

extname(path) {
validateString(path, 'path');
validateString(path, "path");
let start = 0;

@@ -790,3 +790,3 @@ let startDot = -1;

) {
return '';
return "";
}

@@ -796,8 +796,8 @@ return path.slice(startDot, end);

format: _format.bind(null, '\\'),
format: _format.bind(null, "\\"),
parse(path) {
validateString(path, 'path');
validateString(path, "path");
const ret = { root: '', dir: '', base: '', ext: '', name: '' };
const ret = { root: "", dir: "", base: "", ext: "", name: "" };
if (path.length === 0) return ret;

@@ -941,4 +941,4 @@

sep: '\\',
delimiter: ';',
sep: "\\",
delimiter: ";",
win32: null,

@@ -951,3 +951,3 @@ posix: null,

resolve(...args) {
let resolvedPath = '';
let resolvedPath = "";
let resolvedAbsolute = false;

@@ -958,3 +958,3 @@

validateString(path, 'path');
validateString(path, "path");

@@ -974,3 +974,3 @@ // Skip empty entries

// Normalize the path
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute, '/', isPosixPathSeparator);
resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute, "/", isPosixPathSeparator);

@@ -980,9 +980,9 @@ if (resolvedAbsolute) {

}
return resolvedPath.length > 0 ? resolvedPath : '.';
return resolvedPath.length > 0 ? resolvedPath : ".";
},
normalize(path) {
validateString(path, 'path');
validateString(path, "path");
if (path.length === 0) return '.';
if (path.length === 0) return ".";

@@ -993,9 +993,9 @@ const isAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH;

// Normalize the path
path = normalizeString(path, !isAbsolute, '/', isPosixPathSeparator);
path = normalizeString(path, !isAbsolute, "/", isPosixPathSeparator);
if (path.length === 0) {
if (isAbsolute) return '/';
return trailingSeparator ? './' : '.';
if (isAbsolute) return "/";
return trailingSeparator ? "./" : ".";
}
if (trailingSeparator) path += '/';
if (trailingSeparator) path += "/";

@@ -1006,3 +1006,3 @@ return isAbsolute ? `/${path}` : path;

isAbsolute(path) {
validateString(path, 'path');
validateString(path, "path");
return path.length > 0 && path.charCodeAt(0) === CHAR_FORWARD_SLASH;

@@ -1012,7 +1012,7 @@ },

join(...args) {
if (args.length === 0) return '.';
if (args.length === 0) return ".";
let joined;
for (let i = 0; i < args.length; ++i) {
const arg = args[i];
validateString(arg, 'path');
validateString(arg, "path");
if (arg.length > 0) {

@@ -1023,3 +1023,3 @@ if (joined === undefined) joined = arg;

}
if (joined === undefined) return '.';
if (joined === undefined) return ".";
return posix.normalize(joined);

@@ -1029,6 +1029,6 @@ },

relative(from, to) {
validateString(from, 'from');
validateString(to, 'to');
validateString(from, "from");
validateString(to, "to");
if (from === to) return '';
if (from === to) return "";

@@ -1039,3 +1039,3 @@ // Trim leading forward slashes.

if (from === to) return '';
if (from === to) return "";

@@ -1082,3 +1082,3 @@ const fromStart = 1;

let out = '';
let out = "";
// Generate the relative path based on the path difference between `to`

@@ -1088,3 +1088,3 @@ // and `from`.

if (i === fromEnd || from.charCodeAt(i) === CHAR_FORWARD_SLASH) {
out += out.length === 0 ? '..' : '/..';
out += out.length === 0 ? ".." : "/..";
}

@@ -1104,4 +1104,4 @@ }

dirname(path) {
validateString(path, 'path');
if (path.length === 0) return '.';
validateString(path, "path");
if (path.length === 0) return ".";
const hasRoot = path.charCodeAt(0) === CHAR_FORWARD_SLASH;

@@ -1122,4 +1122,4 @@ let end = -1;

if (end === -1) return hasRoot ? '/' : '.';
if (hasRoot && end === 1) return '//';
if (end === -1) return hasRoot ? "/" : ".";
if (hasRoot && end === 1) return "//";
return path.slice(0, end);

@@ -1129,4 +1129,4 @@ },

basename(path, ext) {
if (ext !== undefined) validateString(ext, 'ext');
validateString(path, 'path');
if (ext !== undefined) validateString(ext, "ext");
validateString(path, "path");

@@ -1138,3 +1138,3 @@ let start = 0;

if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
if (ext === path) return '';
if (ext === path) return "";
let extIdx = ext.length - 1;

@@ -1196,3 +1196,3 @@ let firstNonSlashEnd = -1;

if (end === -1) return '';
if (end === -1) return "";
return path.slice(start, end);

@@ -1202,3 +1202,3 @@ },

extname(path) {
validateString(path, 'path');
validateString(path, "path");
let startDot = -1;

@@ -1247,3 +1247,3 @@ let startPart = 0;

) {
return '';
return "";
}

@@ -1253,8 +1253,8 @@ return path.slice(startDot, end);

format: _format.bind(null, '/'),
format: _format.bind(null, "/"),
parse(path) {
validateString(path, 'path');
validateString(path, "path");
const ret = { root: '', dir: '', base: '', ext: '', name: '' };
const ret = { root: "", dir: "", base: "", ext: "", name: "" };
if (path.length === 0) return ret;

@@ -1264,3 +1264,3 @@ const isAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH;

if (isAbsolute) {
ret.root = '/';
ret.root = "/";
start = 1;

@@ -1327,3 +1327,3 @@ } else {

if (startPart > 0) ret.dir = path.slice(0, startPart - 1);
else if (isAbsolute) ret.dir = '/';
else if (isAbsolute) ret.dir = "/";

@@ -1333,4 +1333,4 @@ return ret;

sep: '/',
delimiter: ':',
sep: "/",
delimiter: ":",
win32: null,

@@ -1347,2 +1347,2 @@ posix: null,

module.exports = _process.platform === 'win32' ? win32 : posix;
module.exports = _process.platform === "win32" ? win32 : posix;

@@ -1,2 +0,2 @@

declare const path: import('@file-services/types').IFileSystemPath;
declare const path: import("@file-services/types").IFileSystemPath;
export = path;
"use strict";
Object.defineProperty(exports, '__esModule', { value: true });
const path = require('path');
Object.defineProperty(exports, "__esModule", { value: true });
const path = require("path");

@@ -5,0 +5,0 @@ exports.default = exports;

{
"name": "@file-services/path",
"description": "Node's `path` implementation, ready for the web.",
"version": "8.3.3",
"version": "9.0.0",
"main": "index.js",

@@ -10,3 +10,3 @@ "browser": {

"dependencies": {
"@file-services/types": "^8.3.3"
"@file-services/types": "^9.0.0"
},

@@ -13,0 +13,0 @@ "files": [

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc