Giter Club home page Giter Club logo

sweetify's Introduction

sweetify deprecated

This module has been replaced by @andreypopp's implementation, which you can find here.

A browserify transform for sweet.js, which brings hygienic macros to JavaScript.

Installation

npm install sweetify

Usage

browserify -t sweetify index.sjs

require.macro(file)

You might want to have to avoid copying and pasting your macros between files, so included is an unofficial means to require them into your script.

Take, for example, first.sjs:

// first.sjs
macro first {
  case ($a + $b) => { $a }
}

You can use require.macro to include its contents in your script.

// index.sjs
require.macro('./first.sjs')

var x = first(1 + 2)
console.log(x)

Bundling index.sjs will result in output along these lines:

// bundle.js
var x$2 = 1;
console.log(1);

require.macro uses browser-resolve to find the file too, so you can throw your macros up on NPM if you so please.

Note however that inlining is pretty rudimentary: it literally prepends the file contents to your script before passing it to sweet.js. Pull requests are welcome if you find a way to bend the parser to exclude everything but the macros, or any other improvements you can think of :)

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.