This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccountGUI/node_modulesOLD/stylus/lib/functions/define.js
2019-08-11 20:48:02 +02:00

23 lines
546 B
JavaScript

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;
};