我正在用它的.styl API:http://learnboost.github.io/stylus/docs/js.html编译我的Stylus JavaScript样式表
var stylus = require('../')
, str = require('fs').readFileSync(__dirname + '/test.styl', 'utf8');
stylus(str)
.set('filename', __dirname + '/test.styl')
.import('mixins/vendor')
.render(function(err, css){
if (err) throw err;
console.log(css);
});它没有提到它使用的回调是同步的还是异步的。虽然在我的经验中,它似乎是同步的,但我不确定。是吗?
发布于 2015-01-23 16:30:18
render函数是伪异步的,因为它接受回调,但是函数中的所有调用实际上都是同步的。这个函数也有一个完全同步的版本(如果您不提供回调):
var styl = stylus(str)
.set('filename', __dirname + '/test.styl')
.import('mixins/vendor');
console.log(styl.render()); // outputs compiled csshttps://stackoverflow.com/questions/28049113
复制相似问题