Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"use strict";
const path = require("path");
const whatwgURL = require("whatwg-url");
const { domSymbolTree } = require("./living/helpers/internal-constants");
const SYMBOL_TREE_POSITION = require("symbol-tree").TreePosition;
const { parseURLToResultingURLRecord } = require("./living/helpers/document-base-url");
exports.toFileUrl = function (fileName) {
// Beyond just the `path.resolve`, this is mostly for the benefit of Windows,
// where we need to convert "\" to "/" and add an extra "/" prefix before the
// drive letter.
let pathname = path.resolve(process.cwd(), fileName).replace(/\\/g, "/");
if (pathname[0] !== "/") {
pathname = "/" + pathname;
}
// path might contain spaces, so convert those to %20
return "file://" + encodeURI(pathname);
};
/**
"use strict";
const path = require("path");
const whatwgURL = require("whatwg-url");
const { domSymbolTree } = require("./living/helpers/internal-constants");
const SYMBOL_TREE_POSITION = require("symbol-tree").TreePosition;
const { parseURLToResultingURLRecord } = require("./living/helpers/document-base-url");
exports.toFileUrl = function (fileName) {
// Beyond just the `path.resolve`, this is mostly for the benefit of Windows,
// where we need to convert "\" to "/" and add an extra "/" prefix before the
// drive letter.
let pathname = path.resolve(process.cwd(), fileName).replace(/\\/g, "/");
if (pathname[0] !== "/") {
pathname = "/" + pathname;
}
// path might contain spaces, so convert those to %20
return "file://" + encodeURI(pathname);
};
/**
"use strict";
const path = require("path");
const whatwgURL = require("whatwg-url");
const { domSymbolTree } = require("./living/helpers/internal-constants");
const SYMBOL_TREE_POSITION = require("symbol-tree").TreePosition;
const { parseURLToResultingURLRecord } = require("./living/helpers/document-base-url");
exports.toFileUrl = function (fileName) {
// Beyond just the `path.resolve`, this is mostly for the benefit of Windows,
// where we need to convert "\" to "/" and add an extra "/" prefix before the
// drive letter.
let pathname = path.resolve(process.cwd(), fileName).replace(/\\/g, "/");
if (pathname[0] !== "/") {
pathname = "/" + pathname;
}
// path might contain spaces, so convert those to %20
return "file://" + encodeURI(pathname);
};
/**
exports.treeOrderSorter = function (a, b) {
const compare = domSymbolTree.compareTreePosition(a, b);
if (compare & SYMBOL_TREE_POSITION.PRECEDING) { // b is preceding a
return 1;
}
if (compare & SYMBOL_TREE_POSITION.FOLLOWING) {
return -1;
}
// disconnected or equal:
return 0;
};
exports.treeOrderSorter = function (a, b) {
const compare = domSymbolTree.compareTreePosition(a, b);
if (compare & SYMBOL_TREE_POSITION.PRECEDING) { // b is preceding a
return 1;
}
if (compare & SYMBOL_TREE_POSITION.FOLLOWING) {
return -1;
}
// disconnected or equal:
return 0;
};
exports.treeOrderSorter = function (a, b) {
const compare = domSymbolTree.compareTreePosition(a, b);
if (compare & SYMBOL_TREE_POSITION.PRECEDING) { // b is preceding a
return 1;
}
if (compare & SYMBOL_TREE_POSITION.FOLLOWING) {
return -1;
}
// disconnected or equal:
return 0;
};
exports.treeOrderSorter = function (a, b) {
const compare = domSymbolTree.compareTreePosition(a, b);
if (compare & SYMBOL_TREE_POSITION.PRECEDING) { // b is preceding a
return 1;
}
if (compare & SYMBOL_TREE_POSITION.FOLLOWING) {
return -1;
}
// disconnected or equal:
return 0;
};
exports.treeOrderSorter = function (a, b) {
const compare = domSymbolTree.compareTreePosition(a, b);
if (compare & SYMBOL_TREE_POSITION.PRECEDING) { // b is preceding a
return 1;
}
if (compare & SYMBOL_TREE_POSITION.FOLLOWING) {
return -1;
}
// disconnected or equal:
return 0;
};
exports.treeOrderSorter = function (a, b) {
const compare = domSymbolTree.compareTreePosition(a, b);
if (compare & SYMBOL_TREE_POSITION.PRECEDING) { // b is preceding a
return 1;
}
if (compare & SYMBOL_TREE_POSITION.FOLLOWING) {
return -1;
}
// disconnected or equal:
return 0;
};