source: trip-planner-front/node_modules/stylus/lib/functions/add-property.js@ eed0bf8

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

initial commit

  • Property mode set to 100644
File size: 769 bytes
RevLine 
[6a3a178]1var utils = require('../utils')
2 , nodes = require('../nodes');
3
4/**
5 * Add property `name` with the given `expr`
6 * to the mixin-able block.
7 *
8 * @param {String|Ident|Literal} name
9 * @param {Expression} expr
10 * @return {Property}
11 * @api public
12 */
13
14(module.exports = function addProperty(name, expr){
15 utils.assertType(name, 'expression', 'name');
16 name = utils.unwrap(name).first;
17 utils.assertString(name, 'name');
18 utils.assertType(expr, 'expression', 'expr');
19 var prop = new nodes.Property([name], expr);
20 var block = this.closestBlock;
21
22 var len = block.nodes.length
23 , head = block.nodes.slice(0, block.index)
24 , tail = block.nodes.slice(block.index++, len);
25 head.push(prop);
26 block.nodes = head.concat(tail);
27
28 return prop;
29}).raw = true;
Note: See TracBrowser for help on using the repository browser.