Last change
on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
913 bytes
|
Line | |
---|
1 |
|
---|
2 | /*!
|
---|
3 | * Stylus - Token
|
---|
4 | * Copyright (c) Automattic <developer.wordpress.com>
|
---|
5 | * MIT Licensed
|
---|
6 | */
|
---|
7 |
|
---|
8 | /**
|
---|
9 | * Module dependencies.
|
---|
10 | */
|
---|
11 |
|
---|
12 | var inspect = require('util').inspect;
|
---|
13 |
|
---|
14 | /**
|
---|
15 | * Initialize a new `Token` with the given `type` and `val`.
|
---|
16 | *
|
---|
17 | * @param {String} type
|
---|
18 | * @param {Mixed} val
|
---|
19 | * @api private
|
---|
20 | */
|
---|
21 |
|
---|
22 | var Token = exports = module.exports = function Token(type, val) {
|
---|
23 | this.type = type;
|
---|
24 | this.val = val;
|
---|
25 | };
|
---|
26 |
|
---|
27 | /**
|
---|
28 | * Custom inspect.
|
---|
29 | *
|
---|
30 | * @return {String}
|
---|
31 | * @api public
|
---|
32 | */
|
---|
33 |
|
---|
34 | Token.prototype.inspect = function(){
|
---|
35 | var val = ' ' + inspect(this.val);
|
---|
36 | return '[Token:' + this.lineno + ':' + this.column + ' '
|
---|
37 | + '\x1b[32m' + this.type + '\x1b[0m'
|
---|
38 | + '\x1b[33m' + (this.val ? val : '') + '\x1b[0m'
|
---|
39 | + ']';
|
---|
40 | };
|
---|
41 |
|
---|
42 | /**
|
---|
43 | * Return type or val.
|
---|
44 | *
|
---|
45 | * @return {String}
|
---|
46 | * @api public
|
---|
47 | */
|
---|
48 |
|
---|
49 | Token.prototype.toString = function(){
|
---|
50 | return (undefined === this.val
|
---|
51 | ? this.type
|
---|
52 | : this.val).toString();
|
---|
53 | };
|
---|
Note:
See
TracBrowser
for help on using the repository browser.