utils.d.ts 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import { URI } from './uri';
  2. export declare namespace Utils {
  3. /**
  4. * Joins one or more input paths to the path of URI.
  5. * '/' is used as the directory separation character.
  6. *
  7. * The resolved path will be normalized. That means:
  8. * - all '..' and '.' segments are resolved.
  9. * - multiple, sequential occurences of '/' are replaced by a single instance of '/'.
  10. * - trailing separators are preserved.
  11. *
  12. * @param uri The input URI.
  13. * @param paths The paths to be joined with the path of URI.
  14. * @returns A URI with the joined path. All other properties of the URI (scheme, authority, query, fragments, ...) will be taken from the input URI.
  15. */
  16. function joinPath(uri: URI, ...paths: string[]): URI;
  17. /**
  18. * Resolves one or more paths against the path of a URI.
  19. * '/' is used as the directory separation character.
  20. *
  21. * The resolved path will be normalized. That means:
  22. * - all '..' and '.' segments are resolved.
  23. * - multiple, sequential occurences of '/' are replaced by a single instance of '/'.
  24. * - trailing separators are removed.
  25. *
  26. * @param uri The input URI.
  27. * @param paths The paths to resolve against the path of URI.
  28. * @returns A URI with the resolved path. All other properties of the URI (scheme, authority, query, fragments, ...) will be taken from the input URI.
  29. */
  30. function resolvePath(uri: URI, ...paths: string[]): URI;
  31. /**
  32. * Returns a URI where the path is the directory name of the input uri, similar to the Unix dirname command.
  33. * In the path, '/' is recognized as the directory separation character. Trailing directory separators are ignored.
  34. * The orignal URI is returned if the URIs path is empty or does not contain any path segments.
  35. *
  36. * @param uri The input URI.
  37. * @return The last segment of the URIs path.
  38. */
  39. function dirname(uri: URI): URI;
  40. /**
  41. * Returns the last segment of the path of a URI, similar to the Unix basename command.
  42. * In the path, '/' is recognized as the directory separation character. Trailing directory separators are ignored.
  43. * The empty string is returned if the URIs path is empty or does not contain any path segments.
  44. *
  45. * @param uri The input URI.
  46. * @return The base name of the URIs path.
  47. */
  48. function basename(uri: URI): string;
  49. /**
  50. * Returns the extension name of the path of a URI, similar to the Unix extname command.
  51. * In the path, '/' is recognized as the directory separation character. Trailing directory separators are ignored.
  52. * The empty string is returned if the URIs path is empty or does not contain any path segments.
  53. *
  54. * @param uri The input URI.
  55. * @return The extension name of the URIs path.
  56. */
  57. function extname(uri: URI): string;
  58. }