npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

valkream-function-lib

v1.0.7

Published

Une librairie de fonctions utiles pour le développement de gestionnaire de serveur

Downloads

11

Readme

Valkream Function Lib

Une bibliothèque de fonctions utilitaires pour le développement de gestionnaires de serveur, spécialement conçue pour la gestion de fichiers, la compression/décompression et les interactions console.

📦 Installation

npm install valkream-function-lib

🚀 Utilisation

const {
  cleanGameFolder,
  consoleQuestion,
  consoleStreamAnswer,
  downloadZip,
  formatBytes,
  getAllFilesInAFolder,
  hashFolder,
  sendZip,
  zipFolder,
  unZip,
} = require("valkream-function-lib");

📚 Fonctions Disponibles

🔧 Utilitaires de Formatage

formatBytes(bytes)

Convertit des bytes en format lisible (B, KB, MB, GB, TB).

const { formatBytes } = require("valkream-function-lib");

console.log(formatBytes(1024)); // "1.0 KB"
console.log(formatBytes(1048576)); // "1.0 MB"

💬 Interactions Console

consoleQuestion(question)

Pose une question à l'utilisateur via la console et retourne sa réponse.

const { consoleQuestion } = require("valkream-function-lib");

const answer = await consoleQuestion("Voulez-vous continuer ? (y/n)");
console.log(`Réponse: ${answer}`);

consoleStreamAnswer(message)

Affiche un message formaté dans la console avec timestamp.

const { consoleStreamAnswer } = require("valkream-function-lib");

consoleStreamAnswer("Téléchargement en cours...");

📁 Gestion de Fichiers

getAllFilesInAFolder(folderPath)

Récupère tous les fichiers d'un dossier et ses sous-dossiers.

const { getAllFilesInAFolder } = require("valkream-function-lib");

const files = getAllFilesInAFolder("./mon-dossier");
console.log(files); // Array de chemins de fichiers

hashFolder(folderPath, algorithm)

Génère un hash SHA-256 de tous les fichiers d'un dossier.

const { hashFolder } = require("valkream-function-lib");

const hash = await hashFolder("./mon-dossier", "SHA-256");
console.log(`Hash du dossier: ${hash}`);

cleanGameFolder(folderPath)

Nettoie un dossier de jeu en supprimant les fichiers temporaires.

const { cleanGameFolder } = require("valkream-function-lib");

const foldersToClean = [
  /* exemple */ "/folder1/temp",
  "/folder40/subfolder2/cache",
];

await cleanGameFolder("./mon-jeu", foldersToClean);

📦 Compression et Décompression

zipFolder(sourceFolderPath, zipOutputPath, callback, cancellationToken)

Compresse un dossier en fichier ZIP avec progression.

const { zipFolder } = require("valkream-function-lib");

await zipFolder(
  "./dossier-a-compresser",
  "./archive.zip",
  (processedBytes, totalBytes, fileName, speed) => {
    console.log(`Compression: ${fileName} - ${formatBytes(processedBytes)}`);
  }
);

unZip(zipPath, extractPath, callback, cancellationToken)

Décompresse un fichier ZIP avec progression.

const { unZip } = require("valkream-function-lib");

await unZip(
  "./archive.zip",
  "./dossier-destination",
  (processedBytes, totalBytes, fileName, speed) => {
    console.log(`Décompression: ${fileName} - ${formatBytes(processedBytes)}`);
  }
);

🌐 Téléchargement et Envoi

downloadZip(downloadUrl, destPath, callback)

Télécharge un fichier ZIP avec barre de progression et limitation de vitesse.

const { downloadZip } = require("valkream-function-lib");

await downloadZip(
  "https://example.com/file.zip",
  "./telechargement.zip",
  (downloadedBytes, totalBytes, percent, speed) => {
    console.log(`Téléchargement: ${percent}% - ${formatBytes(speed)}/s`);
  }
);

sendZip(zipPath, uploadUrl, callback)

Envoie un fichier ZIP vers une URL avec progression.

const { sendZip } = require("valkream-function-lib");

await sendZip(
  "./archive.zip",
  "https://api.example.com/upload",
  (uploadedBytes, totalBytes, percent, speed) => {
    console.log(`Envoi: ${percent}% - ${formatBytes(speed)}/s`);
  }
);

🔧 Configuration

Callbacks de Progression

Toutes les fonctions de compression, décompression, téléchargement et envoi acceptent des callbacks personnalisés :

const callback = (processedBytes, totalBytes, fileName, speed) => {
  const percent =
    totalBytes > 0 ? ((processedBytes / totalBytes) * 100).toFixed(1) : 0;
  console.log(`${fileName}: ${percent}% - ${formatBytes(speed)}/s`);
};

Tokens d'Annulation

Les opérations longues peuvent être annulées :

const cancellationToken = { cancelled: false };

// Dans une autre partie du code
cancellationToken.cancelled = true;

📦 Dépendances

  • archiver - Compression ZIP
  • axios - Requêtes HTTP
  • extract-zip - Décompression ZIP
  • form-data - Envoi de données multipart
  • progress-stream - Suivi de progression
  • stream-throttle - Limitation de vitesse
  • unzipper - Décompression ZIP alternative

🤝 Contribution

Les contributions sont les bienvenues ! N'hésitez pas à :

  1. Fork le projet
  2. Créer une branche pour votre fonctionnalité
  3. Commiter vos changements
  4. Pousser vers la branche
  5. Ouvrir une Pull Request

📄 Licence

Ce projet est sous licence MIT.

👥 Auteurs

Valkream Team


Version: 1.0.6