source: trip-planner-front/node_modules/stylus/lib/nodes/binop.js@ e29cc2e

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

initial commit

  • Property mode set to 100644
File size: 1.5 KB
Line 
1
2/*!
3 * Stylus - BinOp
4 * Copyright (c) Automattic <developer.wordpress.com>
5 * MIT Licensed
6 */
7
8/**
9 * Module dependencies.
10 */
11
12var Node = require('./node');
13
14/**
15 * Initialize a new `BinOp` with `op`, `left` and `right`.
16 *
17 * @param {String} op
18 * @param {Node} left
19 * @param {Node} right
20 * @api public
21 */
22
23var BinOp = module.exports = function BinOp(op, left, right){
24 Node.call(this);
25 this.op = op;
26 this.left = left;
27 this.right = right;
28};
29
30/**
31 * Inherit from `Node.prototype`.
32 */
33
34BinOp.prototype.__proto__ = Node.prototype;
35
36/**
37 * Return a clone of this node.
38 *
39 * @return {Node}
40 * @api public
41 */
42
43BinOp.prototype.clone = function(parent){
44 var clone = new BinOp(this.op);
45 clone.left = this.left.clone(parent, clone);
46 clone.right = this.right && this.right.clone(parent, clone);
47 clone.lineno = this.lineno;
48 clone.column = this.column;
49 clone.filename = this.filename;
50 if (this.val) clone.val = this.val.clone(parent, clone);
51 return clone;
52};
53
54/**
55 * Return <left> <op> <right>
56 *
57 * @return {String}
58 * @api public
59 */
60BinOp.prototype.toString = function() {
61 return this.left.toString() + ' ' + this.op + ' ' + this.right.toString();
62};
63
64/**
65 * Return a JSON representation of this node.
66 *
67 * @return {Object}
68 * @api public
69 */
70
71BinOp.prototype.toJSON = function(){
72 var json = {
73 __type: 'BinOp',
74 left: this.left,
75 right: this.right,
76 op: this.op,
77 lineno: this.lineno,
78 column: this.column,
79 filename: this.filename
80 };
81 if (this.val) json.val = this.val;
82 return json;
83};
Note: See TracBrowser for help on using the repository browser.