feat: refactoring project

This commit is contained in:
Carlos
2024-11-23 14:56:07 -05:00
parent f0c2a50c18
commit 1c6db5818d
2351 changed files with 39323 additions and 60326 deletions

143
node_modules/locate-path/index.d.ts generated vendored
View File

@@ -1,83 +1,92 @@
declare namespace locatePath {
interface Options {
/**
Current working directory.
export interface Options {
/**
The current working directory.
@default process.cwd()
*/
readonly cwd?: string;
@default process.cwd()
*/
readonly cwd?: URL | string;
/**
Type of path to match.
/**
The type of path to match.
@default 'file'
*/
readonly type?: 'file' | 'directory';
@default 'file'
*/
readonly type?: 'file' | 'directory';
/**
Allow symbolic links to match if they point to the requested path type.
/**
Allow symbolic links to match if they point to the requested path type.
@default true
*/
readonly allowSymlinks?: boolean;
}
interface AsyncOptions extends Options {
/**
Number of concurrently pending promises. Minimum: `1`.
@default Infinity
*/
readonly concurrency?: number;
/**
Preserve `paths` order when searching.
Disable this to improve performance if you don't care about the order.
@default true
*/
readonly preserveOrder?: boolean;
}
@default true
*/
readonly allowSymlinks?: boolean;
}
declare const locatePath: {
export interface AsyncOptions extends Options {
/**
Get the first path that exists on disk of multiple paths.
The number of concurrently pending promises.
@param paths - Paths to check.
@returns The first path that exists or `undefined` if none exists.
Minimum: `1`
@example
```
import locatePath = require('locate-path');
const files = [
'unicorn.png',
'rainbow.png', // Only this one actually exists on disk
'pony.png'
];
(async () => {
console(await locatePath(files));
//=> 'rainbow'
})();
```
@default Infinity
*/
(paths: Iterable<string>, options?: locatePath.AsyncOptions): Promise<
string | undefined
>;
readonly concurrency?: number;
/**
Synchronously get the first path that exists on disk of multiple paths.
Preserve `paths` order when searching.
@param paths - Paths to check.
@returns The first path that exists or `undefined` if none exists.
Disable this to improve performance if you don't care about the order.
@default true
*/
sync(
paths: Iterable<string>,
options?: locatePath.Options
): string | undefined;
};
readonly preserveOrder?: boolean;
}
export = locatePath;
/**
Get the first path that exists on disk of multiple paths.
@param paths - The paths to check.
@returns The first path that exists or `undefined` if none exists.
@example
```
import {locatePath} from 'locate-path';
const files = [
'unicorn.png',
'rainbow.png', // Only this one actually exists on disk
'pony.png'
];
console(await locatePath(files));
//=> 'rainbow'
```
*/
export function locatePath(
paths: Iterable<string>,
options?: AsyncOptions
): Promise<string | undefined>;
/**
Synchronously get the first path that exists on disk of multiple paths.
@param paths - The paths to check.
@returns The first path that exists or `undefined` if none exists.
@example
```
import {locatePathSync} from 'locate-path';
const files = [
'unicorn.png',
'rainbow.png', // Only this one actually exists on disk
'pony.png'
];
console(locatePathSync(files));
//=> 'rainbow'
```
*/
export function locatePathSync(
paths: Iterable<string>,
options?: Options
): string | undefined;

92
node_modules/locate-path/index.js generated vendored
View File

@@ -1,65 +1,77 @@
'use strict';
const path = require('path');
const fs = require('fs');
const {promisify} = require('util');
const pLocate = require('p-locate');
const fsStat = promisify(fs.stat);
const fsLStat = promisify(fs.lstat);
import process from 'node:process';
import path from 'node:path';
import fs, {promises as fsPromises} from 'node:fs';
import {fileURLToPath} from 'node:url';
import pLocate from 'p-locate';
const typeMappings = {
directory: 'isDirectory',
file: 'isFile'
file: 'isFile',
};
function checkType({type}) {
if (type in typeMappings) {
function checkType(type) {
if (Object.hasOwnProperty.call(typeMappings, type)) {
return;
}
throw new Error(`Invalid type specified: ${type}`);
}
const matchType = (type, stat) => type === undefined || stat[typeMappings[type]]();
const matchType = (type, stat) => stat[typeMappings[type]]();
module.exports = async (paths, options) => {
options = {
cwd: process.cwd(),
type: 'file',
allowSymlinks: true,
...options
};
checkType(options);
const statFn = options.allowSymlinks ? fsStat : fsLStat;
const toPath = urlOrPath => urlOrPath instanceof URL ? fileURLToPath(urlOrPath) : urlOrPath;
export async function locatePath(
paths,
{
cwd = process.cwd(),
type = 'file',
allowSymlinks = true,
concurrency,
preserveOrder,
} = {},
) {
checkType(type);
cwd = toPath(cwd);
const statFunction = allowSymlinks ? fsPromises.stat : fsPromises.lstat;
return pLocate(paths, async path_ => {
try {
const stat = await statFn(path.resolve(options.cwd, path_));
return matchType(options.type, stat);
} catch (_) {
const stat = await statFunction(path.resolve(cwd, path_));
return matchType(type, stat);
} catch {
return false;
}
}, options);
};
}, {concurrency, preserveOrder});
}
module.exports.sync = (paths, options) => {
options = {
cwd: process.cwd(),
allowSymlinks: true,
type: 'file',
...options
};
checkType(options);
const statFn = options.allowSymlinks ? fs.statSync : fs.lstatSync;
export function locatePathSync(
paths,
{
cwd = process.cwd(),
type = 'file',
allowSymlinks = true,
} = {},
) {
checkType(type);
cwd = toPath(cwd);
const statFunction = allowSymlinks ? fs.statSync : fs.lstatSync;
for (const path_ of paths) {
try {
const stat = statFn(path.resolve(options.cwd, path_));
const stat = statFunction(path.resolve(cwd, path_), {
throwIfNoEntry: false,
});
if (matchType(options.type, stat)) {
if (!stat) {
continue;
}
if (matchType(type, stat)) {
return path_;
}
} catch (_) {
}
} catch {}
}
};
}

