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

fast-gcode-analyzer

v1.3.8

Published

Libreria per analizzare file G-code di stampe 3D, calcolare layer, filamento e spreco

Readme

📊 fast-gcode-analyzer

Libreria per analizzare file G-code di stampe 3D e calcolare statistiche come layer, filamento, tempo di stampa e costi stimati.


🧩 Slicer Supportati

  • 🐼 Bambu Studio / Bambu Lab
  • 🐋 OrcaSlicer
  • 🏗️ Creality Print
  • ⚙️ Anycubic

✨ Caratteristiche

  • Estrazione Dati Essenziali: Legge tempo di stampa, lunghezza del filamento, numero di layer, altezza layer, ecc.
  • Calcolo Costi: Stima il peso e il costo del materiale anche se non sono specificati nel G-code.
  • Progettata per l'Integrazione: Usabile come libreria Node.js in progetti propri o CLI tool.
  • Leggera: Nessuna dipendenza esterna.

📦 Installazione

Installa il pacchetto nel tuo progetto tramite npm:

npm install fast-gcode-analyzer

🚀 Utilizzo
🔹 CommonJS (predefinito in Node.js)

✅ Metodo consigliato se non hai "type": "module" nel tuo package.json.
const { parseGCode } = require("fast-gcode-analyzer");

(async () => {
  const filePath = "./esempi/test_bambu.gcode";
  const pricePerKg = 20; // €/kg (opzionale)

  try {
    console.log(`\n🔬 Analizzando il file: ${filePath}...`);
    const stats = await parseGCode(filePath, pricePerKg);
    console.log("\n📊 Risultato Analisi G-code:");
    console.log(stats);
  } catch (error) {
    console.error("❌ Errore:", error.message);
  }
})();

🔹 ES Module (ESM)

Usa questo formato se nel tuo package.json è presente "type": "module".
import { parseGCode } from "fast-gcode-analyzer";

(async () => {
  const filePath = "./esempi/test_bambu.gcode";
  const stats = await parseGCode(filePath, 15); // 15 €/kg
  console.log(stats);
})();

⚙️ API Reference
parseGCode(filePath, pricePerKg?)
Parametro	Tipo	Descrizione
filePath	String	Obbligatorio. Percorso del file .gcode da analizzare.
pricePerKg	Number	Opzionale. Prezzo del filamento in €/kg per il calcolo del costo.
Oggetto Restituito

Restituisce una Promise che risolve in un oggetto con le seguenti proprietà:

Proprietà	Tipo	Descrizione
slicer	String	Nome dello slicer rilevato.
filamentType	String	Tipo di filamento (es. "PLA", "PETG", "1" per multi-material).
filamentLengthM	Number	Lunghezza del filamento in metri.
filamentWeight	Number	Peso stimato del filamento in grammi (g).
filamentCost	Number	Costo stimato del filamento in euro (€).
printTimeFormatted	String	Tempo di stampa stimato in formato leggibile.
printTimeSeconds	Number	Tempo di stampa stimato in secondi.
totalLayers	Number	Numero totale di layer.
layerHeight	Number	Altezza del layer in millimetri (mm).
🖥️ Esempi di Output
🔸 Bambu Studio / Bambu Lab
{
  "slicer": "Bambu Studio",
  "filamentType": "1",
  "filamentLengthM": 71.05,
  "filamentWeight": 211.9,
  "filamentCost": 4.24,
  "printTimeFormatted": "5h 19m 28s",
  "printTimeSeconds": 19168,
  "totalLayers": 350,
  "layerHeight": 70.2
}

🔸 OrcaSlicer
{
  "slicer": "OrcaSlicer",
  "filamentType": "PLA",
  "filamentLengthM": 120.5,
  "filamentWeight": 358.1,
  "filamentCost": 5.37,
  "printTimeFormatted": "3h 45m",
  "printTimeSeconds": 13500,
  "totalLayers": 150,
  "layerHeight": 0.2
}

📌 Note

Se il file G-code non contiene informazioni su peso o costo, la libreria li stima automaticamente.

Il calcolo del peso assume filamento PLA 1.75 mm (~2.97 g/m).

Compatibile con file G-code generati da slicer multipli, anche misti.

📜 Licenza

Rilasciato sotto licenza MIT.
Copyright © 2025
Gabriele Dell'Aquila (Spongix)