/var/www/cobraambalaj/node_modules/webpack/lib/util
NameSizeModeActions
ArrayHelpers.js2800644editdlrm
ArrayQueue.js20920644editdlrm
AsyncQueue.js82720644editdlrm
binarySearchBounds.js19070644editdlrm
cleverMerge.js165290644editdlrm
comparators.js122800644editdlrm
compileBooleanMatcher.js58220644editdlrm
createHash.js40940644editdlrm
DataURI.js7020644editdlrm
deprecation.js63270644editdlrm
deterministicGrouping.js114130644editdlrm
extractUrlAndGlobal.js4160644editdlrm
findGraphRoots.js61110644editdlrm
fs.js95050644editdlrm
Hash.js9250644editdlrm
identifier.js92480644editdlrm
internalSerializables.js97030644editdlrm
IterableHelpers.js9620644editdlrm
LazyBucketSortedSet.js57320644editdlrm
LazySet.js44340644editdlrm
makeSerializable.js6600644editdlrm
MapHelpers.js4720644editdlrm
memoize.js6040644editdlrm
numberHash.js10600644editdlrm
objectToMap.js3460644editdlrm
ParallelismFactorCalculator.js15280644editdlrm
processAsyncTree.js14680644editdlrm
propertyAccess.js5220644editdlrm
Queue.js10480644editdlrm
registerExternalSerializer.js78880644editdlrm
runtime.js146130644editdlrm
Semaphore.js10080644editdlrm
semver.js155460644editdlrm
serialization.js25020644editdlrm
SetHelpers.js23160644editdlrm
smartGrouping.js45980644editdlrm
SortableSet.js36350644editdlrm
source.js17590644editdlrm
StackedMap.js34530644editdlrm
StackedSetMap.js34530644editdlrm
StringXor.js10620644editdlrm
TupleQueue.js13170644editdlrm
TupleSet.js29090644editdlrm
URLAbsoluteSpecifier.js25530644editdlrm
Edit: /var/www/cobraambalaj/node_modules/webpack/lib/util/identifier.js (9248B)
/* MIT License http://www.opensource.org/licenses/mit-license.php */ "use strict"; const path = require("path"); const WINDOWS_ABS_PATH_REGEXP = /^[a-zA-Z]:[\\/]/; const SEGMENTS_SPLIT_REGEXP = /([|!])/; const WINDOWS_PATH_SEPARATOR_REGEXP = /\\/g; /** * @typedef {Object} MakeRelativePathsCache * @property {Map>=} relativePaths */ /** * @param {string} context context for relative path * @param {string} maybeAbsolutePath path to make relative * @returns {string} relative path in request style */ const absoluteToRequest = (context, maybeAbsolutePath) => { if (maybeAbsolutePath[0] === "/") { if ( maybeAbsolutePath.length > 1 && maybeAbsolutePath[maybeAbsolutePath.length - 1] === "/" ) { // this 'path' is actually a regexp generated by dynamic requires. // Don't treat it as an absolute path. return maybeAbsolutePath; } const querySplitPos = maybeAbsolutePath.indexOf("?"); let resource = querySplitPos === -1 ? maybeAbsolutePath : maybeAbsolutePath.slice(0, querySplitPos); resource = path.posix.relative(context, resource); if (!resource.startsWith("../")) { resource = "./" + resource; } return querySplitPos === -1 ? resource : resource + maybeAbsolutePath.slice(querySplitPos); } if (WINDOWS_ABS_PATH_REGEXP.test(maybeAbsolutePath)) { const querySplitPos = maybeAbsolutePath.indexOf("?"); let resource = querySplitPos === -1 ? maybeAbsolutePath : maybeAbsolutePath.slice(0, querySplitPos); resource = path.win32.relative(context, resource); if (!WINDOWS_ABS_PATH_REGEXP.test(resource)) { resource = resource.replace(WINDOWS_PATH_SEPARATOR_REGEXP, "/"); if (!resource.startsWith("../")) { resource = "./" + resource; } } return querySplitPos === -1 ? resource : resource + maybeAbsolutePath.slice(querySplitPos); } // not an absolute path return maybeAbsolutePath; }; /** * @param {string} context context for relative path * @param {string} relativePath path * @returns {string} absolute path */ const requestToAbsolute = (context, relativePath) => { if (relativePath.startsWith("./") || relativePath.startsWith("../")) return path.join(context, relativePath); return relativePath; }; const makeCacheable = fn => { /** @type {WeakMap>>} */ const cache = new WeakMap(); /** * @param {string} context context used to create relative path * @param {string} identifier identifier used to create relative path * @param {Object=} associatedObjectForCache an object to which the cache will be attached * @returns {string} the returned relative path */ const cachedFn = (context, identifier, associatedObjectForCache) => { if (!associatedObjectForCache) return fn(context, identifier); let innerCache = cache.get(associatedObjectForCache); if (innerCache === undefined) { innerCache = new Map(); cache.set(associatedObjectForCache, innerCache); } let cachedResult; let innerSubCache = innerCache.get(context); if (innerSubCache === undefined) { innerCache.set(context, (innerSubCache = new Map())); } else { cachedResult = innerSubCache.get(identifier); } if (cachedResult !== undefined) { return cachedResult; } else { const result = fn(context, identifier); innerSubCache.set(identifier, result); return result; } }; /** * @param {Object=} associatedObjectForCache an object to which the cache will be attached * @returns {function(string, string): string} cached function */ cachedFn.bindCache = associatedObjectForCache => { let innerCache; if (associatedObjectForCache) { innerCache = cache.get(associatedObjectForCache); if (innerCache === undefined) { innerCache = new Map(); cache.set(associatedObjectForCache, innerCache); } } else { innerCache = new Map(); } /** * @param {string} context context used to create relative path * @param {string} identifier identifier used to create relative path * @returns {string} the returned relative path */ const boundFn = (context, identifier) => { let cachedResult; let innerSubCache = innerCache.get(context); if (innerSubCache === undefined) { innerCache.set(context, (innerSubCache = new Map())); } else { cachedResult = innerSubCache.get(identifier); } if (cachedResult !== undefined) { return cachedResult; } else { const result = fn(context, identifier); innerSubCache.set(identifier, result); return result; } }; return boundFn; }; /** * @param {string} context context used to create relative path * @param {Object=} associatedObjectForCache an object to which the cache will be attached * @returns {function(string): string} cached function */ cachedFn.bindContextCache = (context, associatedObjectForCache) => { let innerSubCache; if (associatedObjectForCache) { let innerCache = cache.get(associatedObjectForCache); if (innerCache === undefined) { innerCache = new Map(); cache.set(associatedObjectForCache, innerCache); } innerSubCache = innerCache.get(context); if (innerSubCache === undefined) { innerCache.set(context, (innerSubCache = new Map())); } } else { innerSubCache = new Map(); } /** * @param {string} identifier identifier used to create relative path * @returns {string} the returned relative path */ const boundFn = identifier => { const cachedResult = innerSubCache.get(identifier); if (cachedResult !== undefined) { return cachedResult; } else { const result = fn(context, identifier); innerSubCache.set(identifier, result); return result; } }; return boundFn; }; return cachedFn; }; /** * * @param {string} context context for relative path * @param {string} identifier identifier for path * @returns {string} a converted relative path */ const _makePathsRelative = (context, identifier) => { return identifier .split(SEGMENTS_SPLIT_REGEXP) .map(str => absoluteToRequest(context, str)) .join(""); }; exports.makePathsRelative = makeCacheable(_makePathsRelative); /** * @param {string} context absolute context path * @param {string} request any request string may containing absolute paths, query string, etc. * @returns {string} a new request string avoiding absolute paths when possible */ const _contextify = (context, request) => { return request .split("!") .map(r => absoluteToRequest(context, r)) .join("!"); }; const contextify = makeCacheable(_contextify); exports.contextify = contextify; /** * @param {string} context absolute context path * @param {string} request any request string * @returns {string} a new request string using absolute paths when possible */ const _absolutify = (context, request) => { return request .split("!") .map(r => requestToAbsolute(context, r)) .join("!"); }; const absolutify = makeCacheable(_absolutify); exports.absolutify = absolutify; const PATH_QUERY_FRAGMENT_REGEXP = /^((?:\0.|[^?#\0])*)(\?(?:\0.|[^#\0])*)?(#.*)?$/; /** @typedef {{ resource: string, path: string, query: string, fragment: string }} ParsedResource */ /** * @param {string} str the path with query and fragment * @returns {ParsedResource} parsed parts */ const _parseResource = str => { const match = PATH_QUERY_FRAGMENT_REGEXP.exec(str); return { resource: str, path: match[1].replace(/\0(.)/g, "$1"), query: match[2] ? match[2].replace(/\0(.)/g, "$1") : "", fragment: match[3] || "" }; }; exports.parseResource = (realFn => { /** @type {WeakMap>} */ const cache = new WeakMap(); const getCache = associatedObjectForCache => { const entry = cache.get(associatedObjectForCache); if (entry !== undefined) return entry; /** @type {Map} */ const map = new Map(); cache.set(associatedObjectForCache, map); return map; }; /** * @param {string} str the path with query and fragment * @param {Object=} associatedObjectForCache an object to which the cache will be attached * @returns {ParsedResource} parsed parts */ const fn = (str, associatedObjectForCache) => { if (!associatedObjectForCache) return realFn(str); const cache = getCache(associatedObjectForCache); const entry = cache.get(str); if (entry !== undefined) return entry; const result = realFn(str); cache.set(str, result); return result; }; fn.bindCache = associatedObjectForCache => { const cache = getCache(associatedObjectForCache); return str => { const entry = cache.get(str); if (entry !== undefined) return entry; const result = realFn(str); cache.set(str, result); return result; }; }; return fn; })(_parseResource); /** * @param {string} filename the filename which should be undone * @param {boolean} enforceRelative true returns ./ for empty paths * @returns {string} repeated ../ to leave the directory of the provided filename to be back on root dir */ exports.getUndoPath = (filename, enforceRelative) => { let depth = -1; for (const part of filename.split(/[/\\]+/)) { if (part !== ".") { depth += part === ".." ? -1 : 1; } } return depth > 0 ? "../".repeat(depth) : enforceRelative ? "./" : ""; };