source: trip-planner-front/node_modules/stylus/lib/functions/define.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 598 bytes
Line 
1var utils = require('../utils')
2 , nodes = require('../nodes');
3
4/**
5 * Set a variable `name` on current scope.
6 *
7 * @param {String} name
8 * @param {Expression} expr
9 * @param {Boolean} [global]
10 * @api public
11 */
12
13function define(name, expr, global){
14 utils.assertType(name, 'string', 'name');
15 expr = utils.unwrap(expr);
16 var scope = this.currentScope;
17 if (global && global.toBoolean().isTrue) {
18 scope = this.global.scope;
19 }
20 var node = new nodes.Ident(name.val, expr);
21 scope.add(node);
22 return nodes.null;
23};
24define.params = ['name', 'expr', 'global'];
25module.exports = define;
Note: See TracBrowser for help on using the repository browser.