ventojs 0.7.1 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/esm/_dnt.shims.js +0 -1
  2. package/esm/deps/deno.land/std@0.201.0/assert/assert.d.ts +2 -0
  3. package/esm/deps/deno.land/std@0.201.0/assert/assert.js +8 -0
  4. package/esm/deps/deno.land/std@0.201.0/assert/assertion_error.d.ts +4 -0
  5. package/esm/deps/deno.land/std@0.201.0/assert/assertion_error.js +7 -0
  6. package/esm/deps/deno.land/std@0.201.0/path/_basename.d.ts +16 -0
  7. package/esm/deps/deno.land/std@0.201.0/path/_basename.js +78 -0
  8. package/esm/deps/deno.land/std@0.201.0/path/_dirname.d.ts +10 -0
  9. package/esm/deps/deno.land/std@0.201.0/path/_dirname.js +132 -0
  10. package/esm/deps/deno.land/std@0.201.0/path/_extname.d.ts +12 -0
  11. package/esm/deps/deno.land/std@0.201.0/path/_extname.js +121 -0
  12. package/esm/deps/deno.land/std@0.201.0/path/_format.d.ts +11 -0
  13. package/esm/deps/deno.land/std@0.201.0/path/_format.js +35 -0
  14. package/esm/deps/deno.land/std@0.201.0/path/_from_file_url.d.ts +25 -0
  15. package/esm/deps/deno.land/std@0.201.0/path/_from_file_url.js +46 -0
  16. package/esm/deps/deno.land/std@0.201.0/path/_is_absolute.d.ts +10 -0
  17. package/esm/deps/deno.land/std@0.201.0/path/_is_absolute.js +34 -0
  18. package/esm/deps/deno.land/std@0.201.0/path/_join.d.ts +10 -0
  19. package/esm/deps/deno.land/std@0.201.0/path/_join.js +93 -0
  20. package/esm/deps/deno.land/std@0.201.0/path/_normalize.d.ts +14 -0
  21. package/esm/deps/deno.land/std@0.201.0/path/_normalize.js +153 -0
  22. package/esm/deps/deno.land/std@0.201.0/path/_parse.d.ts +11 -0
  23. package/esm/deps/deno.land/std@0.201.0/path/_parse.js +250 -0
  24. package/esm/deps/deno.land/std@0.201.0/path/_relative.d.ts +19 -0
  25. package/esm/deps/deno.land/std@0.201.0/path/_relative.js +216 -0
  26. package/esm/deps/deno.land/std@0.201.0/path/_resolve.d.ts +10 -0
  27. package/esm/deps/deno.land/std@0.201.0/path/_resolve.js +183 -0
  28. package/esm/deps/deno.land/std@0.201.0/path/_to_file_url.d.ts +25 -0
  29. package/esm/deps/deno.land/std@0.201.0/path/_to_file_url.js +61 -0
  30. package/esm/deps/deno.land/std@0.201.0/path/_to_namespaced_path.d.ts +10 -0
  31. package/esm/deps/deno.land/std@0.201.0/path/_to_namespaced_path.js +46 -0
  32. package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/_util.d.ts +0 -5
  33. package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/_util.js +0 -54
  34. package/esm/deps/deno.land/std@0.201.0/path/basename.d.ts +8 -0
  35. package/esm/deps/deno.land/std@0.201.0/path/basename.js +16 -0
  36. package/esm/deps/deno.land/std@0.201.0/path/dirname.d.ts +5 -0
  37. package/esm/deps/deno.land/std@0.201.0/path/dirname.js +11 -0
  38. package/esm/deps/deno.land/std@0.201.0/path/extname.d.ts +6 -0
  39. package/esm/deps/deno.land/std@0.201.0/path/extname.js +12 -0
  40. package/esm/deps/deno.land/std@0.201.0/path/format.d.ts +6 -0
  41. package/esm/deps/deno.land/std@0.201.0/path/format.js +11 -0
  42. package/esm/deps/deno.land/std@0.201.0/path/from_file_url.d.ts +18 -0
  43. package/esm/deps/deno.land/std@0.201.0/path/from_file_url.js +23 -0
  44. package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/glob.d.ts +1 -1
  45. package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/glob.js +50 -50
  46. package/esm/deps/deno.land/std@0.201.0/path/is_absolute.d.ts +5 -0
  47. package/esm/deps/deno.land/std@0.201.0/path/is_absolute.js +11 -0
  48. package/esm/deps/deno.land/std@0.201.0/path/join.d.ts +5 -0
  49. package/esm/deps/deno.land/std@0.201.0/path/join.js +11 -0
  50. package/esm/deps/deno.land/std@0.201.0/path/mod.d.ts +22 -0
  51. package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/mod.js +17 -4
  52. package/esm/deps/deno.land/std@0.201.0/path/normalize.d.ts +7 -0
  53. package/esm/deps/deno.land/std@0.201.0/path/normalize.js +13 -0
  54. package/esm/deps/deno.land/std@0.201.0/path/parse.d.ts +6 -0
  55. package/esm/deps/deno.land/std@0.201.0/path/parse.js +11 -0
  56. package/esm/deps/deno.land/std@0.201.0/path/posix.d.ts +15 -0
  57. package/esm/deps/deno.land/std@0.201.0/path/posix.js +19 -0
  58. package/esm/deps/deno.land/std@0.201.0/path/relative.d.ts +12 -0
  59. package/esm/deps/deno.land/std@0.201.0/path/relative.js +18 -0
  60. package/esm/deps/deno.land/std@0.201.0/path/resolve.d.ts +5 -0
  61. package/esm/deps/deno.land/std@0.201.0/path/resolve.js +13 -0
  62. package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/separator.js +1 -1
  63. package/esm/deps/deno.land/std@0.201.0/path/to_file_url.d.ts +18 -0
  64. package/esm/deps/deno.land/std@0.201.0/path/to_file_url.js +23 -0
  65. package/esm/deps/deno.land/std@0.201.0/path/to_namespaced_path.d.ts +5 -0
  66. package/esm/deps/deno.land/std@0.201.0/path/to_namespaced_path.js +13 -0
  67. package/esm/deps/deno.land/std@0.201.0/path/win32.d.ts +15 -0
  68. package/esm/deps/deno.land/std@0.201.0/path/win32.js +19 -0
  69. package/esm/deps.d.ts +1 -1
  70. package/esm/deps.js +1 -1
  71. package/esm/src/environment.js +3 -1
  72. package/package.json +1 -1
  73. package/esm/_dnt.test_polyfills.d.ts +0 -11
  74. package/esm/_dnt.test_shims.d.ts +0 -5
  75. package/esm/deps/deno.land/std@0.178.0/_util/asserts.d.ts +0 -10
  76. package/esm/deps/deno.land/std@0.178.0/_util/asserts.js +0 -21
  77. package/esm/deps/deno.land/std@0.178.0/path/mod.d.ts +0 -9
  78. package/esm/deps/deno.land/std@0.178.0/path/posix.d.ts +0 -86
  79. package/esm/deps/deno.land/std@0.178.0/path/posix.js +0 -442
  80. package/esm/deps/deno.land/std@0.178.0/path/win32.d.ts +0 -91
  81. package/esm/deps/deno.land/std@0.178.0/path/win32.js +0 -909
  82. package/esm/deps/deno.land/std@0.190.0/_util/asserts.d.ts +0 -10
  83. package/esm/deps/deno.land/std@0.190.0/bytes/copy.d.ts +0 -27
  84. package/esm/deps/deno.land/std@0.190.0/fmt/colors.d.ts +0 -270
  85. package/esm/deps/deno.land/std@0.190.0/front_matter/mod.d.ts +0 -78
  86. package/esm/deps/deno.land/std@0.190.0/front_matter/yaml.d.ts +0 -4
  87. package/esm/deps/deno.land/std@0.190.0/io/buffer.d.ts +0 -81
  88. package/esm/deps/deno.land/std@0.190.0/testing/_diff.d.ts +0 -26
  89. package/esm/deps/deno.land/std@0.190.0/testing/_format.d.ts +0 -1
  90. package/esm/deps/deno.land/std@0.190.0/testing/asserts.d.ts +0 -284
  91. package/esm/deps/deno.land/std@0.190.0/yaml/_error.d.ts +0 -6
  92. package/esm/deps/deno.land/std@0.190.0/yaml/_loader/loader.d.ts +0 -4
  93. package/esm/deps/deno.land/std@0.190.0/yaml/_loader/loader_state.d.ts +0 -43
  94. package/esm/deps/deno.land/std@0.190.0/yaml/_mark.d.ts +0 -10
  95. package/esm/deps/deno.land/std@0.190.0/yaml/_state.d.ts +0 -5
  96. package/esm/deps/deno.land/std@0.190.0/yaml/_type/binary.d.ts +0 -2
  97. package/esm/deps/deno.land/std@0.190.0/yaml/_type/bool.d.ts +0 -2
  98. package/esm/deps/deno.land/std@0.190.0/yaml/_type/float.d.ts +0 -2
  99. package/esm/deps/deno.land/std@0.190.0/yaml/_type/function.d.ts +0 -2
  100. package/esm/deps/deno.land/std@0.190.0/yaml/_type/int.d.ts +0 -2
  101. package/esm/deps/deno.land/std@0.190.0/yaml/_type/map.d.ts +0 -2
  102. package/esm/deps/deno.land/std@0.190.0/yaml/_type/merge.d.ts +0 -2
  103. package/esm/deps/deno.land/std@0.190.0/yaml/_type/mod.d.ts +0 -16
  104. package/esm/deps/deno.land/std@0.190.0/yaml/_type/nil.d.ts +0 -2
  105. package/esm/deps/deno.land/std@0.190.0/yaml/_type/omap.d.ts +0 -2
  106. package/esm/deps/deno.land/std@0.190.0/yaml/_type/pairs.d.ts +0 -2
  107. package/esm/deps/deno.land/std@0.190.0/yaml/_type/regexp.d.ts +0 -2
  108. package/esm/deps/deno.land/std@0.190.0/yaml/_type/seq.d.ts +0 -2
  109. package/esm/deps/deno.land/std@0.190.0/yaml/_type/set.d.ts +0 -2
  110. package/esm/deps/deno.land/std@0.190.0/yaml/_type/str.d.ts +0 -2
  111. package/esm/deps/deno.land/std@0.190.0/yaml/_type/timestamp.d.ts +0 -2
  112. package/esm/deps/deno.land/std@0.190.0/yaml/_type/undefined.d.ts +0 -2
  113. package/esm/deps/deno.land/std@0.190.0/yaml/_utils.d.ts +0 -19
  114. package/esm/deps/deno.land/std@0.190.0/yaml/parse.d.ts +0 -35
  115. package/esm/deps/deno.land/std@0.190.0/yaml/schema/core.d.ts +0 -2
  116. package/esm/deps/deno.land/std@0.190.0/yaml/schema/default.d.ts +0 -2
  117. package/esm/deps/deno.land/std@0.190.0/yaml/schema/extended.d.ts +0 -30
  118. package/esm/deps/deno.land/std@0.190.0/yaml/schema/failsafe.d.ts +0 -2
  119. package/esm/deps/deno.land/std@0.190.0/yaml/schema/json.d.ts +0 -2
  120. package/esm/deps/deno.land/std@0.190.0/yaml/schema/mod.d.ts +0 -5
  121. package/esm/deps/deno.land/std@0.190.0/yaml/schema.d.ts +0 -22
  122. package/esm/deps/deno.land/std@0.190.0/yaml/type.d.ts +0 -28
  123. package/esm/test/comment.test.d.ts +0 -1
  124. package/esm/test/escape.test.d.ts +0 -1
  125. package/esm/test/for.test.d.ts +0 -1
  126. package/esm/test/function.test.d.ts +0 -1
  127. package/esm/test/if.test.d.ts +0 -1
  128. package/esm/test/import.test.d.ts +0 -1
  129. package/esm/test/include.test.d.ts +0 -1
  130. package/esm/test/js.test.d.ts +0 -1
  131. package/esm/test/layout.test.d.ts +0 -1
  132. package/esm/test/print.test.d.ts +0 -1
  133. package/esm/test/raw.test.d.ts +0 -1
  134. package/esm/test/set.test.d.ts +0 -1
  135. package/esm/test/tokenizer.test.d.ts +0 -1
  136. package/esm/test/utils.d.ts +0 -24
  137. /package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/_constants.d.ts +0 -0
  138. /package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/_constants.js +0 -0
  139. /package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/_interface.d.ts +0 -0
  140. /package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/_interface.js +0 -0
  141. /package/esm/deps/deno.land/{std@0.178.0/_util/os.d.ts → std@0.201.0/path/_os.d.ts} +0 -0
  142. /package/esm/deps/deno.land/{std@0.178.0/_util/os.js → std@0.201.0/path/_os.js} +0 -0
  143. /package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/common.d.ts +0 -0
  144. /package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/common.js +0 -0
  145. /package/esm/deps/deno.land/{std@0.178.0 → std@0.201.0}/path/separator.d.ts +0 -0
