lib/transformers.js
function (str, options, cb) {
    var self = this;
    if (self.cache(options)) return cb(null, self.cache(options));
    if (options.filename) {
      options.paths = options.paths || [dirname(options.filename)];
    }

    // If this.cache is enabled, compress by default
    if (options.compress !== true && options.compress !== false) {
      options.compress = options.cache || false;
    }

    var initial = this.engine(str);

    // Special handling for stylus js api functions
    // given { define: { foo: 'bar', baz: 'quux' } }
    // runs initial.define('foo', 'bar').define('baz', 'quux')

    var allowed = ['set', 'include', 'import', 'define', 'use'];
    var special = {}
    var normal = clone(options);
    for (var v in options) {
      if (allowed.indexOf(v) > -1) { special[v] = options[v]; delete normal[v]; }
    }

    // special options through their function names
    for (var k in special) {
      for (var v in special[k]) { initial[k](v, special[k][v]); }
    }

    // normal options through set()
    for (var k in normal) {
      initial.set(k, normal[k]);
    }

    initial.render(function (err, res) {
      if (err) return cb(err);
      self.cache(options, res);
      cb(null, res);
    });
  }
function (str, options, cb) {
    var self = this;
    if (self.cache(options)) return cb(null, self.cache(options));
    if (options.filename) {
      options.paths = options.paths || [dirname(options.filename)];
    }

    // If this.cache is enabled, compress by default
    if (options.compress !== true && options.compress !== false) {
      options.compress = options.cache || false;
    }

    var initial = this.engine(str);

    // Special handling for stylus js api functions
    // given { define: { foo: 'bar', baz: 'quux' } }
    // runs initial.define('foo', 'bar').define('baz', 'quux')

    var allowed = ['set', 'include', 'import', 'define', 'use'];
    var special = {}
    var normal = clone(options);
    for (var v in options) {
      if (allowed.indexOf(v) > -1) { special[v] = options[v]; delete normal[v]; }
    }

    // special options through their function names
    for (var k in special) {
      for (var v in special[k]) { initial[k](v, special[k][v]); }
    }

    // normal options through set()
    for (var k in normal) {
      initial.set(k, normal[k]);
    }

    initial.render(function (err, res) {
      if (err) return cb(err);
      self.cache(options, res);
      cb(null, res);
    });
  }
function ( str , options , cb ) { var self = this ; if ( self . cache ( options ) ) return cb ( null , self . cache ( options ) ) ; if ( options . filename ) { options . paths = options . paths || [ dirname ( options . filename ) ] ; } // If this.cache is enabled, compress by default if ( options . compress !== true && options . compress !== false ) { options . compress = options . cache || false ; } var initial = this . engine ( str ) ; // Special handling for stylus js api functions // given { define: { foo: 'bar', baz: 'quux' } } // runs initial.define('foo', 'bar').define('baz', 'quux') var allowed = [ 'set' , 'include' , 'import' , 'define' , 'use' ] ; var special = { } var normal = clone ( options ) ; for ( var v in options ) { if ( allowed . indexOf ( v ) > - 1 ) { special [ v ] = options [ v ] ; delete normal [ v ] ; } } // special options through their function names for ( var k in special ) { for ( var v in special [ k ] ) { initial [ k ] ( v , special [ k ] [ v ] ) ; } } // normal options through set() for ( var k in normal ) { initial . set ( k , normal [ k ] ) ; } initial . render ( function ( err , res ) { if ( err ) return cb ( err ) ; self . cache ( options , res ) ; cb ( null , res ) ; } ) ; }
always runs synchronously
always runs synchronously