Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. declare namespace detectIndent {
  2. interface Indent {
  3. /**
  4. Type of indentation. Is `undefined` if no indentation is detected.
  5. */
  6. type: 'tab' | 'space' | undefined;
  7. /**
  8. Amount of indentation, for example `2`.
  9. */
  10. amount: number;
  11. /**
  12. Actual indentation.
  13. */
  14. indent: string;
  15. }
  16. }
  17. /**
  18. Detect the indentation of code.
  19. @param string - A string of any kind of text.
  20. @example
  21. ```
  22. import * as fs from 'fs';
  23. import detectIndent = require('detect-indent');
  24. // {
  25. // "ilove": "pizza"
  26. // }
  27. const file = fs.readFileSync('foo.json', 'utf8');
  28. // Tries to detect the indentation and falls back to a default if it can't
  29. const indent = detectIndent(file).indent || ' ';
  30. const json = JSON.parse(file);
  31. json.ilove = 'unicorns';
  32. fs.writeFileSync('foo.json', JSON.stringify(json, null, indent));
  33. // {
  34. // "ilove": "unicorns"
  35. // }
  36. ```
  37. */
  38. declare function detectIndent(string: string): detectIndent.Indent;
  39. export = detectIndent;