Giter Site home page Giter Site logo

esy-language's Introduction

Esy

NPM

CircleCI npm version downloads dependencies license Gitter chat

Esy Logo

Esy is a new JS preprocessor allows you to use custom block structures.

What does it mean?

Right now in JavaScript and many other languages that support the block structure, you're only able to use some predefined structures like:

  1. if (){...}
  2. for (){...}
  3. while (){...}
  4. do {...} while();
  5. switch (){...}
  6. else {...}
  7. try {...}
  8. catch (){...}
  9. finally (){...}
  10. etc...

Those are all familiar structures to you, but have you ever thought about the following structure?

timeout 200 {
   console.log("Hello World!");
}

Certainly, it's easier than what we have in JS right now:

setTimeout(function() {
   console.log("Hello World!");
}, 200);

Or even with arrow functions:

 setTimeout(() => {
    console.log("Hello World!");
 }, 200);

That why Esy comes from Easy

Install

You can install this package globally by running:

npm install esy-language -g

but if you're interested in the core API and wants to use it in your own package just run:

npm install esy-language --save

Example

After installing the Esy, save this file as ex.esy

// Cache sum for 500ms
cache 500 sum(a,b){
	console.log('Computing...');
	return a+b;
} key (c,d){
	// We don't care about numbers order in sum function (a+b=b+a)
	return [c, d].sort();
}

// Compute 5+7 once
console.log(sum(5,7))

// Load theme from cache without computing
console.log(sum(5,7))
console.log(sum(7,5))

// Wait 100ms more than cache's lifetime.
timeout 600{
	// It should compute 5+7 again
	console.log(sum(7,5))
}

and then cd to the directory that your file is and run this command to run program:

esy ex.esy

for saving result to a file run:

esy compile ex.esy -s

Docs

Read official docs for more details.

Testing

To run tests just run:

git clone https://github.com/Slye-team/esy-language.git
cd esy-language
npm run test

esy-language's People

Contributors

qti3e 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.