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

oma-parser-js

v1.0.1

Published

Parseur pour fichiers OMA (Optician's Measurement Archive) - Traitement des données optiques

Readme

OMA Parser

Un parseur JavaScript/TypeScript pour les fichiers OMA (Optician's Measurement Archive) utilisé pour traiter les données de verres optiques.

Installation

npm install oma

Utilisation

JavaScript/Node.js

const OMAParser = require('oma');
const fs = require('fs');

// Lire le fichier OMA
const fileContent = fs.readFileSync('votre-fichier.oma', 'utf8');

// Parser le contenu
const parser = new OMAParser(fileContent);
const result = parser.parse();

console.log('Job:', result.data.job);
console.log('Fabricant:', result.data.manufacturer);
console.log('Points de perçage:', result.drillingPoints);
console.log('Trace droite:', result.rightTrace.radii);

TypeScript

import OMAParser from 'oma';

const parser = new OMAParser(fileContent);
const result = parser.parse();

// Conversion des données polaires en cartésiennes
const cartesianPoints = OMAParser.polarToCartesian(
  result.rightTrace.radii,
  result.rightTrace.scaleFactor
);

Navigateur (ES6 Modules)

<script type="module">
  import OMAParser from './node_modules/oma/dist/index.js';
  
  // Utilisation identique
  const parser = new OMAParser(fileContent);
  const result = parser.parse();
</script>

Navigateur (Global)

<script src="./node_modules/oma/dist/index.js"></script>
<script>
  const parser = new OMAParser(fileContent);
  const result = parser.parse();
</script>

API

OMAParser

Constructeur

  • new OMAParser(fileContent: string) - Crée une nouvelle instance avec le contenu du fichier OMA

Méthodes

  • parse(): ParsedOMA - Parse le fichier et retourne les données structurées
  • OMAParser.polarToCartesian(radii: number[], scaleFactor?: number): Point2D[] - Convertit les coordonnées polaires en cartésiennes

Structure des Données

ParsedOMA

{
  data: OMAData;           // Données de base du verre
  drillingPoints: DrillingPoint[];  // Points de perçage
  leftTrace: TraceData;    // Trace gauche
  rightTrace: TraceData;   // Trace droite
}

OMAData

Contient toutes les métadonnées du verre:

  • job: Identifiant du travail
  • manufacturer: Fabricant
  • frame: Cadre
  • eyeSize: Taille de l'œil
  • dbl: Distance entre verres
  • Et bien d'autres propriétés...

DrillingPoint

{
  x: number;        // Coordonnée X
  y: number;        // Coordonnée Y
  diameter: number; // Diamètre de perçage
  x2?: number;      // Coordonnée X secondaire (optionnel)
  y2?: number;      // Coordonnée Y secondaire (optionnel)
  angle?: number;   // Angle (optionnel)
  type?: string;    // Type de perçage (optionnel)
}

TraceData

{
  radii: number[];      // Données de rayon polaire
  format: string;       // Format de la trace
  scaleFactor: number;  // Facteur d'échelle (0.01 pour 1/100mm vers mm)
}

Exemple Complet

const OMAParser = require('oma');
const fs = require('fs');

try {
  const fileContent = fs.readFileSync('exemple.oma', 'utf8');
  const parser = new OMAParser(fileContent);
  const result = parser.parse();
  
  // Afficher les informations de base
  console.log(`Job: ${result.data.job}`);
  console.log(`Fabricant: ${result.data.manufacturer}`);
  console.log(`Taille: ${result.data.eyeSize}`);
  
  // Afficher les points de perçage
  result.drillingPoints.forEach((point, index) => {
    console.log(`Point ${index + 1}: (${point.x}, ${point.y}) - Ø${point.diameter}mm`);
  });
  
  // Convertir la trace droite en coordonnées cartésiennes
  const cartesian = OMAParser.polarToCartesian(result.rightTrace.radii);
  console.log(`Trace convertie: ${cartesian.length} points`);
  
} catch (error) {
  console.error('Erreur lors du parsing:', error);
}

Support

Pour les questions ou problèmes, ouvrez une issue sur le repository GitHub.

License

MIT