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

oj-node

v0.0.3

Published

Run OJ in Node, just like any other JS. <3 ObjC and OJ!

Downloads

7

Readme

oj-node

This is a very, very, very basic bit of code that works similar to CoffeeScript's "register". It makes .oj code able to be required just like other code. The state is saved locally int he module, so it can not be tampered with, nor can it be accidentially deleted. It simply exists in it's own little scope.

The global $oj_oj variable is required for the runtime. Feel free to tamper with OJ itself by requireing the runtime! If you want to do so, install it as a peer dependency.

Very basic, very easy.

require("oj-node");
require("./Application.oj");
// Or without extension:
require("./Application");

Rules of thumb when using oj-node:

  • Define classes globally. Making defined inside a class is a) pointless and b) would break compilation.
  • The @class keyword has no effect, except when the class was not already require'd. Then again, you could just require it and are good to go.
  • You can not module.export classes directly; you also don't need to either. Once defined, they are avilable everywhere. Re-requireing the respective files does not crash the compilation. All it will do is give back the exported data from module.exports, but the file, like usual, is not re-run.
  • There is only one compile state. If one class tries to override another, an Exception is thrown and you risk crashing the process.
  • OJ files have advanced syntax, but are compiled down to JS before execution. That means they behave exactly the same.

Why?

Many people use libraries to add class support to their applications. There also are people using CoffeeScript in exactly this manner - so I decided to try if it works with OJ. And looky, it does :). I like objective-c and already am using OJ in my front-end coding (to a point I even wrote a language pack for Atom...) and so I wanted to see if this works with NodeJS. Well - let's see how far I can push this.

Yes, this project is partially a PoC. It works, but I KNOW that OJ wasn't originally meant for this use :) However...trying does not hurt!

install

Do your typical NPM-dance and you're good to go.

npm install --save oj-node

REPL

There is a tiny REPL I wrote that you can use to communicate with a script you wrote and test functionality. It is like the regular NodeJS REPL, just that it will also accept and understand OJ.

To use it, you have to install this package using --global or -g. Then just type in oj in your command shell.

[email protected] ~ $ oj
oj>

#-macro support?

I do have a project that supports it - but it works asynchronously to an extend where deasync would be more painful than helpful. If you want that, consider pre-compiling your code.

Module support?

Yep. Theoretically, you should be able to specify a .oj file in a package.json's main entry and it should work. But unless your users include this module, it makes no sense. Consider using a NPM script to compile your module upon installation.