Giter Site home page Giter Site logo

oltdaniel / watasu Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 0.0 82 KB

customizable abstract function layer for your JavaScript application

Home Page: https://oltdaniel.eu/watasu/

License: GNU General Public License v3.0

JavaScript 61.70% CSS 3.96% HTML 34.35%
interpreter scripting-language

watasu's Introduction

watasu

Watasu (Japanese: 渡す; English: pass on) is a simple JavaScript abstraction, that simply passes on a function call from a safe run context to the outside. This allows for a quick execution, as the program will only describe the order and values of calls in native JavaScript.

Example

This is a screenshot of the example that can be found in ./index.html. It is deployed at oltdaniel.eu/watasu.

Usage

The project is compiled as an esmodule. So you can use it like:

<script type="module">
  import Watasu from 'http://cdn.jsdelivr.net/gh/oltdaniel/watasu/dist/watasu.js';

  const watasu = new Watasu();
  watasu.loadProgram(`
  set(sum, 0);
  inc(sum);
  print("current sum is ", sum);
  `);

  watasu.registerCall('set', function set(name, value) {
    if (name.name === 'dataReference') {
      this._context[name.value] = this.resolveParameterValue(value);
    } else {
      throw new Error('invalid set call');
    }
  })
  watasu.registerCall('inc', function inc(name) {
    if (name.name === 'dataReference') {
      this._context[name.value]++;
    } else {
      throw new Error('invalid inc call');
    }
  })
  watasu.registerCall('print', function print(...args) {
    console.log(...this.resolveParametersValues(args));
  })

  while(!watasu._runner.isDone) {
    watasu.step();
  }
</script>

Developing

We use esbuild because it is easy and supports exactly what we need to build a simple library.

# get the repo
git clone https://github.com/oltdaniel/watasu.git
cd watasu
# start live rebuild
yarn watch
# fix all eslint errors
yarn eslint . --fix
# all changes done. do production build
yarn build
# commit

License

Do what you'd like to do. But keep sharing it publicly.

GitHub

watasu's People

Contributors

oltdaniel avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.