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

View File

@@ -5,7 +5,15 @@
"use strict";
/** @template T @typedef {(string | Record<string, string | string[] | T>)[] | Record<string, string | string[] | T>} ContainerOptionsFormat */
/**
* @template T
* @typedef {Record<string, string | string[] | T>} Item
*/
/**
* @template T
* @typedef {(string | Item<T>)[] | Item<T>} ContainerOptionsFormat
*/
/**
* @template T
@@ -17,6 +25,9 @@
* @returns {void}
*/
const process = (options, normalizeSimple, normalizeOptions, fn) => {
/**
* @param {(string | Item<T>)[]} items items
*/
const array = items => {
for (const item of items) {
if (typeof item === "string") {
@@ -28,6 +39,9 @@ const process = (options, normalizeSimple, normalizeOptions, fn) => {
}
}
};
/**
* @param {Item<T>} obj an object
*/
const object = obj => {
for (const [key, value] of Object.entries(obj)) {
if (typeof value === "string" || Array.isArray(value)) {
@@ -38,7 +52,7 @@ const process = (options, normalizeSimple, normalizeOptions, fn) => {
}
};
if (!options) {
return;
// Do nothing
} else if (Array.isArray(options)) {
array(options);
} else if (typeof options === "object") {
@@ -87,5 +101,5 @@ const scope = (scope, options) => {
return obj;
};
exports.parseOptions = parseOptions;
exports.scope = scope;
module.exports.parseOptions = parseOptions;
module.exports.scope = scope;