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 🙏

© 2024 – Pkg Stats / Ryan Hefner

gcodejs

v0.0.1

Published

a module for processing gcode

Downloads

6

Readme

GCode JS - statemachine to parse GCode

This package contains a statemachine based parser to parse GCode in node or (possibly) in the browser.

Caveats

It's fairly rough around the edges at the moment. No support for parameters

Usage

Should be fairly straightforward to use. Require require parser.js:

var gcode = require("./parser.js")

Afterwards, instantiate the parser, with a callback (see below) and optional configuration:

var parser = new gcode.GCode(cb, cfg)

Call parse on any data / chunks of data you receive. Typically (see config, below) parse will emit data for each event to the callback adn return true or terminate processing, returning false after an error is encountered and error data is emitted.

... get data from somewhere ...
if (!parser.parse(data)) {
  .. quit parsing ...
}

CALLBACK

The callback you pass to the GCode constructor will receive data describing one of the following events:

  • BLOCK_START : start of a block (line)
  • BLOCK_END : end of a block (line)
  • BLOCK_DEL : indicates a leading '/'
  • WORD : a complete word, e.g. G00, M02, X12.12
  • COMMENT : the text of a comment
  • ERROR : an error

Data passed to the callback is a hash an will always contain the following parameters:

  • ev : one of gcode.Events.BLOCK_START, ...BLOCK_END, (...)
  • line_no : the line currently being processed (line of the file, not the line indicated by N words.

ERROR events also have the following parameters: msg the error message and state which is the internal state of the parser and is only useful for debugging, this will likely be omitted in the future.

WORD events have the following additional parameters: code the letter part of the word and value the value part. Unless you configure the parser to do otherwise, it will also contain a desc parameter with a humanreadable describtion of the command.

COMMENT contains a parameter called comment containing the text of the comment, stripped of comment delimiters.

Configuration

The optinal cfg parameter that may be passed to the constructor is a hash which may currently contain two configuration options:

  • continue_on_err : don't return false from parse after an error has been emitted, instead, try to recover (this may void your warranty)
  • no_annotate : don't append the desc parameter to word events.

Motivation

This will be part of a JS based CNC control for the Anykey[1] /Anycnc[2]

TODO

Write a proper example driver for anycnc ... Package nicely for npm.

License

MIT

FILES

README.md : this file anycnc.js : example drive, extremly wip test : test fixtures make_json_fixtures.js : pre-parse fixture data for test parser.js : the actual parser test_gcode.js : run tests.

[1] http://www.anykey0x.de [2] http://blog.anykey0x.de/?p=60