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

@flybywiresim/rnp

v2.1.0

Published

RNP is a language which compiles to [RPN][], a scripting language used by MSFS.

Downloads

1,383

Readme

RNP

RNP is a language which compiles to RPN, a scripting language used by MSFS.

RNP provides a familiar and expressive environment with strict types. In the future it may also perform optimization.

API

const { Type, translate } = require('@flybywiresim/rnp');

// function to resolve imports
function getSource(
  referrer,  // specifier of importing module
  specifier, // specifier of module to be imported
) {
  // return `null` if module can't be resolved.
  return {
    source,    // source of imported module
    specifier, // resolved specifier, e.g. `dirname(referrer).join(specifier)`
  };
}

const {
  output,    // string RPN output
  messages,  // [{ level, message, location }]
} = translate(source, {
  specifier,   // defaults to '(anonymous)'
  returnType,  // defaults to `Type.VOID`
  getSource,   // defaults to resolution error
});

Types

  • boolean - true or false.
  • number - IEEE-754 double precision floating point number.
  • string - A string type.
  • any - Used for unknown types. No builtin in the language allows this type, but some expressions may be valid with it, for example (L:X) = (L:Y).
  • void - The absence of a value. An example of an expression which produces void is if true {}.

Syntax

Comments

Line Comments

Comment out a single line.

// this is a line comment

Block Comments

Comment out multiple lines. Nesting is allowed.

/* this
comment
is
longer
*/
/*

/*
comment doesn't end here
*/

comment ends here
*/

Declarations

Locals

Declare a local.

let a = 1;

Aliases

SimVars can be aliased to local names.

alias x = (L:X, bool);

x = true; // set L:X to true
if x {    // if L:X is true
}

Macros

Declare a macro. Macros may be exported using export. Macros are "hygienic", meaning that identifiers may not be implicitly leaked into or out of a macro scope. Macros parameters use $ to avoid being confused with normal variables.

macro add($a, $b) {
  $a + $b
}
export macro sub($a, $b) {
  $a - $b
}
macro assign($a) {
  $a = 1;
}

let b = 0;
// does not break hygiene rules because `b` was explicitly passed
assign(b);

Imports

Macros can be imported from other files using import.

import { sub } from './file.rnp';

Assignments

Locals

Assign a value to a local.

a = 1;

SimVars

Assign a value to a SimVar.

(X:Y) = 1;
(X:Y, unit) = 1;

Expressions

Literals

// booleans
true;
false;

// numbers
1.0;
0x10;
0b101010;

// strings
'hello';

Locals

Reference a local.

a

SimVars

Reference a SimVar.

(X:Y)
(X:Y, unit)

Inserts

Allows XML substitutions. Expressions must be typed.

let x = #X, bool#;
#Y#;

Macro Expansion

Expand a macro.

add(1, 2);

Blocks

{
  1
}

If Expressions

Conditional evaluation, may be used as an expression.

if x {
}
if x {
} else {
}
if x {
} else if y {
} else {
}
let a = if x { 1 } else { 2 };

Binary and Unary Operators

Mathematical and relational operations.

1 + 1;
1 / 1;
'hello' == 'hello';
// etc...

!true
~1
// etc...

Method Operations

RPN provides several standard operations. These operations are available in RNP as method-ish syntax.

8.log(2);
'hello'.toUpperCase();