charset.js 872 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*!
  2. * Stylus - Charset
  3. * Copyright (c) Automattic <developer.wordpress.com>
  4. * MIT Licensed
  5. */
  6. /**
  7. * Module dependencies.
  8. */
  9. var Node = require('./node');
  10. /**
  11. * Initialize a new `Charset` with the given `val`
  12. *
  13. * @param {String} val
  14. * @api public
  15. */
  16. var Charset = module.exports = function Charset(val){
  17. Node.call(this);
  18. this.val = val;
  19. };
  20. /**
  21. * Inherit from `Node.prototype`.
  22. */
  23. Charset.prototype.__proto__ = Node.prototype;
  24. /**
  25. * Return @charset "val".
  26. *
  27. * @return {String}
  28. * @api public
  29. */
  30. Charset.prototype.toString = function(){
  31. return '@charset ' + this.val;
  32. };
  33. /**
  34. * Return a JSON representation of this node.
  35. *
  36. * @return {Object}
  37. * @api public
  38. */
  39. Charset.prototype.toJSON = function(){
  40. return {
  41. __type: 'Charset',
  42. val: this.val,
  43. lineno: this.lineno,
  44. column: this.column,
  45. filename: this.filename
  46. };
  47. };