null.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*!
  2. * Stylus - Null
  3. * Copyright (c) Automattic <developer.wordpress.com>
  4. * MIT Licensed
  5. */
  6. /**
  7. * Module dependencies.
  8. */
  9. var Node = require('./node')
  10. , nodes = require('./');
  11. /**
  12. * Initialize a new `Null` node.
  13. *
  14. * @api public
  15. */
  16. var Null = module.exports = function Null(){};
  17. /**
  18. * Inherit from `Node.prototype`.
  19. */
  20. Null.prototype.__proto__ = Node.prototype;
  21. /**
  22. * Return 'Null'.
  23. *
  24. * @return {String}
  25. * @api public
  26. */
  27. Null.prototype.inspect =
  28. Null.prototype.toString = function(){
  29. return 'null';
  30. };
  31. /**
  32. * Return false.
  33. *
  34. * @return {Boolean}
  35. * @api public
  36. */
  37. Null.prototype.toBoolean = function(){
  38. return nodes.false;
  39. };
  40. /**
  41. * Check if the node is a null node.
  42. *
  43. * @return {Boolean}
  44. * @api public
  45. */
  46. Null.prototype.__defineGetter__('isNull', function(){
  47. return true;
  48. });
  49. /**
  50. * Return hash.
  51. *
  52. * @return {String}
  53. * @api public
  54. */
  55. Null.prototype.__defineGetter__('hash', function(){
  56. return null;
  57. });
  58. /**
  59. * Return a JSON representation of this node.
  60. *
  61. * @return {Object}
  62. * @api public
  63. */
  64. Null.prototype.toJSON = function(){
  65. return {
  66. __type: 'Null',
  67. lineno: this.lineno,
  68. column: this.column,
  69. filename: this.filename
  70. };
  71. };