0.4.0 • Published 10 years ago

language v0.4.0

Weekly downloads
22
License
BSD-2-Clause
Repository
github
Last release
10 years ago

Language

language is a very small library for building DSLs in Javascript.

npm install language

Why?

Because magic scope! and because no globals!

var language = require('language');

var robot = language({
  position: {x: 0, y: 0},

  moveLeft: function() {
    this.position.x--;
  },

  moveRight: function() {
    this.position.x++;
  },

  moveUp: function() {
    this.position.y--;
  },

  moveDown: function() {
    this.position.y++;
  },
});

robot(function () {
  console.log(position);

  moveDown();
  console.log(position);

  moveRight();
  console.log(position);
});

How?

Read the source, it's small.