@gglib/utils 0.6.2 → 0.8.0

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 (238) hide show
  1. package/LICENSE +7 -0
  2. package/Readme.md +1 -1
  3. package/dist/bundles/utils.esm.js +1904 -0
  4. package/dist/bundles/utils.esm.js.map +1 -0
  5. package/dist/stats.html +211 -170
  6. package/dist/utils/src/collections/IdMap.d.ts +13 -0
  7. package/dist/utils/src/collections/IdMap.d.ts.map +1 -0
  8. package/dist/utils/src/collections/IdMap.js +63 -0
  9. package/dist/utils/src/collections/IdMap.js.map +1 -0
  10. package/dist/utils/src/collections/IdSet.d.ts +11 -0
  11. package/dist/utils/src/collections/IdSet.d.ts.map +1 -0
  12. package/dist/utils/src/collections/IdSet.js +47 -0
  13. package/dist/utils/src/collections/IdSet.js.map +1 -0
  14. package/dist/utils/src/collections/PooledList.d.ts +15 -0
  15. package/dist/utils/src/collections/PooledList.d.ts.map +1 -0
  16. package/dist/utils/src/collections/PooledList.js +44 -0
  17. package/dist/utils/src/collections/PooledList.js.map +1 -0
  18. package/dist/utils/src/collections/PriorityQueue.d.ts +27 -0
  19. package/dist/utils/src/collections/PriorityQueue.d.ts.map +1 -0
  20. package/dist/utils/src/collections/PriorityQueue.js +142 -0
  21. package/dist/utils/src/collections/PriorityQueue.js.map +1 -0
  22. package/dist/utils/src/collections/array.d.ts +27 -0
  23. package/dist/utils/src/collections/array.d.ts.map +1 -0
  24. package/dist/utils/src/collections/array.js +55 -0
  25. package/dist/utils/src/collections/array.js.map +1 -0
  26. package/dist/utils/src/collections/index.d.ts +6 -0
  27. package/dist/utils/src/collections/index.d.ts.map +1 -0
  28. package/dist/utils/src/collections/index.js +6 -0
  29. package/dist/utils/src/collections/index.js.map +1 -0
  30. package/dist/utils/src/events/bus.d.ts +15 -0
  31. package/dist/utils/src/events/bus.d.ts.map +1 -0
  32. package/dist/utils/src/events/bus.js +47 -0
  33. package/dist/utils/src/events/bus.js.map +1 -0
  34. package/dist/utils/src/events/channel.d.ts +23 -0
  35. package/dist/utils/src/events/channel.d.ts.map +1 -0
  36. package/dist/utils/src/events/channel.js +95 -0
  37. package/dist/utils/src/events/channel.js.map +1 -0
  38. package/dist/utils/src/events/emitter.d.ts +14 -0
  39. package/dist/utils/src/events/emitter.d.ts.map +1 -0
  40. package/dist/utils/src/events/emitter.js +37 -0
  41. package/dist/utils/src/events/emitter.js.map +1 -0
  42. package/dist/utils/src/events/index.d.ts +6 -0
  43. package/dist/utils/src/events/index.d.ts.map +1 -0
  44. package/dist/utils/src/events/index.js +6 -0
  45. package/dist/utils/src/events/index.js.map +1 -0
  46. package/dist/utils/src/events/source.d.ts +20 -0
  47. package/dist/utils/src/events/source.d.ts.map +1 -0
  48. package/dist/utils/src/events/source.js +69 -0
  49. package/dist/utils/src/events/source.js.map +1 -0
  50. package/dist/utils/src/events/types.d.ts +3 -0
  51. package/dist/utils/src/events/types.d.ts.map +1 -0
  52. package/dist/utils/src/events/types.js +2 -0
  53. package/dist/utils/src/events/types.js.map +1 -0
  54. package/dist/utils/src/index.d.ts +5 -9
  55. package/dist/utils/src/index.d.ts.map +1 -1
  56. package/dist/utils/src/index.js +5 -9
  57. package/dist/utils/src/index.js.map +1 -1
  58. package/dist/utils/src/{BinaryReader.d.ts → reader/BinaryReader.d.ts} +19 -1
  59. package/dist/utils/src/reader/BinaryReader.d.ts.map +1 -0
  60. package/dist/utils/src/{BinaryReader.js → reader/BinaryReader.js} +80 -61
  61. package/dist/utils/src/reader/BinaryReader.js.map +1 -0
  62. package/dist/utils/src/reader/TextReader.d.ts +245 -0
  63. package/dist/utils/src/reader/TextReader.d.ts.map +1 -0
  64. package/dist/utils/src/reader/TextReader.js +465 -0
  65. package/dist/utils/src/reader/TextReader.js.map +1 -0
  66. package/dist/utils/src/reader/index.d.ts +3 -0
  67. package/dist/utils/src/reader/index.d.ts.map +1 -0
  68. package/dist/utils/src/reader/index.js +3 -0
  69. package/dist/utils/src/reader/index.js.map +1 -0
  70. package/dist/utils/src/types/brand.d.ts +26 -0
  71. package/dist/utils/src/types/brand.d.ts.map +1 -0
  72. package/dist/utils/src/types/brand.js +4 -0
  73. package/dist/utils/src/types/brand.js.map +1 -0
  74. package/dist/utils/src/types/index.d.ts +4 -0
  75. package/dist/utils/src/types/index.d.ts.map +1 -0
  76. package/dist/utils/src/types/index.js +4 -0
  77. package/dist/utils/src/types/index.js.map +1 -0
  78. package/dist/utils/src/types/json-rpc.d.ts +72 -0
  79. package/dist/utils/src/types/json-rpc.d.ts.map +1 -0
  80. package/dist/utils/src/types/json-rpc.js +99 -0
  81. package/dist/utils/src/types/json-rpc.js.map +1 -0
  82. package/dist/utils/src/types/rxjs.d.ts +17 -0
  83. package/dist/utils/src/types/rxjs.d.ts.map +1 -0
  84. package/dist/utils/src/types/rxjs.js +10 -0
  85. package/dist/utils/src/types/rxjs.js.map +1 -0
  86. package/dist/utils/src/uri/index.d.ts +4 -0
  87. package/dist/utils/src/uri/index.d.ts.map +1 -0
  88. package/dist/utils/src/uri/index.js +4 -0
  89. package/dist/utils/src/uri/index.js.map +1 -0
  90. package/dist/utils/src/uri/merge.d.ts +2 -0
  91. package/dist/utils/src/uri/merge.d.ts.map +1 -0
  92. package/dist/utils/src/uri/merge.js +56 -0
  93. package/dist/utils/src/uri/merge.js.map +1 -0
  94. package/dist/utils/src/uri/parse.d.ts +129 -0
  95. package/dist/utils/src/uri/parse.d.ts.map +1 -0
  96. package/dist/utils/src/uri/parse.js +83 -0
  97. package/dist/utils/src/uri/parse.js.map +1 -0
  98. package/dist/utils/src/uri/path.d.ts +22 -0
  99. package/dist/utils/src/uri/path.d.ts.map +1 -0
  100. package/dist/utils/src/uri/path.js +34 -0
  101. package/dist/utils/src/uri/path.js.map +1 -0
  102. package/dist/utils/src/utils/dom.d.ts +7 -2
  103. package/dist/utils/src/utils/dom.d.ts.map +1 -1
  104. package/dist/utils/src/utils/dom.js +59 -63
  105. package/dist/utils/src/utils/dom.js.map +1 -1
  106. package/dist/utils/src/utils/index.d.ts +3 -8
  107. package/dist/utils/src/utils/index.d.ts.map +1 -1
  108. package/dist/utils/src/utils/index.js +3 -8
  109. package/dist/utils/src/utils/index.js.map +1 -1
  110. package/dist/utils/src/utils/logfmt.d.ts +53 -0
  111. package/dist/utils/src/utils/logfmt.d.ts.map +1 -0
  112. package/dist/utils/src/utils/logfmt.js +66 -0
  113. package/dist/utils/src/utils/logfmt.js.map +1 -0
  114. package/dist/utils/src/utils/loop.d.ts +12 -28
  115. package/dist/utils/src/utils/loop.d.ts.map +1 -1
  116. package/dist/utils/src/utils/loop.js +23 -54
  117. package/dist/utils/src/utils/loop.js.map +1 -1
  118. package/dist/utils/src/utils/metric.d.ts +23 -0
  119. package/dist/utils/src/utils/metric.d.ts.map +1 -0
  120. package/dist/utils/src/utils/metric.js +47 -0
  121. package/dist/utils/src/utils/metric.js.map +1 -0
  122. package/dist/utils/src/utils/uuid.js +3 -3
  123. package/dist/utils/src/utils/uuid.js.map +1 -1
  124. package/dist/utils/src/utils/worker.d.ts +18 -0
  125. package/dist/utils/src/utils/worker.d.ts.map +1 -0
  126. package/dist/utils/src/utils/worker.js +23 -0
  127. package/dist/utils/src/utils/worker.js.map +1 -0
  128. package/dist/utils/tsconfig.build.tsbuildinfo +1 -0
  129. package/package.json +11 -4
  130. package/dist/bundles/utils.umd.js +0 -1663
  131. package/dist/bundles/utils.umd.js.map +0 -1
  132. package/dist/utils/src/BinaryReader.d.ts.map +0 -1
  133. package/dist/utils/src/BinaryReader.js.map +0 -1
  134. package/dist/utils/src/BinaryReader.spec.d.ts +0 -2
  135. package/dist/utils/src/BinaryReader.spec.d.ts.map +0 -1
  136. package/dist/utils/src/BinaryReader.spec.js +0 -38
  137. package/dist/utils/src/BinaryReader.spec.js.map +0 -1
  138. package/dist/utils/src/DataUri.d.ts +0 -36
  139. package/dist/utils/src/DataUri.d.ts.map +0 -1
  140. package/dist/utils/src/DataUri.js +0 -45
  141. package/dist/utils/src/DataUri.js.map +0 -1
  142. package/dist/utils/src/DataUri.spec.d.ts +0 -2
  143. package/dist/utils/src/DataUri.spec.d.ts.map +0 -1
  144. package/dist/utils/src/DataUri.spec.js +0 -34
  145. package/dist/utils/src/DataUri.spec.js.map +0 -1
  146. package/dist/utils/src/Events.d.ts +0 -59
  147. package/dist/utils/src/Events.d.ts.map +0 -1
  148. package/dist/utils/src/Events.js +0 -125
  149. package/dist/utils/src/Events.js.map +0 -1
  150. package/dist/utils/src/Events.spec.d.ts +0 -2
  151. package/dist/utils/src/Events.spec.d.ts.map +0 -1
  152. package/dist/utils/src/Events.spec.js +0 -61
  153. package/dist/utils/src/Events.spec.js.map +0 -1
  154. package/dist/utils/src/Http.d.ts +0 -56
  155. package/dist/utils/src/Http.d.ts.map +0 -1
  156. package/dist/utils/src/Http.js +0 -60
  157. package/dist/utils/src/Http.js.map +0 -1
  158. package/dist/utils/src/Http.spec.d.ts +0 -2
  159. package/dist/utils/src/Http.spec.d.ts.map +0 -1
  160. package/dist/utils/src/Http.spec.js +0 -23
  161. package/dist/utils/src/Http.spec.js.map +0 -1
  162. package/dist/utils/src/Immutable.d.ts +0 -10
  163. package/dist/utils/src/Immutable.d.ts.map +0 -1
  164. package/dist/utils/src/Immutable.js +0 -2
  165. package/dist/utils/src/Immutable.js.map +0 -1
  166. package/dist/utils/src/JsonRpc.d.ts +0 -35
  167. package/dist/utils/src/JsonRpc.d.ts.map +0 -1
  168. package/dist/utils/src/JsonRpc.js +0 -2
  169. package/dist/utils/src/JsonRpc.js.map +0 -1
  170. package/dist/utils/src/Log.d.ts +0 -26
  171. package/dist/utils/src/Log.d.ts.map +0 -1
  172. package/dist/utils/src/Log.js +0 -77
  173. package/dist/utils/src/Log.js.map +0 -1
  174. package/dist/utils/src/TextReader.d.ts +0 -100
  175. package/dist/utils/src/TextReader.d.ts.map +0 -1
  176. package/dist/utils/src/TextReader.js +0 -217
  177. package/dist/utils/src/TextReader.js.map +0 -1
  178. package/dist/utils/src/TextReader.spec.d.ts +0 -2
  179. package/dist/utils/src/TextReader.spec.d.ts.map +0 -1
  180. package/dist/utils/src/TextReader.spec.js +0 -42
  181. package/dist/utils/src/TextReader.spec.js.map +0 -1
  182. package/dist/utils/src/Uri.d.ts +0 -29
  183. package/dist/utils/src/Uri.d.ts.map +0 -1
  184. package/dist/utils/src/Uri.js +0 -129
  185. package/dist/utils/src/Uri.js.map +0 -1
  186. package/dist/utils/src/Uri.spec.d.ts +0 -2
  187. package/dist/utils/src/Uri.spec.d.ts.map +0 -1
  188. package/dist/utils/src/Uri.spec.js +0 -43
  189. package/dist/utils/src/Uri.spec.js.map +0 -1
  190. package/dist/utils/src/WebWorker.d.ts +0 -105
  191. package/dist/utils/src/WebWorker.d.ts.map +0 -1
  192. package/dist/utils/src/WebWorker.js +0 -216
  193. package/dist/utils/src/WebWorker.js.map +0 -1
  194. package/dist/utils/src/WebWorker.spec.d.ts +0 -2
  195. package/dist/utils/src/WebWorker.spec.d.ts.map +0 -1
  196. package/dist/utils/src/WebWorker.spec.js +0 -30
  197. package/dist/utils/src/WebWorker.spec.js.map +0 -1
  198. package/dist/utils/src/utils/array.d.ts +0 -39
  199. package/dist/utils/src/utils/array.d.ts.map +0 -1
  200. package/dist/utils/src/utils/array.js +0 -63
  201. package/dist/utils/src/utils/array.js.map +0 -1
  202. package/dist/utils/src/utils/get-canvas.d.ts +0 -7
  203. package/dist/utils/src/utils/get-canvas.d.ts.map +0 -1
  204. package/dist/utils/src/utils/get-canvas.js +0 -22
  205. package/dist/utils/src/utils/get-canvas.js.map +0 -1
  206. package/dist/utils/src/utils/get-option.d.ts +0 -11
  207. package/dist/utils/src/utils/get-option.d.ts.map +0 -1
  208. package/dist/utils/src/utils/get-option.js +0 -16
  209. package/dist/utils/src/utils/get-option.js.map +0 -1
  210. package/dist/utils/src/utils/getImageData.d.ts +0 -7
  211. package/dist/utils/src/utils/getImageData.d.ts.map +0 -1
  212. package/dist/utils/src/utils/getImageData.js +0 -25
  213. package/dist/utils/src/utils/getImageData.js.map +0 -1
  214. package/dist/utils/src/utils/getImageData.spec.d.ts +0 -2
  215. package/dist/utils/src/utils/getImageData.spec.d.ts.map +0 -1
  216. package/dist/utils/src/utils/getImageData.spec.js +0 -22
  217. package/dist/utils/src/utils/getImageData.spec.js.map +0 -1
  218. package/dist/utils/src/utils/hasOwnProperty.d.ts +0 -5
  219. package/dist/utils/src/utils/hasOwnProperty.d.ts.map +0 -1
  220. package/dist/utils/src/utils/hasOwnProperty.js +0 -7
  221. package/dist/utils/src/utils/hasOwnProperty.js.map +0 -1
  222. package/dist/utils/src/utils/loop.spec.d.ts +0 -2
  223. package/dist/utils/src/utils/loop.spec.d.ts.map +0 -1
  224. package/dist/utils/src/utils/loop.spec.js +0 -17
  225. package/dist/utils/src/utils/loop.spec.js.map +0 -1
  226. package/dist/utils/src/utils/object.d.ts +0 -23
  227. package/dist/utils/src/utils/object.d.ts.map +0 -1
  228. package/dist/utils/src/utils/object.js +0 -90
  229. package/dist/utils/src/utils/object.js.map +0 -1
  230. package/dist/utils/src/utils/string.d.ts +0 -19
  231. package/dist/utils/src/utils/string.d.ts.map +0 -1
  232. package/dist/utils/src/utils/string.js +0 -25
  233. package/dist/utils/src/utils/string.js.map +0 -1
  234. package/dist/utils/src/utils/type.d.ts +0 -58
  235. package/dist/utils/src/utils/type.d.ts.map +0 -1
  236. package/dist/utils/src/utils/type.js +0 -17
  237. package/dist/utils/src/utils/type.js.map +0 -1
  238. package/dist/utils/tsconfig.tsbuildinfo +0 -510
