Self documenting runtime interfaces.
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.

README.md

rfx

Self documenting runtime interfaces.

In rfx, interfaces are called fx. The r stands for rtype.

What does rfx do?

rfx lets you easily specify rtypes in standard JavaScript. What could be possible with rtypes?

  • Write code that documents itself.
  • Access type metadata inside your program at runtime.
  • Generate docs like JSDoc. (Future)
  • Enhance IDE tooling. (Future)
  • Optional runtime type checking. (Future)

It's driven by the idea originally inspired by Lisp: Code as data. We're extending this concept to type information and documentation metadata.

This provides several benefits, but importantly, it makes your code literally self-documenting, and paves the way for powerful in-app developer tooling that is not available using compile-time type systems such as TypeScript. (Note: The TypeScript team is actively working on runtime type reflection, but it currently requires you to opt-in to experimental TypeScript features, and it works using the unstable Reflect API proposal for some future ES Next).

Status - Ready for Testing & Feedback

The documentation features of rfx are working today. Feel free to experiment and open an issue with your comments.

Getting Started

rfx is super easy to use. In place of a regular function expression or declaration, call the rfx with a tagged template literal containing your rtype documentation. The rtype function is a curried function that will return a function that you pass your code into.

npm install --save rfx
import rfx from 'rfx';

const add2 = rfx`
// Take two values, a & b, and return the sum.
add2(a: n, b: n) => Number
`(
  (a, b) => a + b
);

add2.rfx(); // logs tagged description to the console.

See rtype for more info.

Brought to You by Learn JavaScript with Eric Elliott

eejs-screenshot

Join the chat at https://gitter.im/learn-javascript-courses/javascript-questions

An online course series for application developers. Ready to jump in? Learn more.