GithubHelp home page GithubHelp logo

runt18 / sweet.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mathiasbynens/sweet.js

0.0 3.0 0.0 6.25 MB

Sweeten your JavaScript.

Home Page: http://sweetjs.org

License: BSD 2-Clause "Simplified" License

JavaScript 98.01% HTML 1.19% CSS 0.80%

sweet.js's Introduction

Build Status

sweet.js

Hygienic Macros for JavaScript!

  • Read a tutorial on macros.
  • Read the documentation at sweetjs.org.
  • Play with the editor.
  • Hang out on IRC #sweet.js at irc.mozilla.org.
  • Try out other macros.

Getting started

Install sweet.js with npm:

$ npm install -g sweet.js

And compile your sweet macro enhanced code:

$ sjs --output compiled.js my_sweet_code.js

Sharing

You can collect your macros into a single module file to share with your other code or on npm. Full details here but the basic idea is to define your macros in a file macros.js and use the export keyword:

// macros.js
macro m { ... }
export m;

Then compile using the --module flag:

sjs --module /macros.js my_sweet_code.js

The --module also looks up along the npm path so you can install macro modules from npm (using lambda-chop as an example):

npm install lambda-chop
sjs --module lambda-chop/macros my_sweet_code.js

If you want to share your macros on npm we recommend using the sweet-macros keyword to make macros easy to find.

Hacking

Install the dev dependencies:

$ npm install

Build and run the tests:

$ grunt

Sweet.js is self hosted so you hack on the files in src/ using the version of sweet.js already built in lib/. When you are happy with your hacking, grunt dist will build a new version of sweet.js and put it into lib/.

Slightly confusing but the process goes like this:

<hack hack hack>
$ grunt
<tests fail!>
<hack hack hack>
$ grunt
<tests pass!>
$ grunt dist
$ git add lib/
$ git commit -m "sweet!"

Credits

Built on top of esprima and escodegen. Contributors are awesome!

sweet.js's People

Contributors

disnet avatar natefaubion avatar jlongster avatar srikumarks avatar puffnfresh avatar carlqlange avatar int3 avatar andreypopp avatar escalant3 avatar magnetised avatar lantiga avatar matthewrobb avatar iammerrick avatar paxa avatar parndt avatar tuchida avatar

Watchers

James Cloos 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.