giovandyyg
Version:
"Lee y analiza archivos en formato Markdown, para verificar los links que contengan y reportan algunas estadÃsticas."
50 lines (41 loc) • 1.75 kB
JavaScript
import { getLinks, optionValidate } from './utils1.js'
// const functionMdLinks = require('./utils1.js');
// export default mdLinks;
export const mdLinks = (route, options) => {
if (options.validate === true) {
return optionValidate(route)
// .then(resp => resp).catch(err => err);
}
if (options.validate === false) {
return new Promise(resolve => resolve(getLinks(route)));
}
};
// export default mdLinks;
// module.exports = mdLinks;
// console.log('Prueba de mdLinks, validate false');
// console.log(mdLinks('prueba1.md', { validate: true }));
// mdLinks('./test/prueba/Documento/prueba4.md', { validate: false }).then(res=>console.log(res));
// mdLinks('./test/prueba/Documento/prueba4.md',{validate:true}).then(res=>console.log(res));
// console.log('');
// const mdLinks = (path, options) => {
// const allLinks = new Promise((resolve, reject) => {
// if (functionMdLinks.pathValid(path)) {
// if (options.validate === false) {
// resolve(functionMdLinks.getLinks(path));
// } else if (options.validate === true) {
// return (functionMdLinks.optionValidate(path).then((links) => resolve(links)));
// } else {
// // reject ((new Error('Option invalidate: ')).message)
// reject('Parametro invalido ');
// }
// } else {
// // reject ((new Error('Path is not valid ')).message)
// reject(console.log('Path is not valid'))
// }
// });
// return allLinks;
// };
// // mdLinks(ruta1, option1).then(res => console.log(res));
// module.exports = { mdLinks };
// console.log(mdLinks('prueba1.md', { validate: true }));
// // console.log(mdLinks('README.md', { validate: false }))