mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-28 00:45:04 +08:00
Bug: 370734442 No-Presubmit: true Change-Id: I7021b801e5bacd4ed33643651a53b8db20ccf8b0 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/5898986 Commit-Queue: Danil Somsikov <dsv@chromium.org> Reviewed-by: Simon Zünd <szuend@chromium.org>
80 lines
2.7 KiB
JavaScript
80 lines
2.7 KiB
JavaScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
(function (factory) {
|
|
if (typeof module === "object" && typeof module.exports === "object") {
|
|
var v = factory(require, exports);
|
|
if (v !== undefined) module.exports = v;
|
|
}
|
|
else if (typeof define === "function" && define.amd) {
|
|
define(["require", "exports"], factory);
|
|
}
|
|
})(function (require, exports) {
|
|
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
/**
|
|
* @returns the directory name of a path.
|
|
*/
|
|
function dirname(path) {
|
|
var idx = ~path.lastIndexOf('/') || ~path.lastIndexOf('\\');
|
|
if (idx === 0) {
|
|
return '.';
|
|
}
|
|
else if (~idx === 0) {
|
|
return path[0];
|
|
}
|
|
else {
|
|
return path.substring(0, ~idx);
|
|
}
|
|
}
|
|
exports.dirname = dirname;
|
|
/**
|
|
* @returns the base name of a path.
|
|
*/
|
|
function basename(path) {
|
|
var idx = ~path.lastIndexOf('/') || ~path.lastIndexOf('\\');
|
|
if (idx === 0) {
|
|
return path;
|
|
}
|
|
else if (~idx === path.length - 1) {
|
|
return basename(path.substring(0, path.length - 1));
|
|
}
|
|
else {
|
|
return path.substr(~idx + 1);
|
|
}
|
|
}
|
|
exports.basename = basename;
|
|
/**
|
|
* @returns {{.far}} from boo.far or the empty string.
|
|
*/
|
|
function extname(path) {
|
|
path = basename(path);
|
|
var idx = ~path.lastIndexOf('.');
|
|
return idx ? path.substring(~idx) : '';
|
|
}
|
|
exports.extname = extname;
|
|
exports.join = function () {
|
|
// Not using a function with var-args because of how TS compiles
|
|
// them to JS - it would result in 2*n runtime cost instead
|
|
// of 1*n, where n is parts.length.
|
|
var value = '';
|
|
for (var i = 0; i < arguments.length; i++) {
|
|
var part = arguments[i];
|
|
if (i > 0) {
|
|
// add the separater between two parts unless
|
|
// there already is one
|
|
var last = value.charCodeAt(value.length - 1);
|
|
if (last !== 47 /* Slash */ && last !== 92 /* Backslash */) {
|
|
var next = part.charCodeAt(0);
|
|
if (next !== 47 /* Slash */ && next !== 92 /* Backslash */) {
|
|
value += '/';
|
|
}
|
|
}
|
|
}
|
|
value += part;
|
|
}
|
|
return value;
|
|
};
|
|
});
|