Galerie und tage

This commit is contained in:
2021-11-23 17:56:26 +01:00
parent ff35366279
commit 5f873bee89
4693 changed files with 149659 additions and 301447 deletions

61
node_modules/strip-dirs/index.js generated vendored
View File

@@ -4,67 +4,46 @@
*/
'use strict';
const path = require('path');
const util = require('util');
var path = require('path');
const isNaturalNumber = require('is-natural-number');
var isAbsolutePath = require('is-absolute');
var isNaturalNumber = require('is-natural-number');
module.exports = function stripDirs(pathStr, count, option) {
option = option || {narrow: false};
if (arguments.length < 2) {
throw new Error('strip-dirs requires two arguments and more. (path, count[, option])');
}
if (typeof pathStr !== 'string') {
throw new TypeError(
util.inspect(pathStr) +
pathStr +
' is not a string. First argument to strip-dirs must be a path string.'
);
}
if (path.posix.isAbsolute(pathStr) || path.win32.isAbsolute(pathStr)) {
throw new Error(`${pathStr} is an absolute path. strip-dirs requires a relative path.`);
}
if (!isNaturalNumber(count, {includeZero: true})) {
throw new Error(
'The Second argument of strip-dirs must be a natural number or 0, but received ' +
util.inspect(count) +
'.'
if (isAbsolutePath(pathStr)) {
throw new TypeError(
pathStr +
' is an absolute path. strip-dirs requires a relative path.'
);
}
if (option) {
if (typeof option !== 'object') {
throw new TypeError(
util.inspect(option) +
' is not an object. Expected an object with a boolean `disallowOverflow` property.'
);
}
if (Array.isArray(option)) {
throw new TypeError(
util.inspect(option) +
' is an array. Expected an object with a boolean `disallowOverflow` property.'
);
}
if ('disallowOverflow' in option && typeof option.disallowOverflow !== 'boolean') {
throw new TypeError(
util.inspect(option.disallowOverflow) +
' is neither true nor false. `disallowOverflow` option must be a Boolean value.'
);
}
} else {
option = {disallowOverflow: false};
if (!isNaturalNumber(count, true)) {
throw new Error(
'Second argument to strip-dirs must be a natural number or 0.'
);
}
const pathComponents = path.normalize(pathStr).split(path.sep);
var pathComponents = path.normalize(pathStr).split(path.sep);
if (pathComponents.length > 1 && pathComponents[0] === '.') {
pathComponents.shift();
}
if (count > pathComponents.length - 1) {
if (option.disallowOverflow) {
if (option.narrow) {
throw new RangeError('Cannot strip more directories than there are.');
}
count = pathComponents.length - 1;
}