/usr/lib/node_modules/pnpm/dist/node_modules/tar/dist/esm
NameSizeModeActions
create.d.ts.map1920644editdlrm
create.js21630644editdlrm
create.js.map53290644editdlrm
cwd-error.d.ts.map2830644editdlrm
cwd-error.js3100644editdlrm
cwd-error.js.map7270644editdlrm
extract.d.ts.map1940644editdlrm
extract.js16920644editdlrm
extract.js.map36340644editdlrm
get-write-flag.d.ts.map1680644editdlrm
get-write-flag.js10180644editdlrm
get-write-flag.js.map19310644editdlrm
header.d.ts.map18300644editdlrm
header.js106040644editdlrm
header.js.map241970644editdlrm
index.d.ts.map8270644editdlrm
index.js6470644editdlrm
index.js.map16310644editdlrm
large-numbers.d.ts.map2170644editdlrm
large-numbers.js25810644editdlrm
large-numbers.js.map59030644editdlrm
list.d.ts.map2870644editdlrm
list.js32340644editdlrm
list.js.map70980644editdlrm
make-command.d.ts.map44070644editdlrm
make-command.js18700644editdlrm
make-command.js.map90750644editdlrm
mkdir.d.ts.map8000644editdlrm
mkdir.js64520644editdlrm
mkdir.js.map151560644editdlrm
mode-fix.d.ts.map1740644editdlrm
mode-fix.js7530644editdlrm
mode-fix.js.map13930644editdlrm
normalize-unicode.d.ts.map1730644editdlrm
normalize-unicode.js4890644editdlrm
normalize-unicode.js.map10040644editdlrm
normalize-windows-path.d.ts.map1840644editdlrm
normalize-windows-path.js4900644editdlrm
normalize-windows-path.js.map9500644editdlrm
options.d.ts.map58320644editdlrm
options.js16390644editdlrm
options.js.map263980644editdlrm
pack.d.ts.map37950644editdlrm
pack.js130050644editdlrm
pack.js.map281820644editdlrm
package.json230644editdlrm
parse.d.ts.map37050644editdlrm
parse.js217410644editdlrm
parse.js.map401290644editdlrm
path-reservations.d.ts.map4190644editdlrm
path-reservations.js54610644editdlrm
path-reservations.js.map109440644editdlrm
pax.d.ts.map8820644editdlrm
pax.js47540644editdlrm
pax.js.map100850644editdlrm
read-entry.d.ts.map11800644editdlrm
read-entry.js41750644editdlrm
read-entry.js.map81880644editdlrm
replace.d.ts.map1440644editdlrm
replace.js71850644editdlrm
replace.js.map152580644editdlrm
strip-absolute-path.d.ts.map1780644editdlrm
strip-absolute-path.js10600644editdlrm
strip-absolute-path.js.map19230644editdlrm
strip-trailing-slashes.d.ts.map1830644editdlrm
strip-trailing-slashes.js4890644editdlrm
strip-trailing-slashes.js.map10560644editdlrm
symlink-error.d.ts.map3210644editdlrm
symlink-error.js3900644editdlrm
symlink-error.js.map8370644editdlrm
types.d.ts.map7670644editdlrm
types.js12770644editdlrm
types.js.map35020644editdlrm
unpack.d.ts.map39850644editdlrm
unpack.js324450644editdlrm
unpack.js.map620810644editdlrm
update.d.ts.map1400644editdlrm
update.js10060644editdlrm
update.js.map23240644editdlrm
warn-method.d.ts.map11110644editdlrm
warn-method.js7950644editdlrm
warn-method.js.map25930644editdlrm
winchars.d.ts.map1950644editdlrm
winchars.js5490644editdlrm
winchars.js.map16420644editdlrm
write-entry.d.ts.map48330644editdlrm
write-entry.js227810644editdlrm
write-entry.js.map483860644editdlrm
Edit: /usr/lib/node_modules/pnpm/dist/node_modules/tar/dist/esm/path-reservations.js (5461B)
// A path exclusive reservation system // reserve([list, of, paths], fn) // When the fn is first in line for all its paths, it // is called with a cb that clears the reservation. // // Used by async unpack to avoid clobbering paths in use, // while still allowing maximal safe parallelization. import { join } from 'node:path'; import { normalizeUnicode } from './normalize-unicode.js'; import { stripTrailingSlashes } from './strip-trailing-slashes.js'; const platform = process.env.TESTING_TAR_FAKE_PLATFORM || process.platform; const isWindows = platform === 'win32'; // return a set of parent dirs for a given path // '/a/b/c/d' -> ['/', '/a', '/a/b', '/a/b/c', '/a/b/c/d'] const getDirs = (path) => { const dirs = path .split('/') .slice(0, -1) .reduce((set, path) => { const s = set[set.length - 1]; if (s !== undefined) { path = join(s, path); } set.push(path || '/'); return set; }, []); return dirs; }; export class PathReservations { // path => [function or Set] // A Set object means a directory reservation // A fn is a direct reservation on that path #queues = new Map(); // fn => {paths:[path,...], dirs:[path, ...]} #reservations = new Map(); // functions currently running #running = new Set(); reserve(paths, fn) { paths = isWindows ? ['win32 parallelization disabled'] : paths.map(p => { // don't need normPath, because we skip this entirely for windows return stripTrailingSlashes(join(normalizeUnicode(p))).toLowerCase(); }); const dirs = new Set(paths.map(path => getDirs(path)).reduce((a, b) => a.concat(b))); this.#reservations.set(fn, { dirs, paths }); for (const p of paths) { const q = this.#queues.get(p); if (!q) { this.#queues.set(p, [fn]); } else { q.push(fn); } } for (const dir of dirs) { const q = this.#queues.get(dir); if (!q) { this.#queues.set(dir, [new Set([fn])]); } else { const l = q[q.length - 1]; if (l instanceof Set) { l.add(fn); } else { q.push(new Set([fn])); } } } return this.#run(fn); } // return the queues for each path the function cares about // fn => {paths, dirs} #getQueues(fn) { const res = this.#reservations.get(fn); /* c8 ignore start */ if (!res) { throw new Error('function does not have any path reservations'); } /* c8 ignore stop */ return { paths: res.paths.map((path) => this.#queues.get(path)), dirs: [...res.dirs].map(path => this.#queues.get(path)), }; } // check if fn is first in line for all its paths, and is // included in the first set for all its dir queues check(fn) { const { paths, dirs } = this.#getQueues(fn); return (paths.every(q => q && q[0] === fn) && dirs.every(q => q && q[0] instanceof Set && q[0].has(fn))); } // run the function if it's first in line and not already running #run(fn) { if (this.#running.has(fn) || !this.check(fn)) { return false; } this.#running.add(fn); fn(() => this.#clear(fn)); return true; } #clear(fn) { if (!this.#running.has(fn)) { return false; } const res = this.#reservations.get(fn); /* c8 ignore start */ if (!res) { throw new Error('invalid reservation'); } /* c8 ignore stop */ const { paths, dirs } = res; const next = new Set(); for (const path of paths) { const q = this.#queues.get(path); /* c8 ignore start */ if (!q || q?.[0] !== fn) { continue; } /* c8 ignore stop */ const q0 = q[1]; if (!q0) { this.#queues.delete(path); continue; } q.shift(); if (typeof q0 === 'function') { next.add(q0); } else { for (const f of q0) { next.add(f); } } } for (const dir of dirs) { const q = this.#queues.get(dir); const q0 = q?.[0]; /* c8 ignore next - type safety only */ if (!q || !(q0 instanceof Set)) continue; if (q0.size === 1 && q.length === 1) { this.#queues.delete(dir); continue; } else if (q0.size === 1) { q.shift(); // next one must be a function, // or else the Set would've been reused const n = q[0]; if (typeof n === 'function') { next.add(n); } } else { q0.delete(fn); } } this.#running.delete(fn); next.forEach(fn => this.#run(fn)); return true; } } //# sourceMappingURL=path-reservations.js.map