@gomomento/sdk-core 1.12.8

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 (184) hide show
  1. package/dist/src/auth/credential-provider.d.ts +83 -0
  2. package/dist/src/auth/credential-provider.js +82 -0
  3. package/dist/src/auth/index.d.ts +1 -0
  4. package/dist/src/auth/index.js +18 -0
  5. package/dist/src/config/logging/default-momento-logger.d.ts +24 -0
  6. package/dist/src/config/logging/default-momento-logger.js +69 -0
  7. package/dist/src/config/logging/index.d.ts +3 -0
  8. package/dist/src/config/logging/index.js +20 -0
  9. package/dist/src/config/logging/momento-logger.d.ts +10 -0
  10. package/dist/src/config/logging/momento-logger.js +3 -0
  11. package/dist/src/config/logging/noop-momento-logger.d.ts +11 -0
  12. package/dist/src/config/logging/noop-momento-logger.js +34 -0
  13. package/dist/src/config/transport/grpc-configuration.d.ts +41 -0
  14. package/dist/src/config/transport/grpc-configuration.js +3 -0
  15. package/dist/src/config/transport/index.d.ts +2 -0
  16. package/dist/src/config/transport/index.js +19 -0
  17. package/dist/src/config/transport/transport-strategy.d.ts +77 -0
  18. package/dist/src/config/transport/transport-strategy.js +60 -0
  19. package/dist/src/errors/error-utils.d.ts +2 -0
  20. package/dist/src/errors/error-utils.js +12 -0
  21. package/dist/src/errors/errors.d.ts +140 -0
  22. package/dist/src/errors/errors.js +229 -0
  23. package/dist/src/errors/index.d.ts +2 -0
  24. package/dist/src/errors/index.js +19 -0
  25. package/dist/src/index.d.ts +57 -0
  26. package/dist/src/index.js +137 -0
  27. package/dist/src/internal/clients/auth/AbstractAuthClient.d.ts +10 -0
  28. package/dist/src/internal/clients/auth/AbstractAuthClient.js +13 -0
  29. package/dist/src/internal/clients/auth/IAuthClient.d.ts +4 -0
  30. package/dist/src/internal/clients/auth/IAuthClient.js +3 -0
  31. package/dist/src/internal/clients/auth/index.d.ts +2 -0
  32. package/dist/src/internal/clients/auth/index.js +19 -0
  33. package/dist/src/internal/clients/cache/AbstractCacheClient.d.ts +638 -0
  34. package/dist/src/internal/clients/cache/AbstractCacheClient.js +870 -0
  35. package/dist/src/internal/clients/cache/ICacheClient.d.ts +45 -0
  36. package/dist/src/internal/clients/cache/ICacheClient.js +3 -0
  37. package/dist/src/internal/clients/cache/IControlClient.d.ts +7 -0
  38. package/dist/src/internal/clients/cache/IControlClient.js +3 -0
  39. package/dist/src/internal/clients/cache/IDataClient.d.ts +29 -0
  40. package/dist/src/internal/clients/cache/IDataClient.js +3 -0
  41. package/dist/src/internal/clients/cache/index.d.ts +4 -0
  42. package/dist/src/internal/clients/cache/index.js +21 -0
  43. package/dist/src/internal/clients/index.d.ts +3 -0
  44. package/dist/src/internal/clients/index.js +20 -0
  45. package/dist/src/internal/clients/ping/AbstractPingClient.d.ts +25 -0
  46. package/dist/src/internal/clients/ping/AbstractPingClient.js +29 -0
  47. package/dist/src/internal/clients/ping/IPingClient.d.ts +3 -0
  48. package/dist/src/internal/clients/ping/IPingClient.js +3 -0
  49. package/dist/src/internal/clients/ping/index.d.ts +2 -0
  50. package/dist/src/internal/clients/ping/index.js +19 -0
  51. package/dist/src/internal/subscription-state.d.ts +15 -0
  52. package/dist/src/internal/subscription-state.js +38 -0
  53. package/dist/src/internal/utils/auth.d.ts +25 -0
  54. package/dist/src/internal/utils/auth.js +50 -0
  55. package/dist/src/internal/utils/collections.d.ts +1 -0
  56. package/dist/src/internal/utils/collections.js +8 -0
  57. package/dist/src/internal/utils/display.d.ts +2 -0
  58. package/dist/src/internal/utils/display.js +30 -0
  59. package/dist/src/internal/utils/index.d.ts +7 -0
  60. package/dist/src/internal/utils/index.js +24 -0
  61. package/dist/src/internal/utils/object.d.ts +1 -0
  62. package/dist/src/internal/utils/object.js +8 -0
  63. package/dist/src/internal/utils/sleep.d.ts +1 -0
  64. package/dist/src/internal/utils/sleep.js +6 -0
  65. package/dist/src/internal/utils/string.d.ts +2 -0
  66. package/dist/src/internal/utils/string.js +17 -0
  67. package/dist/src/internal/utils/validators.d.ts +13 -0
  68. package/dist/src/internal/utils/validators.js +105 -0
  69. package/dist/src/internal/vendor/printf/README.md +31 -0
  70. package/dist/src/internal/vendor/printf/printf.d.ts +9 -0
  71. package/dist/src/internal/vendor/printf/printf.js +478 -0
  72. package/dist/src/messages/cache-info.d.ts +5 -0
  73. package/dist/src/messages/cache-info.js +13 -0
  74. package/dist/src/messages/responses/cache-delete.d.ts +61 -0
  75. package/dist/src/messages/responses/cache-delete.js +54 -0
  76. package/dist/src/messages/responses/cache-dictionary-fetch.d.ts +120 -0
  77. package/dist/src/messages/responses/cache-dictionary-fetch.js +162 -0
  78. package/dist/src/messages/responses/cache-dictionary-get-field.d.ts +123 -0
  79. package/dist/src/messages/responses/cache-dictionary-get-field.js +143 -0
  80. package/dist/src/messages/responses/cache-dictionary-get-fields.d.ts +122 -0
  81. package/dist/src/messages/responses/cache-dictionary-get-fields.js +173 -0
  82. package/dist/src/messages/responses/cache-dictionary-increment.d.ts +69 -0
  83. package/dist/src/messages/responses/cache-dictionary-increment.js +68 -0
  84. package/dist/src/messages/responses/cache-dictionary-remove-field.d.ts +61 -0
  85. package/dist/src/messages/responses/cache-dictionary-remove-field.js +54 -0
  86. package/dist/src/messages/responses/cache-dictionary-remove-fields.d.ts +61 -0
  87. package/dist/src/messages/responses/cache-dictionary-remove-fields.js +54 -0
  88. package/dist/src/messages/responses/cache-dictionary-set-field.d.ts +61 -0
  89. package/dist/src/messages/responses/cache-dictionary-set-field.js +54 -0
  90. package/dist/src/messages/responses/cache-dictionary-set-fields.d.ts +61 -0
  91. package/dist/src/messages/responses/cache-dictionary-set-fields.js +54 -0
  92. package/dist/src/messages/responses/cache-flush.d.ts +61 -0
  93. package/dist/src/messages/responses/cache-flush.js +54 -0
  94. package/dist/src/messages/responses/cache-get.d.ts +86 -0
  95. package/dist/src/messages/responses/cache-get.js +88 -0
  96. package/dist/src/messages/responses/cache-increment.d.ts +69 -0
  97. package/dist/src/messages/responses/cache-increment.js +68 -0
  98. package/dist/src/messages/responses/cache-list-concatenate-back.d.ts +69 -0
  99. package/dist/src/messages/responses/cache-list-concatenate-back.js +68 -0
  100. package/dist/src/messages/responses/cache-list-concatenate-front.d.ts +69 -0
  101. package/dist/src/messages/responses/cache-list-concatenate-front.js +68 -0
  102. package/dist/src/messages/responses/cache-list-fetch.d.ts +92 -0
  103. package/dist/src/messages/responses/cache-list-fetch.js +96 -0
  104. package/dist/src/messages/responses/cache-list-length.d.ts +84 -0
  105. package/dist/src/messages/responses/cache-list-length.js +78 -0
  106. package/dist/src/messages/responses/cache-list-pop-back.d.ts +86 -0
  107. package/dist/src/messages/responses/cache-list-pop-back.js +88 -0
  108. package/dist/src/messages/responses/cache-list-pop-front.d.ts +86 -0
  109. package/dist/src/messages/responses/cache-list-pop-front.js +88 -0
  110. package/dist/src/messages/responses/cache-list-push-back.d.ts +69 -0
  111. package/dist/src/messages/responses/cache-list-push-back.js +68 -0
  112. package/dist/src/messages/responses/cache-list-push-front.d.ts +69 -0
  113. package/dist/src/messages/responses/cache-list-push-front.js +68 -0
  114. package/dist/src/messages/responses/cache-list-remove-value.d.ts +61 -0
  115. package/dist/src/messages/responses/cache-list-remove-value.js +54 -0
  116. package/dist/src/messages/responses/cache-list-retain.d.ts +61 -0
  117. package/dist/src/messages/responses/cache-list-retain.js +54 -0
  118. package/dist/src/messages/responses/cache-set-add-element.d.ts +71 -0
  119. package/dist/src/messages/responses/cache-set-add-element.js +54 -0
  120. package/dist/src/messages/responses/cache-set-add-elements.d.ts +65 -0
  121. package/dist/src/messages/responses/cache-set-add-elements.js +61 -0
  122. package/dist/src/messages/responses/cache-set-fetch.d.ts +111 -0
  123. package/dist/src/messages/responses/cache-set-fetch.js +121 -0
  124. package/dist/src/messages/responses/cache-set-if-not-exists.d.ts +74 -0
  125. package/dist/src/messages/responses/cache-set-if-not-exists.js +63 -0
  126. package/dist/src/messages/responses/cache-set-remove-element.d.ts +61 -0
  127. package/dist/src/messages/responses/cache-set-remove-element.js +54 -0
  128. package/dist/src/messages/responses/cache-set-remove-elements.d.ts +65 -0
  129. package/dist/src/messages/responses/cache-set-remove-elements.js +61 -0
  130. package/dist/src/messages/responses/cache-set.d.ts +61 -0
  131. package/dist/src/messages/responses/cache-set.js +54 -0
  132. package/dist/src/messages/responses/cache-sorted-set-fetch.d.ts +107 -0
  133. package/dist/src/messages/responses/cache-sorted-set-fetch.js +124 -0
  134. package/dist/src/messages/responses/cache-sorted-set-get-rank.d.ts +81 -0
  135. package/dist/src/messages/responses/cache-sorted-set-get-rank.js +78 -0
  136. package/dist/src/messages/responses/cache-sorted-set-get-score.d.ts +118 -0
  137. package/dist/src/messages/responses/cache-sorted-set-get-score.js +131 -0
  138. package/dist/src/messages/responses/cache-sorted-set-get-scores.d.ts +109 -0
  139. package/dist/src/messages/responses/cache-sorted-set-get-scores.js +148 -0
  140. package/dist/src/messages/responses/cache-sorted-set-increment-score.d.ts +69 -0
  141. package/dist/src/messages/responses/cache-sorted-set-increment-score.js +68 -0
  142. package/dist/src/messages/responses/cache-sorted-set-put-element.d.ts +61 -0
  143. package/dist/src/messages/responses/cache-sorted-set-put-element.js +54 -0
  144. package/dist/src/messages/responses/cache-sorted-set-put-elements.d.ts +61 -0
  145. package/dist/src/messages/responses/cache-sorted-set-put-elements.js +54 -0
  146. package/dist/src/messages/responses/cache-sorted-set-remove-element.d.ts +61 -0
  147. package/dist/src/messages/responses/cache-sorted-set-remove-element.js +54 -0
  148. package/dist/src/messages/responses/cache-sorted-set-remove-elements.d.ts +61 -0
  149. package/dist/src/messages/responses/cache-sorted-set-remove-elements.js +54 -0
  150. package/dist/src/messages/responses/create-cache.d.ts +77 -0
  151. package/dist/src/messages/responses/create-cache.js +61 -0
  152. package/dist/src/messages/responses/create-signing-key.d.ts +71 -0
  153. package/dist/src/messages/responses/create-signing-key.js +76 -0
  154. package/dist/src/messages/responses/delete-cache.d.ts +61 -0
  155. package/dist/src/messages/responses/delete-cache.js +54 -0
  156. package/dist/src/messages/responses/generate-api-token.d.ts +50 -0
  157. package/dist/src/messages/responses/generate-api-token.js +52 -0
  158. package/dist/src/messages/responses/grpc-response-types.d.ts +41 -0
  159. package/dist/src/messages/responses/grpc-response-types.js +53 -0
  160. package/dist/src/messages/responses/list-caches.d.ts +70 -0
  161. package/dist/src/messages/responses/list-caches.js +69 -0
  162. package/dist/src/messages/responses/list-signing-keys.d.ts +68 -0
  163. package/dist/src/messages/responses/list-signing-keys.js +68 -0
  164. package/dist/src/messages/responses/response-base.d.ts +43 -0
  165. package/dist/src/messages/responses/response-base.js +50 -0
  166. package/dist/src/messages/responses/revoke-signing-key.d.ts +61 -0
  167. package/dist/src/messages/responses/revoke-signing-key.js +54 -0
  168. package/dist/src/messages/responses/topic-item.d.ts +27 -0
  169. package/dist/src/messages/responses/topic-item.js +43 -0
  170. package/dist/src/messages/responses/topic-publish.d.ts +61 -0
  171. package/dist/src/messages/responses/topic-publish.js +54 -0
  172. package/dist/src/messages/responses/topic-subscribe.d.ts +69 -0
  173. package/dist/src/messages/responses/topic-subscribe.js +72 -0
  174. package/dist/src/messages/signing-key.d.ts +9 -0
  175. package/dist/src/messages/signing-key.js +21 -0
  176. package/dist/src/utils/cache-call-options.d.ts +99 -0
  177. package/dist/src/utils/cache-call-options.js +9 -0
  178. package/dist/src/utils/collection-ttl.d.ts +78 -0
  179. package/dist/src/utils/collection-ttl.js +102 -0
  180. package/dist/src/utils/index.d.ts +3 -0
  181. package/dist/src/utils/index.js +20 -0
  182. package/dist/src/utils/topic-call-options.d.ts +19 -0
  183. package/dist/src/utils/topic-call-options.js +3 -0
  184. package/package.json +53 -0
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isBase64 = exports.validateTtlMinutes = exports.validateTopicName = exports.validateListSliceStartEnd = exports.validateListName = exports.validateDictionaryName = exports.validateSortedSetCount = exports.validateSortedSetOffset = exports.validateSortedSetScores = exports.validateSortedSetRanks = exports.validateSortedSetName = exports.validateSetName = exports.validateCacheName = void 0;
4
+ const errors_1 = require("../../errors/errors");
5
+ const string_1 = require("./string");
6
+ function validateCacheName(name) {
7
+ if (isEmpty(name)) {
8
+ throw new errors_1.InvalidArgumentError('cache name must not be empty');
9
+ }
10
+ }
11
+ exports.validateCacheName = validateCacheName;
12
+ function validateSetName(name) {
13
+ if (isEmpty(name)) {
14
+ throw new errors_1.InvalidArgumentError('set name must not be empty');
15
+ }
16
+ }
17
+ exports.validateSetName = validateSetName;
18
+ function validateSortedSetName(name) {
19
+ if (isEmpty(name)) {
20
+ throw new errors_1.InvalidArgumentError('sorted set name must not be empty');
21
+ }
22
+ }
23
+ exports.validateSortedSetName = validateSortedSetName;
24
+ function validateSortedSetRanks(start_rank, end_rank) {
25
+ if (end_rank === undefined) {
26
+ return;
27
+ }
28
+ if (start_rank > 0 && end_rank > 0 && start_rank > end_rank) {
29
+ throw new errors_1.InvalidArgumentError('start rank must be less than end rank');
30
+ }
31
+ if (start_rank < 0 && end_rank < 0 && start_rank >= end_rank) {
32
+ throw new errors_1.InvalidArgumentError('negative start rank must be less than negative end rank');
33
+ }
34
+ }
35
+ exports.validateSortedSetRanks = validateSortedSetRanks;
36
+ function validateSortedSetScores(minScore, maxScore) {
37
+ if (minScore === undefined)
38
+ return;
39
+ if (maxScore === undefined)
40
+ return;
41
+ if (minScore > maxScore) {
42
+ throw new errors_1.InvalidArgumentError('minScore must be less than or equal to maxScore');
43
+ }
44
+ }
45
+ exports.validateSortedSetScores = validateSortedSetScores;
46
+ function validateSortedSetOffset(offset) {
47
+ if (offset < 0) {
48
+ throw new errors_1.InvalidArgumentError('offset must be non-negative (>= 0)');
49
+ }
50
+ }
51
+ exports.validateSortedSetOffset = validateSortedSetOffset;
52
+ function validateSortedSetCount(count) {
53
+ if (count < 1) {
54
+ throw new errors_1.InvalidArgumentError('count must be strictly positive (> 0)');
55
+ }
56
+ }
57
+ exports.validateSortedSetCount = validateSortedSetCount;
58
+ function validateDictionaryName(name) {
59
+ if (isEmpty(name)) {
60
+ throw new errors_1.InvalidArgumentError('dictionary name must not be empty');
61
+ }
62
+ }
63
+ exports.validateDictionaryName = validateDictionaryName;
64
+ function validateListName(name) {
65
+ if (isEmpty(name)) {
66
+ throw new errors_1.InvalidArgumentError('list name must not be empty');
67
+ }
68
+ }
69
+ exports.validateListName = validateListName;
70
+ function validateListSliceStartEnd(startIndex, endIndex) {
71
+ if (startIndex === undefined || endIndex === undefined)
72
+ return;
73
+ // can't validate bounds for start and index of either or are negative without list length
74
+ if (startIndex > 0 || endIndex < 0)
75
+ return;
76
+ if (endIndex <= startIndex) {
77
+ throw new errors_1.InvalidArgumentError('endIndex (exclusive) must be larger than startIndex (inclusive)');
78
+ }
79
+ }
80
+ exports.validateListSliceStartEnd = validateListSliceStartEnd;
81
+ function validateTopicName(name) {
82
+ if (isEmpty(name)) {
83
+ throw new errors_1.InvalidArgumentError('topic name must not be empty');
84
+ }
85
+ }
86
+ exports.validateTopicName = validateTopicName;
87
+ function validateTtlMinutes(ttlMinutes) {
88
+ if (ttlMinutes < 0) {
89
+ throw new errors_1.InvalidArgumentError('ttlMinutes must be positive');
90
+ }
91
+ }
92
+ exports.validateTtlMinutes = validateTtlMinutes;
93
+ function isEmpty(str) {
94
+ return !str.trim();
95
+ }
96
+ function isBase64(str) {
97
+ try {
98
+ return (0, string_1.encodeToBase64)((0, string_1.decodeFromBase64)(str)) === str;
99
+ }
100
+ catch (e) {
101
+ return false;
102
+ }
103
+ }
104
+ exports.isBase64 = isBase64;
105
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidmFsaWRhdG9ycy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uL3NyYy9pbnRlcm5hbC91dGlscy92YWxpZGF0b3JzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLGdEQUF5RDtBQUN6RCxxQ0FBMEQ7QUFFMUQsU0FBZ0IsaUJB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IGlmIChpc0VtcHR5KG5hbWUpKSB7XG4gICAgdGhyb3cgbmV3IEludmFsaWRBcmd1bWVudEVycm9yKCd0b3BpYyBuYW1lIG11c3Qgbm90IGJlIGVtcHR5Jyk7XG4gIH1cbn1cblxuZXhwb3J0IGZ1bmN0aW9uIHZhbGlkYXRlVHRsTWludXRlcyh0dGxNaW51dGVzOiBudW1iZXIpIHtcbiAgaWYgKHR0bE1pbnV0ZXMgPCAwKSB7XG4gICAgdGhyb3cgbmV3IEludmFsaWRBcmd1bWVudEVycm9yKCd0dGxNaW51dGVzIG11c3QgYmUgcG9zaXRpdmUnKTtcbiAgfVxufVxuXG5mdW5jdGlvbiBpc0VtcHR5KHN0cjogc3RyaW5nKTogYm9vbGVhbiB7XG4gIHJldHVybiAhc3RyLnRyaW0oKTtcbn1cblxuZXhwb3J0IGZ1bmN0aW9uIGlzQmFzZTY0KHN0cjogc3RyaW5nKTogYm9vbGVhbiB7XG4gIHRyeSB7XG4gICAgcmV0dXJuIGVuY29kZVRvQmFzZTY0KGRlY29kZUZyb21CYXNlNjQoc3RyKSkgPT09IHN0cjtcbiAgfSBjYXRjaCAoZSkge1xuICAgIHJldHVybiBmYWxzZTtcbiAgfVxufVxuIl19
@@ -0,0 +1,31 @@
1
+ The code in this directory is vendored from:
2
+
3
+ https://github.com/adaltas/node-printf/blob/5d11e642922fe1a125a141d4becfee00f29c67ce/lib/printf.js
4
+
5
+ We are vendoring it to avoid adding additional transitive dependencies to our library.
6
+
7
+ The original source code is licensed under the MIT license:
8
+
9
+ ```
10
+ The MIT License (MIT)
11
+
12
+ Copyright (c) 2008 Adaltas
13
+
14
+ Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ of this software and associated documentation files (the "Software"), to deal
16
+ in the Software without restriction, including without limitation the rights
17
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ copies of the Software, and to permit persons to whom the Software is
19
+ furnished to do so, subject to the following conditions:
20
+
21
+ The above copyright notice and this permission notice shall be included in all
22
+ copies or substantial portions of the Software.
23
+
24
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
+ SOFTWARE.
31
+ ```
@@ -0,0 +1,9 @@
1
+ // Type definitions for printf 0.2.5 and above
2
+ // Project: http://www.adaltas.com/projects/node-printf
3
+ // Definitions by: Aluísio Augusto Silva Gonçalves <https://github.com/AluisioASG>
4
+
5
+ /// <reference types="node" />
6
+
7
+ export = printf;
8
+ declare function printf(format: string, ...args: any[]): string;
9
+ declare function printf(writeStream: NodeJS.WritableStream, format: string, ...args: any[]): void;
@@ -0,0 +1,478 @@
1
+ /* eslint-disable */
2
+
3
+ var util = require('util');
4
+
5
+ var tokenize = function(/*String*/ str, /*RegExp*/ re, /*Function?*/ parseDelim, /*Object?*/ instance){
6
+ // summary:
7
+ // Split a string by a regular expression with the ability to capture the delimeters
8
+ // parseDelim:
9
+ // Each group (excluding the 0 group) is passed as a parameter. If the function returns
10
+ // a value, it's added to the list of tokens.
11
+ // instance:
12
+ // Used as the "this' instance when calling parseDelim
13
+ var tokens = [];
14
+ var match, content, lastIndex = 0;
15
+ while((match = re.exec(str))){
16
+ content = str.slice(lastIndex, re.lastIndex - match[0].length);
17
+ if(content.length){
18
+ tokens.push(content);
19
+ }
20
+ if(parseDelim){
21
+ var parsed = parseDelim.apply(instance, match.slice(1).concat(tokens.length));
22
+ if(typeof parsed != 'undefined'){
23
+ if(parsed.specifier === '%'){
24
+ tokens.push('%');
25
+ }else{
26
+ tokens.push(parsed);
27
+ }
28
+ }
29
+ }
30
+ lastIndex = re.lastIndex;
31
+ }
32
+ content = str.slice(lastIndex);
33
+ if(content.length){
34
+ tokens.push(content);
35
+ }
36
+ return tokens;
37
+ };
38
+
39
+ var Formatter = function(/*String*/ format){
40
+ this._mapped = false;
41
+ this._format = format;
42
+ this._tokens = tokenize(format, this._re, this._parseDelim, this);
43
+ };
44
+
45
+ // The old regexp `/\%(?:\(([\w_.]+)\)|([1-9]\d*)\$)?([0 +\-\#]*)(\*|\d+)?(\.)?(\*|\d+)?[hlL]?([\%bscdeEfFgGioOuxX])/` has a cubic worst-case time complexity behavior due to overlapping capture groups `([0 +\-\#]*)(\*|\d+)?(\.)?(\*|\d+)?`. And a pump string of 0 can be consumed by `([0 +\-\#]*), (\*|\d+)?, or (\*|\d+)?`.
46
+ // The solution replace the sub-regexp (\*|\d+)?(\.)?(\*|\d+)? with the sub-regexp `(\*|\d+)?(?:(\.)(\*|\d+)?)?`, see the figure in [#32](https://github.com/adaltas/node-printf/pull/32)
47
+ // There are also performance improvement, see in [#31](https://github.com/adaltas/node-printf/issues/31#issuecomment-776731490)
48
+ Formatter.prototype._re = /\%(?:\(([\w_.]+)\)|([1-9]\d*)\$)?([0 +\-\#]*)(\*|\d+)?(?:(\.)(\*|\d+)?)?[hlL]?([\%bscdeEfFgGioOuxX])/g;
49
+ Formatter.prototype._parseDelim = function(mapping, intmapping, flags, minWidth, period, precision, specifier){
50
+ if(mapping){
51
+ this._mapped = true;
52
+ }
53
+ return {
54
+ mapping: mapping,
55
+ intmapping: intmapping,
56
+ flags: flags,
57
+ _minWidth: minWidth, // May be dependent on parameters
58
+ period: period,
59
+ _precision: precision, // May be dependent on parameters
60
+ specifier: specifier
61
+ };
62
+ };
63
+ Formatter.prototype._specifiers = {
64
+ b: {
65
+ base: 2,
66
+ isInt: true
67
+ },
68
+ o: {
69
+ base: 8,
70
+ isInt: true
71
+ },
72
+ x: {
73
+ base: 16,
74
+ isInt: true
75
+ },
76
+ X: {
77
+ extend: ['x'],
78
+ toUpper: true
79
+ },
80
+ d: {
81
+ base: 10,
82
+ isInt: true
83
+ },
84
+ i: {
85
+ extend: ['d']
86
+ },
87
+ u: {
88
+ extend: ['d'],
89
+ isUnsigned: true
90
+ },
91
+ c: {
92
+ setArg: function(token){
93
+ if(!isNaN(token.arg)){
94
+ var num = parseInt(token.arg);
95
+ if(num < 0 || num > 127){
96
+ throw new Error('invalid character code passed to %c in printf');
97
+ }
98
+ token.arg = isNaN(num) ? '' + num : String.fromCharCode(num);
99
+ }
100
+ }
101
+ },
102
+ s: {
103
+ setMaxWidth: function(token){
104
+ token.maxWidth = (token.period == '.') ? token.precision : -1;
105
+ }
106
+ },
107
+ e: {
108
+ isDouble: true,
109
+ doubleNotation: 'e'
110
+ },
111
+ E: {
112
+ extend: ['e'],
113
+ toUpper: true
114
+ },
115
+ f: {
116
+ isDouble: true,
117
+ doubleNotation: 'f'
118
+ },
119
+ F: {
120
+ extend: ['f']
121
+ },
122
+ g: {
123
+ isDouble: true,
124
+ doubleNotation: 'g'
125
+ },
126
+ G: {
127
+ extend: ['g'],
128
+ toUpper: true
129
+ },
130
+ O: {
131
+ isObject: true
132
+ }
133
+ };
134
+ Formatter.prototype.format = function(/*mixed...*/ filler){
135
+ if(this._mapped && typeof filler != 'object'){
136
+ throw new Error('format requires a mapping');
137
+ }
138
+
139
+ var str = '';
140
+ var position = 0;
141
+ for(var i = 0, token; i < this._tokens.length; i++){
142
+ token = this._tokens[i];
143
+
144
+ if(typeof token == 'string'){
145
+ str += token;
146
+ }else{
147
+ if(this._mapped){
148
+ // Identify value of property defined in `token.mapping`
149
+ var tokens = token.mapping.split('.');
150
+ var value = filler;
151
+ for (var j = 0, c = tokens.length; j < c; j++) {
152
+ value = value[tokens[j]];
153
+ if (typeof value === 'undefined') {
154
+ break
155
+ }
156
+ }
157
+ if(typeof value == 'undefined'){
158
+ throw new Error('missing key \'' + token.mapping + '\'');
159
+ }
160
+ token.arg = value;
161
+ }else{
162
+ if(token.intmapping){
163
+ position = parseInt(token.intmapping) - 1;
164
+ }
165
+ if(position >= arguments.length){
166
+ throw new Error('got ' + arguments.length + ' printf arguments, insufficient for \'' + this._format + '\'');
167
+ }
168
+ token.arg = arguments[position++];
169
+ }
170
+
171
+ if(!token.compiled){
172
+ token.compiled = true;
173
+ token.sign = '';
174
+ token.zeroPad = false;
175
+ token.rightJustify = false;
176
+ token.alternative = false;
177
+
178
+ var flags = {};
179
+ for(var fi = token.flags.length; fi--;){
180
+ var flag = token.flags.charAt(fi);
181
+ flags[flag] = true;
182
+ switch(flag){
183
+ case ' ':
184
+ token.sign = ' ';
185
+ break;
186
+ case '+':
187
+ token.sign = '+';
188
+ break;
189
+ case '0':
190
+ token.zeroPad = (flags['-']) ? false : true;
191
+ break;
192
+ case '-':
193
+ token.rightJustify = true;
194
+ token.zeroPad = false;
195
+ break;
196
+ case '#':
197
+ token.alternative = true;
198
+ break;
199
+ default:
200
+ throw Error('bad formatting flag \'' + token.flags.charAt(fi) + '\'');
201
+ }
202
+ }
203
+
204
+ token.minWidth = (token._minWidth) ? parseInt(token._minWidth) : 0;
205
+ token.maxWidth = -1;
206
+ token.toUpper = false;
207
+ token.isUnsigned = false;
208
+ token.isInt = false;
209
+ token.isDouble = false;
210
+ token.isObject = false;
211
+ token.precision = 1;
212
+ if(token.period == '.'){
213
+ if(token._precision){
214
+ token.precision = parseInt(token._precision);
215
+ }else{
216
+ token.precision = 0;
217
+ }
218
+ }
219
+
220
+ var mixins = this._specifiers[token.specifier];
221
+ if(typeof mixins == 'undefined'){
222
+ throw new Error('unexpected specifier \'' + token.specifier + '\'');
223
+ }
224
+ if(mixins.extend){
225
+ var s = this._specifiers[mixins.extend];
226
+ for(var k in s){
227
+ mixins[k] = s[k];
228
+ }
229
+ delete mixins.extend;
230
+ }
231
+ for(var l in mixins){
232
+ token[l] = mixins[l];
233
+ }
234
+ }
235
+
236
+ if(typeof token.setArg == 'function'){
237
+ token.setArg(token);
238
+ }
239
+
240
+ if(typeof token.setMaxWidth == 'function'){
241
+ token.setMaxWidth(token);
242
+ }
243
+
244
+ if(token._minWidth == '*'){
245
+ if(this._mapped){
246
+ throw new Error('* width not supported in mapped formats');
247
+ }
248
+ token.minWidth = parseInt(arguments[position++]);
249
+ if(isNaN(token.minWidth)){
250
+ throw new Error('the argument for * width at position ' + position + ' is not a number in ' + this._format);
251
+ }
252
+ // negative width means rightJustify
253
+ if (token.minWidth < 0) {
254
+ token.rightJustify = true;
255
+ token.minWidth = -token.minWidth;
256
+ }
257
+ }
258
+
259
+ if(token._precision == '*' && token.period == '.'){
260
+ if(this._mapped){
261
+ throw new Error('* precision not supported in mapped formats');
262
+ }
263
+ token.precision = parseInt(arguments[position++]);
264
+ if(isNaN(token.precision)){
265
+ throw Error('the argument for * precision at position ' + position + ' is not a number in ' + this._format);
266
+ }
267
+ // negative precision means unspecified
268
+ if (token.precision < 0) {
269
+ token.precision = 1;
270
+ token.period = '';
271
+ }
272
+ }
273
+ if(token.isInt){
274
+ // a specified precision means no zero padding
275
+ if(token.period == '.'){
276
+ token.zeroPad = false;
277
+ }
278
+ this.formatInt(token);
279
+ }else if(token.isDouble){
280
+ if(token.period != '.'){
281
+ token.precision = 6;
282
+ }
283
+ this.formatDouble(token);
284
+ }else if(token.isObject){
285
+ this.formatObject(token);
286
+ }
287
+ this.fitField(token);
288
+ str += '' + token.arg;
289
+ }
290
+ }
291
+
292
+ return str;
293
+ };
294
+ Formatter.prototype._zeros10 = '0000000000';
295
+ Formatter.prototype._spaces10 = ' ';
296
+ Formatter.prototype.formatInt = function(token) {
297
+ var i = parseInt(token.arg);
298
+ if(!isFinite(i)){ // isNaN(f) || f == Number.POSITIVE_INFINITY || f == Number.NEGATIVE_INFINITY)
299
+ // allow this only if arg is number
300
+ if(typeof token.arg != 'number'){
301
+ throw new Error('format argument \'' + token.arg + '\' not an integer; parseInt returned ' + i);
302
+ }
303
+ //return '' + i;
304
+ i = 0;
305
+ }
306
+
307
+ // if not base 10, make negatives be positive
308
+ // otherwise, (-10).toString(16) is '-a' instead of 'fffffff6'
309
+ if(i < 0 && (token.isUnsigned || token.base != 10)){
310
+ i = 0xffffffff + i + 1;
311
+ }
312
+
313
+ if(i < 0){
314
+ token.arg = (- i).toString(token.base);
315
+ this.zeroPad(token);
316
+ token.arg = '-' + token.arg;
317
+ }else{
318
+ token.arg = i.toString(token.base);
319
+ // need to make sure that argument 0 with precision==0 is formatted as ''
320
+ if(!i && !token.precision){
321
+ token.arg = '';
322
+ }else{
323
+ this.zeroPad(token);
324
+ }
325
+ if(token.sign){
326
+ token.arg = token.sign + token.arg;
327
+ }
328
+ }
329
+ if(token.base == 16){
330
+ if(token.alternative){
331
+ token.arg = '0x' + token.arg;
332
+ }
333
+ token.arg = token.toUpper ? token.arg.toUpperCase() : token.arg.toLowerCase();
334
+ }
335
+ if(token.base == 8){
336
+ if(token.alternative && token.arg.charAt(0) != '0'){
337
+ token.arg = '0' + token.arg;
338
+ }
339
+ }
340
+ };
341
+ Formatter.prototype.formatDouble = function(token) {
342
+ var f = parseFloat(token.arg);
343
+ if(!isFinite(f)){ // isNaN(f) || f == Number.POSITIVE_INFINITY || f == Number.NEGATIVE_INFINITY)
344
+ // allow this only if arg is number
345
+ if(typeof token.arg != 'number'){
346
+ throw new Error('format argument \'' + token.arg + '\' not a float; parseFloat returned ' + f);
347
+ }
348
+ // C99 says that for 'f':
349
+ // infinity -> '[-]inf' or '[-]infinity' ('[-]INF' or '[-]INFINITY' for 'F')
350
+ // NaN -> a string starting with 'nan' ('NAN' for 'F')
351
+ // this is not commonly implemented though.
352
+ //return '' + f;
353
+ f = 0;
354
+ }
355
+
356
+ switch(token.doubleNotation) {
357
+ case 'e': {
358
+ token.arg = f.toExponential(token.precision);
359
+ break;
360
+ }
361
+ case 'f': {
362
+ token.arg = f.toFixed(token.precision);
363
+ break;
364
+ }
365
+ case 'g': {
366
+ // C says use 'e' notation if exponent is < -4 or is >= prec
367
+ // ECMAScript for toPrecision says use exponential notation if exponent is >= prec,
368
+ // though step 17 of toPrecision indicates a test for < -6 to force exponential.
369
+ if(Math.abs(f) < 0.0001){
370
+ //print('forcing exponential notation for f=' + f);
371
+ token.arg = f.toExponential(token.precision > 0 ? token.precision - 1 : token.precision);
372
+ }else{
373
+ token.arg = f.toPrecision(token.precision);
374
+ }
375
+
376
+ // In C, unlike 'f', 'gG' removes trailing 0s from fractional part, unless alternative format flag ('#').
377
+ // But ECMAScript formats toPrecision as 0.00100000. So remove trailing 0s.
378
+ if(!token.alternative){
379
+ //print('replacing trailing 0 in \'' + s + '\'');
380
+ token.arg = token.arg.replace(/(\..*[^0])0*e/, '$1e');
381
+ // if fractional part is entirely 0, remove it and decimal point
382
+ token.arg = token.arg.replace(/\.0*e/, 'e').replace(/\.0$/,'');
383
+ }
384
+ break;
385
+ }
386
+ default: throw new Error('unexpected double notation \'' + token.doubleNotation + '\'');
387
+ }
388
+
389
+ // C says that exponent must have at least two digits.
390
+ // But ECMAScript does not; toExponential results in things like '1.000000e-8' and '1.000000e+8'.
391
+ // Note that s.replace(/e([\+\-])(\d)/, 'e$10$2') won't work because of the '$10' instead of '$1'.
392
+ // And replace(re, func) isn't supported on IE50 or Safari1.
393
+ token.arg = token.arg.replace(/e\+(\d)$/, 'e+0$1').replace(/e\-(\d)$/, 'e-0$1');
394
+
395
+ // if alt, ensure a decimal point
396
+ if(token.alternative){
397
+ token.arg = token.arg.replace(/^(\d+)$/,'$1.');
398
+ token.arg = token.arg.replace(/^(\d+)e/,'$1.e');
399
+ }
400
+
401
+ if(f >= 0 && token.sign){
402
+ token.arg = token.sign + token.arg;
403
+ }
404
+
405
+ token.arg = token.toUpper ? token.arg.toUpperCase() : token.arg.toLowerCase();
406
+ };
407
+ Formatter.prototype.formatObject = function(token) {
408
+ // If no precision is specified, then reset it to null (infinite depth).
409
+ var precision = (token.period === '.') ? token.precision : null;
410
+ // Historically, inspect was called with 3 options
411
+ // token.arg = util.inspect(token.arg, !token.alternative, precision, token.sign);
412
+ // Now using an object but not sure colors make any sense here
413
+ token.arg = util.inspect(token.arg, {
414
+ showHidden: !token.alternative,
415
+ depth: precision,
416
+ colors: token.sign,
417
+ compact: true
418
+ });
419
+ };
420
+ Formatter.prototype.zeroPad = function(token, /*Int*/ length) {
421
+ length = (arguments.length == 2) ? length : token.precision;
422
+ var negative = false;
423
+ if(typeof token.arg != "string"){
424
+ token.arg = "" + token.arg;
425
+ }
426
+ if (token.arg.substr(0,1) === '-') {
427
+ negative = true;
428
+ token.arg = token.arg.substr(1);
429
+ }
430
+
431
+ var tenless = length - 10;
432
+ while(token.arg.length < tenless){
433
+ token.arg = (token.rightJustify) ? token.arg + this._zeros10 : this._zeros10 + token.arg;
434
+ }
435
+ var pad = length - token.arg.length;
436
+ token.arg = (token.rightJustify) ? token.arg + this._zeros10.substring(0, pad) : this._zeros10.substring(0, pad) + token.arg;
437
+ if (negative) token.arg = '-' + token.arg;
438
+ };
439
+ Formatter.prototype.fitField = function(token) {
440
+ if(token.maxWidth >= 0 && token.arg.length > token.maxWidth){
441
+ token.arg = token.arg.substring(0, token.maxWidth);
442
+ }
443
+ if(token.zeroPad){
444
+ this.zeroPad(token, token.minWidth);
445
+ return;
446
+ }
447
+ this.spacePad(token);
448
+ };
449
+ Formatter.prototype.spacePad = function(token, /*Int*/ length) {
450
+ length = (arguments.length == 2) ? length : token.minWidth;
451
+ if(typeof token.arg != 'string'){
452
+ token.arg = '' + token.arg;
453
+ }
454
+ var tenless = length - 10;
455
+ while(token.arg.length < tenless){
456
+ token.arg = (token.rightJustify) ? token.arg + this._spaces10 : this._spaces10 + token.arg;
457
+ }
458
+ var pad = length - token.arg.length;
459
+ token.arg = (token.rightJustify) ? token.arg + this._spaces10.substring(0, pad) : this._spaces10.substring(0, pad) + token.arg;
460
+ };
461
+
462
+ module.exports = function(){
463
+ var args = Array.prototype.slice.call(arguments),
464
+ stream, format;
465
+ if(args[0] instanceof require('stream').Stream){
466
+ stream = args.shift();
467
+ }
468
+ format = args.shift();
469
+ var formatter = new Formatter(format);
470
+ var string = formatter.format.apply(formatter, args);
471
+ if(stream){
472
+ stream.write(string);
473
+ }else{
474
+ return string;
475
+ }
476
+ };
477
+
478
+ module.exports.Formatter = Formatter;
@@ -0,0 +1,5 @@
1
+ export declare class CacheInfo {
2
+ private readonly name;
3
+ constructor(name: string);
4
+ getName(): string;
5
+ }
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CacheInfo = void 0;
4
+ class CacheInfo {
5
+ constructor(name) {
6
+ this.name = name;
7
+ }
8
+ getName() {
9
+ return this.name;
10
+ }
11
+ }
12
+ exports.CacheInfo = CacheInfo;
13
+ //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2FjaGUtaW5mby5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9tZXNzYWdlcy9jYWNoZS1pbmZvLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLE1BQWEsU0FBUztJQUdwQixZQUFZLElBQVk7UUFDdEIsSUFBSSxDQUFDLElBQUksR0FBRyxJQUFJLENBQUM7SUFDbkIsQ0FBQztJQUVNLE9BQU87UUFDWixPQUFPLElBQUksQ0FBQyxJQUFJLENBQUM7SUFDbkIsQ0FBQztDQUNGO0FBVkQsOEJBVUMiLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgY2xhc3MgQ2FjaGVJbmZvIHtcbiAgcHJpdmF0ZSByZWFkb25seSBuYW1lOiBzdHJpbmc7XG5cbiAgY29uc3RydWN0b3IobmFtZTogc3RyaW5nKSB7XG4gICAgdGhpcy5uYW1lID0gbmFtZTtcbiAgfVxuXG4gIHB1YmxpYyBnZXROYW1lKCkge1xuICAgIHJldHVybiB0aGlzLm5hbWU7XG4gIH1cbn1cbiJdfQ==