Blame view

node_modules/stylus/lib/functions/define.js 546 Bytes
ce4c83ff   wxy   初始提交
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  var utils = require('../utils')
    , nodes = require('../nodes');
  
  /**
   * Set a variable `name` on current scope.
   *
   * @param {String} name
   * @param {Expression} expr
   * @param {Boolean} [global]
   * @api public
   */
  
  module.exports = function define(name, expr, global){
    utils.assertType(name, 'string', 'name');
    expr = utils.unwrap(expr);
    var scope = this.currentScope;
    if (global && global.toBoolean().isTrue) {
      scope = this.global.scope;
    }
    var node = new nodes.Ident(name.val, expr);
    scope.add(node);
    return nodes.null;
  };