aster

2019-09-13 admin

aster是什么

什么是aster,Centralized aster API.

aster使用教程帮助文档

aster

NPM version Build Status

aster - AST-based code builder

What’s that

aster is reactive builder specialized for code processing and transformations. It’s built with debugging in mind and makes building JavaScript code more reliable and faster.

Why one more

Source maps are a great invention that is meant to simplify life by allowing developers to debug the original code (the one that they actually write, whatever language it is) on production.

However, using them is pretty hard in any of existing build systems whenever you have at least one plugin in your build pipeline - and you most likely do - that doesn’t support emitting them or even consuming from previous step; some plugins even treat code as simple strings discarding all it’s inner logic and structure.

Your code isn’t just a string. It has a soul and rich inner world and aster is built to treat it like that. As result, it provides complex yet easy and fast transformations that are transparent for browser debugger out of the box.

You can think of aster for JS as of rework for CSS.

But I like X builder! Should I throw it out?

Definitely no! aster doesn’t try to fight your favorite build system. It has only one specific area that it’s exceptionally good at - code processing. Everything else (CSS, images, publishing to CDN, etc.) is left for generic builders, and you can use them together.

Currently there are following bindings:

If you wish, you can define aster pipeline as custom task in any existing build system on your own since aster uses RxJS under the hood, which is interoperable with events, streams, promises, callbacks and any other asynchronous primitives and patterns out of the box.

API

aster is completely modular and main package is just a centralized API wrapper for core parts published as separate modules (check out their documentations for details):

Usage

First, install aster as a development dependency:

npm install --save-dev aster

Then, create build script and use it. Example (requires omitted):

aster.watch(['src/**/*.js', 'src/**/*.coffee', 'src/**/*.jsx'])
.throttle(500)
.map(changed(function (src) {
  return src.map(equery({
    'if ($cond) return $expr1; else return $expr2;':
      'return <%= cond %> ? <%= expr1 %> : <%= expr2 %>'
  }));
}))
.map(concat('built.js'))
.map(umd({exports: 'superLib'}))
.map(aster.dest('dist', {sourceMap: true}))
.subscribe(aster.runner);

aster doesn’t provide task runner - npm is already good one, and we don’t want to reinvent the wheel. You can simply define every needed task as separate script, or use aster as part of existing builder as mentioned before.

Creating plugins

Check out aster’s Yeoman generator.

It automizes the process of creating basic skeleton and Github repo for your plugin in few easy steps. When created, you just need to modify index.js and test.js files to reflect your intended plugin’s functionality (detailed hints included right in code).

License

MIT License

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处。

转载请注明:文章转载自 JavaScript中文网 [https://www.javascriptcn.com]

本文地址:https://www.javascriptcn.com/read-75030.html

文章标题:aster

相关文章
javascript if/else or ternary operator is faster?
user9009597Jeff提出了一个问题:Is ternary operator, if-else or logical OR faster in javascript?,或许与您遇到的问题类似。 回答者Andrew Hare给出了该问...
2018-04-23
urlmaster
urlmaster是什么 什么是urlmaster,URL, Web, testing urlmaster官网:官网 urlmaster源码仓库:源码仓库 urlmaster下载地址:点此下载 点此下载2 urlmaster使用教程帮助...
2018-10-17
config-master
config-master是什么 什么是config-master,Load stored configuration data config-master官网:官网 config-master源码仓库:源码仓库 config-maste...
2018-10-09
In JS, which is faster: Object&apos;s "in" operator or Array&apos;s indexof?
finishingmoveFishtoaster提出了一个问题:In JS, which is faster: Object’s “in” operator or Array’s indexof?,或许与您遇到的问题类似。 回答者T.J. ...
2018-04-16
Mastered in EVENT LOOP
setTimeout(() =&gt; { console.log(&#x27;I am the last one&#x27;) }, 0); function count () { for (var i = 0; i &lt; ...
2018-11-16
eastern
eastern是什么 什么是eastern,a minimal BDD framework for ESM Modules eastern官网:官网 eastern源码仓库:源码仓库 eastern下载地址:点此下载 点此下载2 eas...
2018-12-03
faster-stable-stringify
faster-stable-stringify是什么 什么是faster-stable-stringify,Faster deterministic JSON.stringify() without bells and whistles. ...
2018-10-13
vtex-masterdata
vtex-masterdata是什么 什么是vtex-masterdata,Helpers to manipulate data from Vtex Masterdata vtex-masterdata官网:官网 vtex-masterd...
2019-04-23
Is NodeJs faster than Clojure?
foobar提出了一个问题:Is NodeJs faster than Clojure?,或许与您遇到的问题类似。 回答者Communitydnolen给出了该问题的处理方式: (set! *unchecked-math* true) (...
2018-04-21
Why is iterating through an array backwards faster then forwards
mc01samccone提出了一个问题:Why is iterating through an array backwards faster than forwards,或许与您遇到的问题类似。 回答者Bergi给出了该问题的处理方式: B...
2018-04-13
回到顶部