Newer
Older
CVSS_3.0_GUI / node_modules / nwjs-builder-phoenix / node_modules / plist / node_modules / xmlbuilder / lib / XMLWriterBase.js
root on 7 May 2019 1 KB Initial commit
  1. // Generated by CoffeeScript 1.10.0
  2. (function() {
  3. var XMLWriterBase,
  4. hasProp = {}.hasOwnProperty;
  5.  
  6. module.exports = XMLWriterBase = (function() {
  7. function XMLWriterBase(options) {
  8. var key, ref, ref1, ref2, ref3, ref4, value;
  9. options || (options = {});
  10. this.pretty = options.pretty || false;
  11. this.allowEmpty = (ref = options.allowEmpty) != null ? ref : false;
  12. if (this.pretty) {
  13. this.indent = (ref1 = options.indent) != null ? ref1 : ' ';
  14. this.newline = (ref2 = options.newline) != null ? ref2 : '\n';
  15. this.offset = (ref3 = options.offset) != null ? ref3 : 0;
  16. } else {
  17. this.indent = '';
  18. this.newline = '';
  19. this.offset = 0;
  20. }
  21. ref4 = options.writer || {};
  22. for (key in ref4) {
  23. if (!hasProp.call(ref4, key)) continue;
  24. value = ref4[key];
  25. this[key] = value;
  26. }
  27. }
  28.  
  29. XMLWriterBase.prototype.set = function(options) {
  30. var key, ref, value;
  31. options || (options = {});
  32. if ("pretty" in options) {
  33. this.pretty = options.pretty;
  34. }
  35. if ("allowEmpty" in options) {
  36. this.allowEmpty = options.allowEmpty;
  37. }
  38. if (this.pretty) {
  39. this.indent = "indent" in options ? options.indent : ' ';
  40. this.newline = "newline" in options ? options.newline : '\n';
  41. this.offset = "offset" in options ? options.offset : 0;
  42. } else {
  43. this.indent = '';
  44. this.newline = '';
  45. this.offset = 0;
  46. }
  47. ref = options.writer || {};
  48. for (key in ref) {
  49. if (!hasProp.call(ref, key)) continue;
  50. value = ref[key];
  51. this[key] = value;
  52. }
  53. return this;
  54. };
  55.  
  56. XMLWriterBase.prototype.space = function(level) {
  57. if (this.pretty) {
  58. return new Array((level || 0) + this.offset + 1).join(this.indent);
  59. } else {
  60. return '';
  61. }
  62. };
  63.  
  64. return XMLWriterBase;
  65.  
  66. })();
  67.  
  68. }).call(this);
Buy Me A Coffee