2
node_modules/locate-path/license generated vendored
View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

View File

@@ -1,16 +1,19 @@
{
"name": "locate-path",
"version": "5.0.0",
"version": "7.2.0",
"description": "Get the first path that exists on disk of multiple paths",
"license": "MIT",
"repository": "sindresorhus/locate-path",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=8"
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"scripts": {
"test": "xo && ava && tsd"
@@ -35,11 +38,11 @@
"iterator"
],
"dependencies": {
"p-locate": "^4.1.0"
"p-locate": "^6.0.0"
},
"devDependencies": {
"ava": "^1.4.1",
"tsd": "^0.7.2",
"xo": "^0.24.0"
"ava": "^3.15.0",
"tsd": "^0.17.0",
"xo": "^0.44.0"
}
}

59
node_modules/locate-path/readme.md generated vendored
View File

@@ -1,21 +1,19 @@
# locate-path [![Build Status](https://travis-ci.org/sindresorhus/locate-path.svg?branch=master)](https://travis-ci.org/sindresorhus/locate-path)
# locate-path
> Get the first path that exists on disk of multiple paths
## Install
```
$ npm install locate-path
```
## Usage
Here we find the first file that exists on disk, in array order.
```js
const locatePath = require('locate-path');
import {locatePath} from 'locate-path';
const files = [
'unicorn.png',
@@ -23,16 +21,13 @@ const files = [
'pony.png'
];
(async () => {
console(await locatePath(files));
//=> 'rainbow'
})();
console(await locatePath(files));
//=> 'rainbow'
```
## API
### locatePath(paths, [options])
### locatePath(paths, options?)
Returns a `Promise<string>` for the first path that exists or `undefined` if none exists.
@@ -40,23 +35,23 @@ Returns a `Promise<string>` for the first path that exists or `undefined` if non
Type: `Iterable<string>`
Paths to check.
The paths to check.
#### options
Type: `Object`
Type: `object`
##### concurrency
Type: `number`<br>
Default: `Infinity`<br>
Type: `number`\
Default: `Infinity`\
Minimum: `1`
Number of concurrently pending promises.
The number of concurrently pending promises.
##### preserveOrder
Type: `boolean`<br>
Type: `boolean`\
Default: `true`
Preserve `paths` order when searching.
@@ -65,27 +60,27 @@ Disable this to improve performance if you don't care about the order.
##### cwd
Type: `string`<br>
Type: `URL | string`\
Default: `process.cwd()`
Current working directory.
The current working directory.
##### type
Type: `string`<br>
Default: `file`<br>
Values: `file` `directory`
Type: `string`\
Default: `'file'`\
Values: `'file' | 'directory'`
The type of paths that can match.
##### allowSymlinks
Type: `boolean`<br>
Type: `boolean`\
Default: `true`
Allow symbolic links to match if they point to the chosen path type.
### locatePath.sync(paths, [options])
### locatePathSync(paths, options?)
Returns the first path that exists or `undefined` if none exists.
@@ -93,11 +88,11 @@ Returns the first path that exists or `undefined` if none exists.
Type: `Iterable<string>`
Paths to check.
The paths to check.
#### options
Type: `Object`
Type: `object`
##### cwd
@@ -111,12 +106,18 @@ Same as above.
Same as above.
## Related
- [path-exists](https://github.com/sindresorhus/path-exists) - Check if a path exists
---
## License
MIT © [Sindre Sorhus](https://sindresorhus.com)
<div align="center">
<b>
<a href="https://tidelift.com/subscription/pkg/npm-locate-path?utm_source=npm-locate-path&utm_medium=referral&utm_campaign=readme">Get professional support for this package with a Tidelift subscription</a>
</b>
<br>
<sub>
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
</sub>
</div>