@@ -1,100 +0,0 @@
1
- /**
2
- * A wrapper around a string. Simplifies reading arbitrary formatted text data.
3
- *
4
- * @public
5
- */
6
- export declare class TextReader {
7
- private readonly text;
8
- private index;
9
- /**
10
- * Characters that identify a white space. Default is `' \t\r\n\f'`.
11
- */
12
- whitespaces: string;
13
- /**
14
- * Checks whether the readers position has not reached the end of the string
15
- */
16
- get canRead(): boolean;
17
- /**
18
- * Gets the character at the current readers position.
19
- */
20
- get char(): string;
21
- /**
22
- * Gets a substring until the end of the string.
23
- */
24
- get rest(): string;
25
- /**
26
- * Creates a new instance of {@link TextReader}
27
- *
28
- * @param text - The text data to read
29
- */
30
- constructor(text: string);
31
- /**
32
- * Advances the readers position to the next character.
33
- *
34
- * @remarks
35
- * If the reader is finished reading, an empty string will be returned
36
- *
37
- * @returns the character at the new position
38
- */
39
- next(): string;
40
- /**
41
- * Skips whites paces at current position and then reads until next whitespace character
42
- *
43
- * @returns the string that was being read
44
- */
45
- nextToken(): string;
46
- /**
47
- * Reads until next occurrence of a new line character
48
- *
49
- * @param cb - on optional callback that will receive a new reader for the new line
50
- * @returns the string that was being read
51
- */
52
- nextLine(cb?: (r: TextReader) => void): string;
53
- /**
54
- * Skips until next occurrence of `start` character and then reads the text until the `end` character
55
- *
56
- * @param start - character identifying the begin of a block
57
- * @param end - character identifying the begin of a block
58
- * @param cb - a callback to call with a new text reader
59
- */
60
- nextBlock(start: string, end: string, cb?: (r: TextReader) => void): string;
61
- /**
62
- * Returns the next character but does not advance the reader position.
63
- */
64
- peek(): string;
65
- /**
66
- * Returns the next token but does not advance the reader position.
67
- */
68
- peekToken(): string;
69
- /**
70
- * Returns the current line but does not advance the reader position
71
- */
72
- peekLine(): string;
73
- /**
74
- * Skips all whitespace characters
75
- */
76
- skipWhitespace(): void;
77
- /**
78
- * Skips all characters in given string
79
- *
80
- * @param char - the characters to skip
81
- */
82
- skipWhile(char: string): void;
83
- /**
84
- * Skips characters until occurrence of one in the given string
85
- *
86
- * @param char - the characters to stop at
87
- */
88
- skipUntil(char: string, andBeyond?: boolean): void;
89
- /**
90
- * Reads the next token but throws an error if it does not match the given value
91
- *
92
- * @param value - The value to match
93
- */
94
- consumeToken(value: string): void;
95
- /**
96
- * Consumes the next token only if it matches the given value. Otherwise leaves the state untouched.
97
- */
98
- acceptToken(value: string): boolean;
99
- }
100
- //# sourceMappingURL=TextReader.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TextReader.d.ts","sourceRoot":"","sources":["../../../src/TextReader.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,UAAU;IAkCT,OAAO,CAAC,QAAQ,CAAC,IAAI;IAjCjC,OAAO,CAAC,KAAK,CAAY;IAEzB;;OAEG;IACI,WAAW,SAAc;IAEhC;;OAEG;IACH,IAAW,OAAO,IAAI,OAAO,CAE5B;IAED;;OAEG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;OAEG;IACH,IAAW,IAAI,IAAI,MAAM,CAExB;IAED;;;;OAIG;gBAC0B,IAAI,EAAE,MAAM;IAIzC;;;;;;;OAOG;IACI,IAAI;IAQX;;;;OAIG;IACI,SAAS;IAWhB;;;;;OAKG;IACI,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI;IAc5C;;;;;;OAMG;IACI,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,IAAI;IAmCzE;;OAEG;IACI,IAAI;IAOX;;OAEG;IACI,SAAS;IAOhB;;OAEG;IACI,QAAQ;IAOf;;OAEG;IACI,cAAc;IAIrB;;;;OAIG;IACI,SAAS,CAAC,IAAI,EAAE,MAAM;IAM7B;;;;OAIG;IACI,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,UAAQ;IAShD;;;;OAIG;IACI,YAAY,CAAC,KAAK,EAAE,MAAM;IASjC;;OAEG;IACI,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;CAO3C"}
@@ -1,217 +0,0 @@
1
- /**
2
- * A wrapper around a string. Simplifies reading arbitrary formatted text data.
3
- *
4
- * @public
5
- */
6
- var TextReader = /** @class */ (function () {
7
- /**
8
- * Creates a new instance of {@link TextReader}
9
- *
10
- * @param text - The text data to read
11
- */
12
- function TextReader(text) {
13
- this.text = text;
14
- this.index = 0;
15
- /**
16
- * Characters that identify a white space. Default is `' \t\r\n\f'`.
17
- */
18
- this.whitespaces = ' \t\r\n\f';
19
- }
20
- Object.defineProperty(TextReader.prototype, "canRead", {
21
- /**
22
- * Checks whether the readers position has not reached the end of the string
23
- */
24
- get: function () {
25
- return this.index < this.text.length;
26
- },
27
- enumerable: false,
28
- configurable: true
29
- });
30
- Object.defineProperty(TextReader.prototype, "char", {
31
- /**
32
- * Gets the character at the current readers position.
33
- */
34
- get: function () {
35
- return this.text[this.index];
36
- },
37
- enumerable: false,
38
- configurable: true
39
- });
40
- Object.defineProperty(TextReader.prototype, "rest", {
41
- /**
42
- * Gets a substring until the end of the string.
43
- */
44
- get: function () {
45
- return this.text.substring(this.index);
46
- },
47
- enumerable: false,
48
- configurable: true
49
- });
50
- /**
51
- * Advances the readers position to the next character.
52
- *
53
- * @remarks
54
- * If the reader is finished reading, an empty string will be returned
55
- *
56
- * @returns the character at the new position
57
- */
58
- TextReader.prototype.next = function () {
59
- if (!this.canRead) {
60
- return '';
61
- }
62
- this.index++;
63
- return this.char;
64
- };
65
- /**
66
- * Skips whites paces at current position and then reads until next whitespace character
67
- *
68
- * @returns the string that was being read
69
- */
70
- TextReader.prototype.nextToken = function () {
71
- if (!this.canRead) {
72
- return '';
73
- }
74
- var i = this.index;
75
- this.skipWhile(this.whitespaces);
76
- this.skipUntil(this.whitespaces);
77
- this.skipWhile(this.whitespaces);
78
- return this.text.substr(i, this.index - i).trim();
79
- };
80
- /**
81
- * Reads until next occurrence of a new line character
82
- *
83
- * @param cb - on optional callback that will receive a new reader for the new line
84
- * @returns the string that was being read
85
- */
86
- TextReader.prototype.nextLine = function (cb) {
87
- if (!this.canRead) {
88
- return '';
89
- }
90
- var i = this.index;
91
- this.skipUntil('\n');
92
- this.next();
93
- var line = this.text.substr(i, this.index - i).trim();
94
- if (cb) {
95
- cb(new TextReader(line));
96
- }
97
- return line;
98
- };
99
- /**
100
- * Skips until next occurrence of `start` character and then reads the text until the `end` character
101
- *
102
- * @param start - character identifying the begin of a block
103
- * @param end - character identifying the begin of a block
104
- * @param cb - a callback to call with a new text reader
105
- */
106
- TextReader.prototype.nextBlock = function (start, end, cb) {
107
- if (!this.canRead) {
108
- return '';
109
- }
110
- this.skipUntil(start, true);
111
- var iStart = this.index;
112
- var iEnd = this.index;
113
- var depth = 1;
114
- while (this.canRead) {
115
- if (start.indexOf(this.char) >= 0) {
116
- depth++;
117
- }
118
- if (end.indexOf(this.char) >= 0) {
119
- depth--;
120
- if (depth === 0) {
121
- iEnd = this.index;
122
- this.next();
123
- break;
124
- }
125
- }
126
- this.next();
127
- }
128
- var block = this.text.substring(iStart, iEnd);
129
- if (cb) {
130
- cb(new TextReader(block));
131
- }
132
- return block;
133
- };
134
- /**
135
- * Returns the next character but does not advance the reader position.
136
- */
137
- TextReader.prototype.peek = function () {
138
- var i = this.index;
139
- var c = this.next();
140
- this.index = i;
141
- return c;
142
- };
143
- /**
144
- * Returns the next token but does not advance the reader position.
145
- */
146
- TextReader.prototype.peekToken = function () {
147
- var i = this.index;
148
- var t = this.nextToken();
149
- this.index = i;
150
- return t;
151
- };
152
- /**
153
- * Returns the current line but does not advance the reader position
154
- */
155
- TextReader.prototype.peekLine = function () {
156
- var i = this.index;
157
- var l = this.nextLine();
158
- this.index = i;
159
- return l;
160
- };
161
- /**
162
- * Skips all whitespace characters
163
- */
164
- TextReader.prototype.skipWhitespace = function () {
165
- this.skipWhile(this.whitespaces);
166
- };
167
- /**
168
- * Skips all characters in given string
169
- *
170
- * @param char - the characters to skip
171
- */
172
- TextReader.prototype.skipWhile = function (char) {
173
- while (this.canRead && char.indexOf(this.char) >= 0) {
174
- this.next();
175
- }
176
- };
177
- /**
178
- * Skips characters until occurrence of one in the given string
179
- *
180
- * @param char - the characters to stop at
181
- */
182
- TextReader.prototype.skipUntil = function (char, andBeyond) {
183
- if (andBeyond === void 0) { andBeyond = false; }
184
- while (this.canRead && char.indexOf(this.char) === -1) {
185
- this.next();
186
- }
187
- if (andBeyond) {
188
- this.skipWhile(char);
189
- }
190
- };
191
- /**
192
- * Reads the next token but throws an error if it does not match the given value
193
- *
194
- * @param value - The value to match
195
- */
196
- TextReader.prototype.consumeToken = function (value) {
197
- if (this.peekToken() !== value) {
198
- var line = (this.text.match(/\n/g) || []).length;
199
- var post = this.index - this.text.lastIndexOf('\n');
200
- throw new Error("expected token \"" + value + "\" but was \"" + this.peekToken() + "\" at " + line + ":" + post);
201
- }
202
- this.nextToken();
203
- };
204
- /**
205
- * Consumes the next token only if it matches the given value. Otherwise leaves the state untouched.
206
- */
207
- TextReader.prototype.acceptToken = function (value) {
208
- if (this.peekToken() !== value) {
209
- return false;
210
- }
211
- this.nextToken();
212
- return true;
213
- };
214
- return TextReader;
215
- }());
216
- export { TextReader };
217
- //# sourceMappingURL=TextReader.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TextReader.js","sourceRoot":"","sources":["../../../src/TextReader.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH;IA6BE;;;;OAIG;IACH,oBAA6B,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;QAjCjC,UAAK,GAAW,CAAC,CAAA;QAEzB;;WAEG;QACI,gBAAW,GAAG,WAAW,CAAA;IA8BhC,CAAC;IAzBD,sBAAW,+BAAO;QAHlB;;WAEG;aACH;YACE,OAAO,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAA;QACtC,CAAC;;;OAAA;IAKD,sBAAW,4BAAI;QAHf;;WAEG;aACH;YACE,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAC9B,CAAC;;;OAAA;IAKD,sBAAW,4BAAI;QAHf;;WAEG;aACH;YACE,OAAO,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QACxC,CAAC;;;OAAA;IAWD;;;;;;;OAOG;IACI,yBAAI,GAAX;QACE,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,OAAO,EAAE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E,cAAQ,IAAI,SAAI,IAAM,CAAC,CAAA;SAC9F;QACD,IAAI,CAAC,SAAS,EAAE,CAAA;IAClB,CAAC;IAED;;OAEG;IACI,gCAAW,GAAlB,UAAmB,KAAa;QAC9B,IAAI,IAAI,CAAC,SAAS,EAAE,KAAK,KAAK,EAAE;YAC9B,OAAO,KAAK,CAAA;SACb;QACD,IAAI,CAAC,SAAS,EAAE,CAAA;QAChB,OAAO,IAAI,CAAA;IACb,CAAC;IACH,iBAAC;AAAD,CAAC,AA1ND,IA0NC","sourcesContent":["/**\n * A wrapper around a string. Simplifies reading arbitrary formatted text data.\n *\n * @public\n */\nexport class TextReader {\n private index: number = 0\n\n /**\n * Characters that identify a white space. Default is `' \\t\\r\\n\\f'`.\n */\n public whitespaces = ' \\t\\r\\n\\f'\n\n /**\n * Checks whether the readers position has not reached the end of the string\n */\n public get canRead(): boolean {\n return this.index < this.text.length\n }\n\n /**\n * Gets the character at the current readers position.\n */\n public get char(): string {\n return this.text[this.index]\n }\n\n /**\n * Gets a substring until the end of the string.\n */\n public get rest(): string {\n return this.text.substring(this.index)\n }\n\n /**\n * Creates a new instance of {@link TextReader}\n *\n * @param text - The text data to read\n */\n constructor(private readonly text: string) {\n\n }\n\n /**\n * Advances the readers position to the next character.\n *\n * @remarks\n * If the reader is finished reading, an empty string will be returned\n *\n * @returns the character at the new position\n */\n public next() {\n if (!this.canRead) {\n return ''\n }\n this.index++\n return this.char\n }\n\n /**\n * Skips whites paces at current position and then reads until next whitespace character\n *\n * @returns the string that was being read\n */\n public nextToken() {\n if (!this.canRead) {\n return ''\n }\n const i = this.index\n this.skipWhile(this.whitespaces)\n this.skipUntil(this.whitespaces)\n this.skipWhile(this.whitespaces)\n return this.text.substr(i, this.index - i).trim()\n }\n\n /**\n * Reads until next occurrence of a new line character\n *\n * @param cb - on optional callback that will receive a new reader for the new line\n * @returns the string that was being read\n */\n public nextLine(cb?: (r: TextReader) => void) {\n if (!this.canRead) {\n return ''\n }\n const i = this.index\n this.skipUntil('\\n')\n this.next()\n const line = this.text.substr(i, this.index - i).trim()\n if (cb) {\n cb(new TextReader(line))\n }\n return line\n }\n\n /**\n * Skips until next occurrence of `start` character and then reads the text until the `end` character\n *\n * @param start - character identifying the begin of a block\n * @param end - character identifying the begin of a block\n * @param cb - a callback to call with a new text reader\n */\n public nextBlock(start: string, end: string, cb?: (r: TextReader) => void) {\n if (!this.canRead) {\n return ''\n }\n\n this.skipUntil(start, true)\n\n let iStart = this.index\n let iEnd = this.index\n let depth = 1\n\n while (this.canRead) {\n if (start.indexOf(this.char) >= 0) {\n depth++\n }\n if (end.indexOf(this.char) >= 0) {\n depth--\n\n if (depth === 0) {\n iEnd = this.index\n this.next()\n break\n }\n }\n this.next()\n }\n\n const block = this.text.substring(iStart, iEnd)\n\n if (cb) {\n cb(new TextReader(block))\n }\n return block\n }\n\n /**\n * Returns the next character but does not advance the reader position.\n */\n public peek() {\n const i = this.index\n const c = this.next()\n this.index = i\n return c\n }\n\n /**\n * Returns the next token but does not advance the reader position.\n */\n public peekToken() {\n const i = this.index\n const t = this.nextToken()\n this.index = i\n return t\n }\n\n /**\n * Returns the current line but does not advance the reader position\n */\n public peekLine() {\n const i = this.index\n const l = this.nextLine()\n this.index = i\n return l\n }\n\n /**\n * Skips all whitespace characters\n */\n public skipWhitespace() {\n this.skipWhile(this.whitespaces)\n }\n\n /**\n * Skips all characters in given string\n *\n * @param char - the characters to skip\n */\n public skipWhile(char: string) {\n while (this.canRead && char.indexOf(this.char) >= 0) {\n this.next()\n }\n }\n\n /**\n * Skips characters until occurrence of one in the given string\n *\n * @param char - the characters to stop at\n */\n public skipUntil(char: string, andBeyond = false) {\n while (this.canRead && char.indexOf(this.char) === -1) {\n this.next()\n }\n if (andBeyond) {\n this.skipWhile(char)\n }\n }\n\n /**\n * Reads the next token but throws an error if it does not match the given value\n *\n * @param value - The value to match\n */\n public consumeToken(value: string) {\n if (this.peekToken() !== value) {\n const line = (this.text.match(/\\n/g) || []).length\n const post = this.index - this.text.lastIndexOf('\\n')\n throw new Error(`expected token \"${value}\" but was \"${this.peekToken()}\" at ${line}:${post}`)\n }\n this.nextToken()\n }\n\n /**\n * Consumes the next token only if it matches the given value. Otherwise leaves the state untouched.\n */\n public acceptToken(value: string): boolean {\n if (this.peekToken() !== value) {\n return false\n }\n this.nextToken()\n return true\n }\n}\n"]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=TextReader.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TextReader.spec.d.ts","sourceRoot":"","sources":["../../../src/TextReader.spec.ts"],"names":[],"mappings":""}
@@ -1,42 +0,0 @@
1
- import { TextReader } from './TextReader';
2
- describe('Glib.Core.TextReader', function () {
3
- it('skipUntil', function () {
4
- var r = new TextReader('foo (bar) {baz}');
5
- r.skipUntil('({');
6
- expect(r.char).toBe('(');
7
- r.next();
8
- r.skipUntil('({', true);
9
- expect(r.char).toBe('b');
10
- expect(r.rest).toBe('baz}');
11
- });
12
- it('skipWhile', function () {
13
- var r = new TextReader('abababab123');
14
- r.skipWhile('ba');
15
- expect(r.char).toBe('1');
16
- expect(r.rest).toBe('123');
17
- });
18
- it('nextToken', function () {
19
- var r = new TextReader('\r\nfoo\n bar\t baz \fbingo');
20
- expect(r.nextToken()).toBe('foo');
21
- expect(r.nextToken()).toBe('bar');
22
- expect(r.nextToken()).toBe('baz');
23
- expect(r.nextToken()).toBe('bingo');
24
- expect(r.nextToken()).toBe('');
25
- });
26
- it('nextLine', function () {
27
- var r = new TextReader('foo foo\nbar bar\nbaz baz\n');
28
- expect(r.nextLine()).toBe('foo foo');
29
- expect(r.nextLine()).toBe('bar bar');
30
- expect(r.nextLine()).toBe('baz baz');
31
- expect(r.nextToken()).toBe('');
32
- });
33
- it('nextBlock', function () {
34
- var r = new TextReader('foo ( 1, 2, 3 ) bar ( 4, 5, 6 ) baz { 7, 8, 9 } ');
35
- expect(r.nextBlock('({', ')}')).toBe(' 1, 2, 3 ');
36
- expect(r.char).toBe(' ');
37
- expect(r.nextBlock('({', ')}')).toBe(' 4, 5, 6 ');
38
- expect(r.char).toBe(' ');
39
- expect(r.nextBlock('({', ')}')).toBe(' 7, 8, 9 ');
40
- });
41
- });
42
- //# sourceMappingURL=TextReader.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TextReader.spec.js","sourceRoot":"","sources":["../../../src/TextReader.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAEzC,QAAQ,CAAC,sBAAsB,EAAE;IAE/B,EAAE,CAAC,WAAW,EAAE;QACd,IAAM,CAAC,GAAG,IAAI,UAAU,CAAC,iBAAiB,CAAC,CAAA;QAC3C,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;QACjB,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QAExB,CAAC,CAAC,IAAI,EAAE,CAAA;QACR,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;QACvB,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACxB,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC7B,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,WAAW,EAAE;QACd,IAAM,CAAC,GAAG,IAAI,UAAU,CAAC,aAAa,CAAC,CAAA;QACvC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;QACjB,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACxB,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC5B,CAAC,CAAC,CAAA;IAEF,EAAE,CAAC,WAAW,EAAE;QACd,IAAM,CAAC,GAAG,IAAI,UAAU,C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AC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QACjD,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;QACxB,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;IACnD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { TextReader } from './TextReader'\n\ndescribe('Glib.Core.TextReader', () => {\n\n it('skipUntil', () => {\n const r = new TextReader('foo (bar) {baz}')\n r.skipUntil('({')\n expect(r.char).toBe('(')\n\n r.next()\n r.skipUntil('({', true)\n expect(r.char).toBe('b')\n expect(r.rest).toBe('baz}')\n })\n\n it('skipWhile', () => {\n const r = new TextReader('abababab123')\n r.skipWhile('ba')\n expect(r.char).toBe('1')\n expect(r.rest).toBe('123')\n })\n\n it('nextToken', () => {\n const r = new TextReader('\\r\\nfoo\\n bar\\t baz \\fbingo')\n expect(r.nextToken()).toBe('foo')\n expect(r.nextToken()).toBe('bar')\n expect(r.nextToken()).toBe('baz')\n expect(r.nextToken()).toBe('bingo')\n expect(r.nextToken()).toBe('')\n })\n\n it('nextLine', () => {\n const r = new TextReader('foo foo\\nbar bar\\nbaz baz\\n')\n expect(r.nextLine()).toBe('foo foo')\n expect(r.nextLine()).toBe('bar bar')\n expect(r.nextLine()).toBe('baz baz')\n expect(r.nextToken()).toBe('')\n })\n\n it('nextBlock', () => {\n const r = new TextReader('foo ( 1, 2, 3 ) bar ( 4, 5, 6 ) baz { 7, 8, 9 } ')\n expect(r.nextBlock('({', ')}')).toBe(' 1, 2, 3 ')\n expect(r.char).toBe(' ')\n expect(r.nextBlock('({', ')}')).toBe(' 4, 5, 6 ')\n expect(r.char).toBe(' ')\n expect(r.nextBlock('({', ')}')).toBe(' 7, 8, 9 ')\n })\n})\n"]}
@@ -1,29 +0,0 @@
1
- /**
2
- * @public
3
- */
4
- export declare class Uri {
5
- /**
6
- * Parses a string and extracts all uri components
7
- */
8
- static parse(path: string, strict?: boolean): any;
9
- static dir(path: string): any;
10
- static file(path: string): string;
11
- static ext(path: string): string;
12
- static merge(a: string, b: string): string;
13
- static escape(fragment: string): string;
14
- source: string;
15
- protocol: string;
16
- authority: string;
17
- userInfo: string;
18
- user: string;
19
- password: string;
20
- host: string;
21
- port: string;
22
- relative: string;
23
- path: string;
24
- directory: string;
25
- file: string;
26
- query: string;
27
- anchor: string;
28
- }
29
- //# sourceMappingURL=Uri.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Uri.d.ts","sourceRoot":"","sources":["../../../src/Uri.ts"],"names":[],"mappings":"AA4DA;;GAEG;AACH,qBAAa,GAAG;IACd;;OAEG;WACW,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,GAAE,OAAc;WAoB1C,GAAG,CAAC,IAAI,EAAE,MAAM;WAIhB,IAAI,CAAC,IAAI,EAAE,MAAM;WAIjB,GAAG,CAAC,IAAI,EAAE,MAAM;WAIhB,KAAK,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM;WA6B1B,MAAM,CAAC,QAAQ,EAAE,MAAM;IAO9B,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;CACtB"}
@@ -1,129 +0,0 @@
1
- // source: https://github.com/nodejs/node/blob/master/lib/path.js
2
- var pathSplit = /^(\/?|[\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/;
3
- // source: http://blog.stevenlevithan.com/archives/parseuri
4
- var options = {
5
- key: [
6
- 'source',
7
- 'protocol',
8
- 'authority',
9
- 'userInfo',
10
- 'user',
11
- 'password',
12
- 'host',
13
- 'port',
14
- 'relative',
15
- 'path',
16
- 'directory',
17
- 'file',
18
- 'query',
19
- 'anchor',
20
- ],
21
- q: {
22
- name: 'queryKey',
23
- parser: /(?:^|&)([^&=]*)=?([^&]*)/g,
24
- },
25
- parser: {
26
- // tslint:disable
27
- strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
28
- loose: /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
29
- // tslint:enable
30
- },
31
- };
32
- function isAbsolute(path) {
33
- return !!path && path[0] === '/';
34
- }
35
- function hasProtocol(path) {
36
- return !!path && !!path.match(/^[a-zA-Z]+:\/\//i);
37
- }
38
- function collapse(path) {
39
- var wasAbsolute = isAbsolute(path);
40
- var parts = [];
41
- for (var _i = 0, _a = path.split(/\//); _i < _a.length; _i++) {
42
- var token = _a[_i];
43
- if (!token || token === '.') {
44
- continue;
45
- }
46
- if (token === '..') {
47
- parts.pop();
48
- }
49
- else {
50
- parts.push(token);
51
- }
52
- }
53
- var result = parts.join('/');
54
- if (wasAbsolute) {
55
- result = "/" + result;
56
- }
57
- return result;
58
- }
59
- /**
60
- * @public
61
- */
62
- var Uri = /** @class */ (function () {
63
- function Uri() {
64
- }
65
- /**
66
- * Parses a string and extracts all uri components
67
- */
68
- Uri.parse = function (path, strict) {
69
- if (strict === void 0) { strict = true; }
70
- var o = options;
71
- var m = o.parser[strict ? 'strict' : 'loose'].exec(path);
72
- var uri = new Uri();
73
- var i = 14;
74
- while (i--) {
75
- uri[o.key[i]] = m[i] || '';
76
- }
77
- uri[o.q.name] = {};
78
- uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
79
- if ($1) {
80
- uri[o.q.name][$1] = $2;
81
- }
82
- });
83
- return uri;
84
- };
85
- Uri.dir = function (path) {
86
- return Uri.parse(path).directory;
87
- };
88
- Uri.file = function (path) {
89
- return pathSplit.exec(path)[2];
90
- };
91
- Uri.ext = function (path) {
92
- return pathSplit.exec(path)[3];
93
- };
94
- Uri.merge = function (a, b) {
95
- if (hasProtocol(b)) {
96
- return b;
97
- }
98
- var aUri = Uri.parse(a);
99
- var bUri = Uri.parse(b);
100
- var path = isAbsolute(b) ? b : aUri.directory + bUri.path;
101
- path = collapse(path);
102
- if (bUri.query) {
103
- path += "?" + bUri.query;
104
- }
105
- if (bUri.anchor) {
106
- path += "#" + bUri.anchor;
107
- }
108
- var result = '';
109
- if (aUri.protocol) {
110
- result = aUri.protocol + '://';
111
- }
112
- if (aUri.authority) {
113
- result += aUri.authority;
114
- }
115
- if (!isAbsolute(path)) {
116
- result += '/';
117
- }
118
- return result + path;
119
- };
120
- Uri.escape = function (fragment) {
121
- if (fragment.length > 1) {
122
- return fragment[0] + fragment.substring(1).replace(/[!"#$%&'()*+,-.\/\\:;<=>?@\[\]^`{|}~]/gi, function (token) { return "\\" + token; });
123
- }
124
- return fragment;
125
- };
126
- return Uri;
127
- }());
128
- export { Uri };
129
- //# sourceMappingURL=Uri.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Uri.js","sourceRoot":"","sources":["../../../src/Uri.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,I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AC,SAAS,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,yCAAyC,EAAE,UAAC,KAAK,IAAK,OAAA,OAAK,KAAO,EAAZ,CAAY,CAAC,CAAA;SACvH;QACD,OAAO,QAAQ,CAAA;IACjB,CAAC;IAgBH,UAAC;AAAD,CAAC,AAtFD,IAsFC","sourcesContent":["// source: https://github.com/nodejs/node/blob/master/lib/path.js\nconst pathSplit = /^(\\/?|[\\s\\S]*?)((?:\\.{1,2}|[^\\/]+?|)(\\.[^.\\/]*|))(?:[\\/]*)$/\n// source: http://blog.stevenlevithan.com/archives/parseuri\nconst options = {\n key: [\n 'source',\n 'protocol',\n 'authority',\n 'userInfo',\n 'user',\n 'password',\n 'host',\n 'port',\n 'relative',\n 'path',\n 'directory',\n 'file',\n 'query',\n 'anchor',\n ],\n q: {\n name: 'queryKey',\n parser: /(?:^|&)([^&=]*)=?([^&]*)/g,\n },\n parser: {\n // tslint:disable\n strict: /^(?:([^:\\/?#]+):)?(?:\\/\\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\\/?#]*)(?::(\\d*))?))?((((?:[^?#\\/]*\\/)*)([^?#]*))(?:\\?([^#]*))?(?:#(.*))?)/,\n loose: /^(?:(?![^:@]+:[^:@\\/]*@)([^:\\/?#.]+):)?(?:\\/\\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\\/?#]*)(?::(\\d*))?)(((\\/(?:[^?#](?![^?#\\/]*\\.[^?#\\/.]+(?:[?#]|$)))*\\/?)?([^?#\\/]*))(?:\\?([^#]*))?(?:#(.*))?)/\n // tslint:enable\n },\n}\n\nfunction isAbsolute(path: string) {\n return !!path && path[0] === '/'\n}\n\nfunction hasProtocol(path: string) {\n return !!path && !!path.match(/^[a-zA-Z]+:\\/\\//i)\n}\n\nfunction collapse(path: string) {\n const wasAbsolute = isAbsolute(path)\n const parts = []\n for (const token of path.split(/\\//)) {\n if (!token || token === '.') {\n continue\n }\n if (token === '..') {\n parts.pop()\n } else {\n parts.push(token)\n }\n }\n let result = parts.join('/')\n if (wasAbsolute) {\n result = `/${result}`\n }\n return result\n}\n\n/**\n * @public\n */\nexport class Uri {\n /**\n * Parses a string and extracts all uri components\n */\n public static parse(path: string, strict: boolean = true) {\n let\to = options\n let m = o.parser[strict ? 'strict' : 'loose'].exec(path)\n let uri: any = new Uri()\n let i = 14\n\n while (i--) {\n uri[o.key[i]] = m[i] || ''\n }\n\n uri[o.q.name] = {}\n uri[o.key[12]].replace(o.q.parser, ($0: string, $1: string, $2: string) => {\n if ($1) {\n uri[o.q.name][$1] = $2\n }\n })\n\n return uri\n }\n\n public static dir(path: string) {\n return Uri.parse(path).directory\n }\n\n public static file(path: string) {\n return pathSplit.exec(path)[2]\n }\n\n public static ext(path: string) {\n return pathSplit.exec(path)[3]\n }\n\n public static merge(a: string, b: string) {\n if (hasProtocol(b)) {\n return b\n }\n\n let aUri = Uri.parse(a)\n let bUri = Uri.parse(b)\n let path = isAbsolute(b) ? b : aUri.directory + bUri.path\n path = collapse(path)\n if (bUri.query) {\n path += `?${bUri.query}`\n }\n if (bUri.anchor) {\n path += `#${bUri.anchor}`\n }\n\n let result = ''\n if (aUri.protocol) {\n result = aUri.protocol + '://'\n }\n if (aUri.authority) {\n result += aUri.authority\n }\n if (!isAbsolute(path)) {\n result += '/'\n }\n return result + path\n }\n\n public static escape(fragment: string) {\n if (fragment.length > 1) {\n return fragment[0] + fragment.substring(1).replace(/[!\"#$%&'()*+,-.\\/\\\\:;<=>?@\\[\\]^`{|}~]/gi, (token) => `\\\\${token}`)\n }\n return fragment\n }\n\n public source: string\n public protocol: string\n public authority: string\n public userInfo: string\n public user: string\n public password: string\n public host: string\n public port: string\n public relative: string\n public path: string\n public directory: string\n public file: string\n public query: string\n public anchor: string\n}\n"]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=Uri.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Uri.spec.d.ts","sourceRoot":"","sources":["../../../src/Uri.spec.ts"],"names":[],"mappings":""}
@@ -1,43 +0,0 @@
1
- import { Uri } from './Uri';
2
- describe('@gglib/utils/Uri', function () {
3
- describe('.parse', function () {
4
- it('parses the uri', function () {
5
- var parsed = Uri.parse('http://www.example.com:80/foo/bar?lorem=ipsum#dolor');
6
- expect(parsed.source).toBe('http://www.example.com:80/foo/bar?lorem=ipsum#dolor');
7
- expect(parsed.protocol).toBe('http');
8
- expect(parsed.host).toBe('www.example.com');
9
- expect(parsed.port).toBe('80');
10
- expect(parsed.authority).toBe('www.example.com:80');
11
- expect(parsed.path).toBe('/foo/bar');
12
- expect(parsed.directory).toBe('/foo/');
13
- expect(parsed.file).toBe('bar');
14
- });
15
- });
16
- describe('.dir', function () {
17
- it('returns the dir', function () {
18
- expect(Uri.dir('foo/bar/lorem')).toBe('foo/bar/');
19
- });
20
- });
21
- describe('.file', function () {
22
- it('returns the name of the file', function () {
23
- expect(Uri.file('foo/bar/lorem.png')).toBe('lorem.png');
24
- });
25
- });
26
- describe('.ext', function () {
27
- it('returns the extension name of the file', function () {
28
- expect(Uri.ext('foo/bar/lorem.png')).toBe('.png');
29
- });
30
- });
31
- describe('.merge', function () {
32
- it('merges two paths', function () {
33
- expect(Uri.merge('foo/bar/baz', '../lorem/ipsum.png')).toBe('/foo/lorem/ipsum.png');
34
- expect(Uri.merge('foo/bar/baz/', '../lorem/ipsum.png')).toBe('/foo/bar/lorem/ipsum.png');
35
- expect(Uri.merge('http://example.com/foo/bar/baz/', '../lorem/ipsum.png')).toBe('http://example.com/foo/bar/lorem/ipsum.png');
36
- });
37
- it('ignores first param if second is absolute', function () {
38
- expect(Uri.merge('foo/bar/baz/', '/lorem/ipsum.png')).toBe('/lorem/ipsum.png');
39
- expect(Uri.merge('foo/bar/baz/', 'http://example.com')).toBe('http://example.com');
40
- });
41
- });
42
- });
43
- //# sourceMappingURL=Uri.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Uri.spec.js","sourceRoot":"","sources":["../../../src/U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I,CAAC,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QACzD,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,QAAQ,CAAC,MAAM,EAAE;QACf,EAAE,CAAE,wCAAwC,EAAE;YAC5C,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QACnD,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;IAEF,QAAQ,CAAC,QAAQ,EAAE;QACjB,EAAE,CAAE,kBAAkB,EAAE;YACtB,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,aAAa,EAAE,oBAAoB,CAAC,CAAC,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAA;YACnF,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,cAAc,EAAE,oBAAoB,CAAC,CAAC,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAA;YACxF,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,iCAAiC,EAAE,oBAAoB,CAAC,CAAC,CAAC,IAAI,CAAC,4CAA4C,CAAC,CAAA;QAC/H,CAAC,CAAC,CAAA;QAEF,EAAE,CAAE,2CAA2C,EAAE;YAC/C,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAA;YAC9E,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,cAAc,EAAE,oBAAoB,CAAC,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA;QACpF,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA","sourcesContent":["import { Uri } from './Uri'\n\ndescribe('@gglib/utils/Uri', () => {\n describe('.parse', () => {\n it('parses the uri', () => {\n const parsed = Uri.parse('http://www.example.com:80/foo/bar?lorem=ipsum#dolor')\n expect(parsed.source).toBe('http://www.example.com:80/foo/bar?lorem=ipsum#dolor')\n expect(parsed.protocol).toBe('http')\n expect(parsed.host).toBe('www.example.com')\n expect(parsed.port).toBe('80')\n expect(parsed.authority).toBe('www.example.com:80')\n expect(parsed.path).toBe('/foo/bar')\n expect(parsed.directory).toBe('/foo/')\n expect(parsed.file).toBe('bar')\n })\n })\n\n describe('.dir', () => {\n it ('returns the dir', () => {\n expect(Uri.dir('foo/bar/lorem')).toBe('foo/bar/')\n })\n })\n\n describe('.file', () => {\n it ('returns the name of the file', () => {\n expect(Uri.file('foo/bar/lorem.png')).toBe('lorem.png')\n })\n })\n\n describe('.ext', () => {\n it ('returns the extension name of the file', () => {\n expect(Uri.ext('foo/bar/lorem.png')).toBe('.png')\n })\n })\n\n describe('.merge', () => {\n it ('merges two paths', () => {\n expect(Uri.merge('foo/bar/baz', '../lorem/ipsum.png')).toBe('/foo/lorem/ipsum.png')\n expect(Uri.merge('foo/bar/baz/', '../lorem/ipsum.png')).toBe('/foo/bar/lorem/ipsum.png')\n expect(Uri.merge('http://example.com/foo/bar/baz/', '../lorem/ipsum.png')).toBe('http://example.com/foo/bar/lorem/ipsum.png')\n })\n\n it ('ignores first param if second is absolute', () => {\n expect(Uri.merge('foo/bar/baz/', '/lorem/ipsum.png')).toBe('/lorem/ipsum.png')\n expect(Uri.merge('foo/bar/baz/', 'http://example.com')).toBe('http://example.com')\n })\n })\n})\n"]}