0.0.4 • Published 12 years ago

redscript v0.0.4

Weekly downloads
48
License
-
Repository
github
Last release
12 years ago

RedScript

A Ruby flavored superset of JavaScript

  • Paste in compatibility with JS (except a few keywords)
  • Cleaner syntax for AMD modules (or opt out)
  • Easier prototypal inheritance
  • Cleaner ES5 object literals
  • Optional Ruby/CoffeeScript like aliases
  • String interpolation
  • Arrow function -> and (foo, bar) ->
  • ------ Check History.md for current working syntax ------

RedScript was created to provide a better syntax for AMD modules and to provide a few aliases to make things a bit nicer to work with (my favs being func, @, puts, ->, and >>).

It was also created as a side project to learn more about Node, NPM Modules and Regular Expressions. In the future I would also like to add a propper lexer/parser to implement more advanced features like optional parens and optional var declarations (feel free to fork!).

You can read more about it on my blog: Introducing RedScript.

To Install and Run

npm install -g redscript

redscript fileName1.rs fileName2.rs
redscript watch fileName1.rs fileName2.rs

Learning RedScript is easy, add a bit here and there until you're comfortable!

# No RedScript syntax, still works!
function sayHello(name) {
  console.log("Hello " + name);  
}

# A little bit of RedScript, func is a more terse alias function, string interpolation
func sayHello(name) {
  console.log("Hello #{name}");
}


 # A lot of RedScript, alias brackets with do/end, puts aliases console.log
func sayHello(name) do
  puts "Hello #{name}"
end

A better AMD RequireJS syntax

define module                                                   define(
require 'jquery' as $                                           ['jquery',
require './views/widget'  as Widget                             './views/widget'], function($, Widget) {        

var options = {                                                    var options = {
  moonRoof: true,                                                    moonRoof: true,   
  seats: 5                                                           seats: 5      
}                                                                  }          
 
var getCost = 16899                                                var getCost = 16899;
var wheels = 4                                                     var wheels = 4;
 
# export literal compiles to an object that gets returned          // export literal compiles to an object that gets returned          
export                                                              return {   
  getCost                                                               getCost : getCost,
  hasMoonRoof from options.moonRoof                                     hasMoonRoof : options.moonRoof,   
  getWheels from wheels                                                 getWheels : wheels     
end                                                                 }           
                                                                }); 
define module
require "jquery" as $

# Arrow function, great for parameters, (opt parens not currently avail.)
myBtn.on 'click', ->
  $('.widget').slideToggle "slow"
end

# Alias @ with this.
model.on('change', @render)


# Private blocks
foo = 200
private
  foo = 10
end
alert(foo)  # alerts 200


# Paren free if/for/while
while foo is 200 do
  puts "I'm looping forever"
end

See more syntax examples on RedScript's website (coming soon)

githalytics.com alpha

0.1.0

12 years ago

0.0.12

12 years ago

0.0.11

12 years ago

0.0.10

12 years ago

0.0.9

12 years ago

0.0.8

12 years ago

0.0.7

12 years ago

0.0.6

12 years ago

0.0.4

12 years ago

0.0.3

12 years ago

0.0.1

12 years ago