This commit is contained in:
2026-04-02 17:50:10 +08:00
parent 60697d80be
commit ce0aa4f789
373 changed files with 82520 additions and 46 deletions

View File

@@ -0,0 +1,24 @@
'use strict';
/**
* Returns true if `path` is included by the `pathsToSave` filter.
* Matches exact paths and child paths (e.g. 'metadata.views' is included by 'metadata').
*
* @param {string} path
* @param {Set<string>} pathsToSaveSet - pre-built Set of pathsToSave for O(1) exact lookup
* @param {string[]} pathsToSave - original array, used for prefix matching
* @returns {boolean}
*/
module.exports = function isInPathsToSave(path, pathsToSaveSet, pathsToSave) {
if (pathsToSaveSet.has(path)) {
return true;
}
for (const pathToSave of pathsToSave) {
if (path.slice(0, pathToSave.length) === pathToSave && path.charAt(pathToSave.length) === '.') {
return true;
}
}
return false;
};