package/esm/_dnt.shims.js CHANGED
@@ -4,7 +4,6 @@ const dntGlobals = {
4
4
  Deno,
5
5
  };
6
6
  export const dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
7
- // deno-lint-ignore ban-types
8
7
  function createMergeProxy(baseObj, extObj) {
9
8
  return new Proxy(baseObj, {
10
9
  get(_target, prop, _receiver) {
@@ -0,0 +1,2 @@
1
+ /** Make an assertion, error will be thrown if `expr` does not have truthy value. */
2
+ export declare function assert(expr: unknown, msg?: string): asserts expr;
@@ -0,0 +1,8 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ import { AssertionError } from "./assertion_error.js";
3
+ /** Make an assertion, error will be thrown if `expr` does not have truthy value. */
4
+ export function assert(expr, msg = "") {
5
+ if (!expr) {
6
+ throw new AssertionError(msg);
7
+ }
8
+ }
@@ -0,0 +1,4 @@
1
+ export declare class AssertionError extends Error {
2
+ name: string;
3
+ constructor(message: string);
4
+ }
@@ -0,0 +1,7 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ export class AssertionError extends Error {
3
+ name = "AssertionError";
4
+ constructor(message) {
5
+ super(message);
6
+ }
7
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Return the last portion of a `path`.
3
+ * Trailing directory separators are ignored, and optional suffix is removed.
4
+ *
5
+ * @param path - path to extract the name from.
6
+ * @param [suffix] - suffix to remove from extracted name.
7
+ */
8
+ export declare function posixBasename(path: string, suffix?: string): string;
9
+ /**
10
+ * Return the last portion of a `path`.
11
+ * Trailing directory separators are ignored, and optional suffix is removed.
12
+ *
13
+ * @param path - path to extract the name from.
14
+ * @param [suffix] - suffix to remove from extracted name.
15
+ */
16
+ export declare function windowsBasename(path: string, suffix?: string): string;
@@ -0,0 +1,78 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+ import { CHAR_COLON } from "./_constants.js";
4
+ import { assertPath, isPathSeparator, isPosixPathSeparator, isWindowsDeviceRoot, stripTrailingSeparators, } from "./_util.js";
5
+ function stripSuffix(name, suffix) {
6
+ if (suffix.length >= name.length) {
7
+ return name;
8
+ }
9
+ const lenDiff = name.length - suffix.length;
10
+ for (let i = suffix.length - 1; i >= 0; --i) {
11
+ if (name.charCodeAt(lenDiff + i) !== suffix.charCodeAt(i)) {
12
+ return name;
13
+ }
14
+ }
15
+ return name.slice(0, -suffix.length);
16
+ }
17
+ function lastPathSegment(path, isSep, start = 0) {
18
+ let matchedNonSeparator = false;
19
+ let end = path.length;
20
+ for (let i = path.length - 1; i >= start; --i) {
21
+ if (isSep(path.charCodeAt(i))) {
22
+ if (matchedNonSeparator) {
23
+ start = i + 1;
24
+ break;
25
+ }
26
+ }
27
+ else if (!matchedNonSeparator) {
28
+ matchedNonSeparator = true;
29
+ end = i + 1;
30
+ }
31
+ }
32
+ return path.slice(start, end);
33
+ }
34
+ function assertArgs(path, suffix) {
35
+ assertPath(path);
36
+ if (path.length === 0)
37
+ return path;
38
+ if (typeof suffix !== "string") {
39
+ throw new TypeError(`Suffix must be a string. Received ${JSON.stringify(suffix)}`);
40
+ }
41
+ }
42
+ /**
43
+ * Return the last portion of a `path`.
44
+ * Trailing directory separators are ignored, and optional suffix is removed.
45
+ *
46
+ * @param path - path to extract the name from.
47
+ * @param [suffix] - suffix to remove from extracted name.
48
+ */
49
+ export function posixBasename(path, suffix = "") {
50
+ assertArgs(path, suffix);
51
+ const lastSegment = lastPathSegment(path, isPosixPathSeparator);
52
+ const strippedSegment = stripTrailingSeparators(lastSegment, isPosixPathSeparator);
53
+ return suffix ? stripSuffix(strippedSegment, suffix) : strippedSegment;
54
+ }
55
+ /**
56
+ * Return the last portion of a `path`.
57
+ * Trailing directory separators are ignored, and optional suffix is removed.
58
+ *
59
+ * @param path - path to extract the name from.
60
+ * @param [suffix] - suffix to remove from extracted name.
61
+ */
62
+ export function windowsBasename(path, suffix = "") {
63
+ assertArgs(path, suffix);
64
+ // Check for a drive letter prefix so as not to mistake the following
65
+ // path separator as an extra separator at the end of the path that can be
66
+ // disregarded
67
+ let start = 0;
68
+ if (path.length >= 2) {
69
+ const drive = path.charCodeAt(0);
70
+ if (isWindowsDeviceRoot(drive)) {
71
+ if (path.charCodeAt(1) === CHAR_COLON)
72
+ start = 2;
73
+ }
74
+ }
75
+ const lastSegment = lastPathSegment(path, isPathSeparator, start);
76
+ const strippedSegment = stripTrailingSeparators(lastSegment, isPathSeparator);
77
+ return suffix ? stripSuffix(strippedSegment, suffix) : strippedSegment;
78
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Return the directory path of a `path`.
3
+ * @param path - path to extract the directory from.
4
+ */
5
+ export declare function posixDirname(path: string): string;
6
+ /**
7
+ * Return the directory path of a `path`.
8
+ * @param path - path to extract the directory from.
9
+ */
10
+ export declare function windowsDirname(path: string): string;
@@ -0,0 +1,132 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+ import { CHAR_COLON } from "./_constants.js";
4
+ import { assertPath, isPathSeparator, isPosixPathSeparator, isWindowsDeviceRoot, stripTrailingSeparators, } from "./_util.js";
5
+ function assertArg(path) {
6
+ assertPath(path);
7
+ if (path.length === 0)
8
+ return ".";
9
+ }
10
+ /**
11
+ * Return the directory path of a `path`.
12
+ * @param path - path to extract the directory from.
13
+ */
14
+ export function posixDirname(path) {
15
+ assertArg(path);
16
+ let end = -1;
17
+ let matchedNonSeparator = false;
18
+ for (let i = path.length - 1; i >= 1; --i) {
19
+ if (isPosixPathSeparator(path.charCodeAt(i))) {
20
+ if (matchedNonSeparator) {
21
+ end = i;
22
+ break;
23
+ }
24
+ }
25
+ else {
26
+ matchedNonSeparator = true;
27
+ }
28
+ }
29
+ // No matches. Fallback based on provided path:
30
+ //
31
+ // - leading slashes paths
32
+ // "/foo" => "/"
33
+ // "///foo" => "/"
34
+ // - no slash path
35
+ // "foo" => "."
36
+ if (end === -1) {
37
+ return isPosixPathSeparator(path.charCodeAt(0)) ? "/" : ".";
38
+ }
39
+ return stripTrailingSeparators(path.slice(0, end), isPosixPathSeparator);
40
+ }
41
+ /**
42
+ * Return the directory path of a `path`.
43
+ * @param path - path to extract the directory from.
44
+ */
45
+ export function windowsDirname(path) {
46
+ assertArg(path);
47
+ const len = path.length;
48
+ let rootEnd = -1;
49
+ let end = -1;
50
+ let matchedSlash = true;
51
+ let offset = 0;
52
+ const code = path.charCodeAt(0);
53
+ // Try to match a root
54
+ if (len > 1) {
55
+ if (isPathSeparator(code)) {
56
+ // Possible UNC root
57
+ rootEnd = offset = 1;
58
+ if (isPathSeparator(path.charCodeAt(1))) {
59
+ // Matched double path separator at beginning
60
+ let j = 2;
61
+ let last = j;
62
+ // Match 1 or more non-path separators
63
+ for (; j < len; ++j) {
64
+ if (isPathSeparator(path.charCodeAt(j)))
65
+ break;
66
+ }
67
+ if (j < len && j !== last) {
68
+ // Matched!
69
+ last = j;
70
+ // Match 1 or more path separators
71
+ for (; j < len; ++j) {
72
+ if (!isPathSeparator(path.charCodeAt(j)))
73
+ break;
74
+ }
75
+ if (j < len && j !== last) {
76
+ // Matched!
77
+ last = j;
78
+ // Match 1 or more non-path separators
79
+ for (; j < len; ++j) {
80
+ if (isPathSeparator(path.charCodeAt(j)))
81
+ break;
82
+ }
83
+ if (j === len) {
84
+ // We matched a UNC root only
85
+ return path;
86
+ }
87
+ if (j !== last) {
88
+ // We matched a UNC root with leftovers
89
+ // Offset by 1 to include the separator after the UNC root to
90
+ // treat it as a "normal root" on top of a (UNC) root
91
+ rootEnd = offset = j + 1;
92
+ }
93
+ }
94
+ }
95
+ }
96
+ }
97
+ else if (isWindowsDeviceRoot(code)) {
98
+ // Possible device root
99
+ if (path.charCodeAt(1) === CHAR_COLON) {
100
+ rootEnd = offset = 2;
101
+ if (len > 2) {
102
+ if (isPathSeparator(path.charCodeAt(2)))
103
+ rootEnd = offset = 3;
104
+ }
105
+ }
106
+ }
107
+ }
108
+ else if (isPathSeparator(code)) {
109
+ // `path` contains just a path separator, exit early to avoid
110
+ // unnecessary work
111
+ return path;
112
+ }
113
+ for (let i = len - 1; i >= offset; --i) {
114
+ if (isPathSeparator(path.charCodeAt(i))) {
115
+ if (!matchedSlash) {
116
+ end = i;
117
+ break;
118
+ }
119
+ }
120
+ else {
121
+ // We saw the first non-path separator
122
+ matchedSlash = false;
123
+ }
124
+ }
125
+ if (end === -1) {
126
+ if (rootEnd === -1)
127
+ return ".";
128
+ else
129
+ end = rootEnd;
130
+ }
131
+ return stripTrailingSeparators(path.slice(0, end), isPosixPathSeparator);
132
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Return the extension of the `path` with leading period.
3
+ * @param path with extension
4
+ * @returns extension (ex. for `file.ts` returns `.ts`)
5
+ */
6
+ export declare function posixExtname(path: string): string;
7
+ /**
8
+ * Return the extension of the `path` with leading period.
9
+ * @param path with extension
10
+ * @returns extension (ex. for `file.ts` returns `.ts`)
11
+ */
12
+ export declare function windowsExtname(path: string): string;
@@ -0,0 +1,121 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+ import { CHAR_COLON, CHAR_DOT } from "./_constants.js";
4
+ import { assertPath, isPathSeparator, isPosixPathSeparator, isWindowsDeviceRoot, } from "./_util.js";
5
+ /**
6
+ * Return the extension of the `path` with leading period.
7
+ * @param path with extension
8
+ * @returns extension (ex. for `file.ts` returns `.ts`)
9
+ */
10
+ export function posixExtname(path) {
11
+ assertPath(path);
12
+ let startDot = -1;
13
+ let startPart = 0;
14
+ let end = -1;
15
+ let matchedSlash = true;
16
+ // Track the state of characters (if any) we see before our first dot and
17
+ // after any path separator we find
18
+ let preDotState = 0;
19
+ for (let i = path.length - 1; i >= 0; --i) {
20
+ const code = path.charCodeAt(i);
21
+ if (isPosixPathSeparator(code)) {
22
+ // If we reached a path separator that was not part of a set of path
23
+ // separators at the end of the string, stop now
24
+ if (!matchedSlash) {
25
+ startPart = i + 1;
26
+ break;
27
+ }
28
+ continue;
29
+ }
30
+ if (end === -1) {
31
+ // We saw the first non-path separator, mark this as the end of our
32
+ // extension
33
+ matchedSlash = false;
34
+ end = i + 1;
35
+ }
36
+ if (code === CHAR_DOT) {
37
+ // If this is our first dot, mark it as the start of our extension
38
+ if (startDot === -1)
39
+ startDot = i;
40
+ else if (preDotState !== 1)
41
+ preDotState = 1;
42
+ }
43
+ else if (startDot !== -1) {
44
+ // We saw a non-dot and non-path separator before our dot, so we should
45
+ // have a good chance at having a non-empty extension
46
+ preDotState = -1;
47
+ }
48
+ }
49
+ if (startDot === -1 ||
50
+ end === -1 ||
51
+ // We saw a non-dot character immediately before the dot
52
+ preDotState === 0 ||
53
+ // The (right-most) trimmed path component is exactly '..'
54
+ (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)) {
55
+ return "";
56
+ }
57
+ return path.slice(startDot, end);
58
+ }
59
+ /**
60
+ * Return the extension of the `path` with leading period.
61
+ * @param path with extension
62
+ * @returns extension (ex. for `file.ts` returns `.ts`)
63
+ */
64
+ export function windowsExtname(path) {
65
+ assertPath(path);
66
+ let start = 0;
67
+ let startDot = -1;
68
+ let startPart = 0;
69
+ let end = -1;
70
+ let matchedSlash = true;
71
+ // Track the state of characters (if any) we see before our first dot and
72
+ // after any path separator we find
73
+ let preDotState = 0;
74
+ // Check for a drive letter prefix so as not to mistake the following
75
+ // path separator as an extra separator at the end of the path that can be
76
+ // disregarded
77
+ if (path.length >= 2 &&
78
+ path.charCodeAt(1) === CHAR_COLON &&
79
+ isWindowsDeviceRoot(path.charCodeAt(0))) {
80
+ start = startPart = 2;
81
+ }
82
+ for (let i = path.length - 1; i >= start; --i) {
83
+ const code = path.charCodeAt(i);
84
+ if (isPathSeparator(code)) {
85
+ // If we reached a path separator that was not part of a set of path
86
+ // separators at the end of the string, stop now
87
+ if (!matchedSlash) {
88
+ startPart = i + 1;
89
+ break;
90
+ }
91
+ continue;
92
+ }
93
+ if (end === -1) {
94
+ // We saw the first non-path separator, mark this as the end of our
95
+ // extension
96
+ matchedSlash = false;
97
+ end = i + 1;
98
+ }
99
+ if (code === CHAR_DOT) {
100
+ // If this is our first dot, mark it as the start of our extension
101
+ if (startDot === -1)
102
+ startDot = i;
103
+ else if (preDotState !== 1)
104
+ preDotState = 1;
105
+ }
106
+ else if (startDot !== -1) {
107
+ // We saw a non-dot and non-path separator before our dot, so we should
108
+ // have a good chance at having a non-empty extension
109
+ preDotState = -1;
110
+ }
111
+ }
112
+ if (startDot === -1 ||
113
+ end === -1 ||
114
+ // We saw a non-dot character immediately before the dot
115
+ preDotState === 0 ||
116
+ // The (right-most) trimmed path component is exactly '..'
117
+ (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)) {
118
+ return "";
119
+ }
120
+ return path.slice(startDot, end);
121
+ }
@@ -0,0 +1,11 @@
1
+ import type { FormatInputPathObject } from "./_interface.js";
2
+ /**
3
+ * Generate a path from `FormatInputPathObject` object.
4
+ * @param pathObject with path
5
+ */
6
+ export declare function posixFormat(pathObject: FormatInputPathObject): string;
7
+ /**
8
+ * Generate a path from `FormatInputPathObject` object.
9
+ * @param pathObject with path
10
+ */
11
+ export declare function windowsFormat(pathObject: FormatInputPathObject): string;
@@ -0,0 +1,35 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+ function _format(sep, pathObject) {
4
+ const dir = pathObject.dir || pathObject.root;
5
+ const base = pathObject.base ||
6
+ (pathObject.name || "") + (pathObject.ext || "");
7
+ if (!dir)
8
+ return base;
9
+ if (base === sep)
10
+ return dir;
11
+ if (dir === pathObject.root)
12
+ return dir + base;
13
+ return dir + sep + base;
14
+ }
15
+ function assertArg(pathObject) {
16
+ if (pathObject === null || typeof pathObject !== "object") {
17
+ throw new TypeError(`The "pathObject" argument must be of type Object. Received type ${typeof pathObject}`);
18
+ }
19
+ }
20
+ /**
21
+ * Generate a path from `FormatInputPathObject` object.
22
+ * @param pathObject with path
23
+ */
24
+ export function posixFormat(pathObject) {
25
+ assertArg(pathObject);
26
+ return _format("/", pathObject);
27
+ }
28
+ /**
29
+ * Generate a path from `FormatInputPathObject` object.
30
+ * @param pathObject with path
31
+ */
32
+ export function windowsFormat(pathObject) {
33
+ assertArg(pathObject);
34
+ return _format("\\", pathObject);
35
+ }
@@ -0,0 +1,25 @@
1
+ /// <reference types="node" />
2
+ /**
3
+ * Converts a file URL to a path string.
4
+ *
5
+ * ```ts
6
+ * import { fromFileUrl } from "https://deno.land/std@$STD_VERSION/path/posix.ts";
7
+ *
8
+ * fromFileUrl("file:///home/foo"); // "/home/foo"
9
+ * ```
10
+ * @param url of a file URL
11
+ */
12
+ export declare function posixFromFileUrl(url: URL | string): string;
13
+ /**
14
+ * Converts a file URL to a path string.
15
+ *
16
+ * ```ts
17
+ * import { fromFileUrl } from "https://deno.land/std@$STD_VERSION/path/win32.ts";
18
+ *
19
+ * fromFileUrl("file:///home/foo"); // "\\home\\foo"
20
+ * fromFileUrl("file:///C:/Users/foo"); // "C:\\Users\\foo"
21
+ * fromFileUrl("file://localhost/home/foo"); // "\\\\localhost\\home\\foo"
22
+ * ```
23
+ * @param url of a file URL
24
+ */
25
+ export declare function windowsFromFileUrl(url: URL | string): string;
@@ -0,0 +1,46 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+ function assertArg(url) {
4
+ url = url instanceof URL ? url : new URL(url);
5
+ if (url.protocol !== "file:") {
6
+ throw new TypeError("Must be a file URL.");
7
+ }
8
+ return url;
9
+ }
10
+ /**
11
+ * Converts a file URL to a path string.
12
+ *
13
+ * ```ts
14
+ * import { fromFileUrl } from "https://deno.land/std@$STD_VERSION/path/posix.ts";
15
+ *
16
+ * fromFileUrl("file:///home/foo"); // "/home/foo"
17
+ * ```
18
+ * @param url of a file URL
19
+ */
20
+ export function posixFromFileUrl(url) {
21
+ url = assertArg(url);
22
+ return decodeURIComponent(url.pathname.replace(/%(?![0-9A-Fa-f]{2})/g, "%25"));
23
+ }
24
+ /**
25
+ * Converts a file URL to a path string.
26
+ *
27
+ * ```ts
28
+ * import { fromFileUrl } from "https://deno.land/std@$STD_VERSION/path/win32.ts";
29
+ *
30
+ * fromFileUrl("file:///home/foo"); // "\\home\\foo"
31
+ * fromFileUrl("file:///C:/Users/foo"); // "C:\\Users\\foo"
32
+ * fromFileUrl("file://localhost/home/foo"); // "\\\\localhost\\home\\foo"
33
+ * ```
34
+ * @param url of a file URL
35
+ */
36
+ export function windowsFromFileUrl(url) {
37
+ url = assertArg(url);
38
+ let path = decodeURIComponent(url.pathname.replace(/\//g, "\\").replace(/%(?![0-9A-Fa-f]{2})/g, "%25")).replace(/^\\*([A-Za-z]:)(\\|$)/, "$1\\");
39
+ if (url.hostname !== "") {
40
+ // Note: The `URL` implementation guarantees that the drive letter and
41
+ // hostname are mutually exclusive. Otherwise it would not have been valid
42
+ // to append the hostname and path like this.
43
+ path = `\\\\${url.hostname}${path}`;
44
+ }
45
+ return path;
46
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Verifies whether provided path is absolute
3
+ * @param path to be verified as absolute
4
+ */
5
+ export declare function windowsIsAbsolute(path: string): boolean;
6
+ /**
7
+ * Verifies whether provided path is absolute
8
+ * @param path to be verified as absolute
9
+ */
10
+ export declare function posixIsAbsolute(path: string): boolean;
@@ -0,0 +1,34 @@
1
+ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+ import { CHAR_COLON } from "./_constants.js";
4
+ import { assertPath, isPathSeparator, isPosixPathSeparator, isWindowsDeviceRoot, } from "./_util.js";
5
+ /**
6
+ * Verifies whether provided path is absolute
7
+ * @param path to be verified as absolute
8
+ */
9
+ export function windowsIsAbsolute(path) {
10
+ assertPath(path);
11
+ const len = path.length;
12
+ if (len === 0)
13
+ return false;
14
+ const code = path.charCodeAt(0);
15
+ if (isPathSeparator(code)) {
16
+ return true;
17
+ }
18
+ else if (isWindowsDeviceRoot(code)) {
19
+ // Possible device root
20
+ if (len > 2 && path.charCodeAt(1) === CHAR_COLON) {
21
+ if (isPathSeparator(path.charCodeAt(2)))
22
+ return true;
23
+ }
24
+ }
25
+ return false;
26
+ }
27
+ /**
28
+ * Verifies whether provided path is absolute
29
+ * @param path to be verified as absolute
30
+ */
31
+ export function posixIsAbsolute(path) {
32
+ assertPath(path);
33
+ return path.length > 0 && isPosixPathSeparator(path.charCodeAt(0));
34
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Join all given a sequence of `paths`,then normalizes the resulting path.
3
+ * @param paths to be joined and normalized
4
+ */
5
+ export declare function posixJoin(...paths: string[]): string;
6
+ /**
7
+ * Join all given a sequence of `paths`,then normalizes the resulting path.
8
+ * @param paths to be joined and normalized
9
+ */
10
+ export declare function windowsJoin(...paths: string[]): string;