@donmahallem/lerna2codecov 0.2.2 → 0.2.3

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 (236) hide show
  1. package/dist/cjs/_virtual/git-host-info.cjs +8 -0
  2. package/dist/cjs/_virtual/git-host-info.cjs.map +1 -0
  3. package/dist/cjs/_virtual/index3.cjs +2 -2
  4. package/dist/cjs/_virtual/index4.cjs +2 -2
  5. package/dist/cjs/node_modules/@lerna/package/index.cjs +3 -4
  6. package/dist/cjs/node_modules/@lerna/package/index.cjs.map +1 -1
  7. package/dist/cjs/node_modules/hosted-git-info/git-host-info.cjs +89 -183
  8. package/dist/cjs/node_modules/hosted-git-info/git-host-info.cjs.map +1 -1
  9. package/dist/cjs/node_modules/hosted-git-info/git-host.cjs +165 -109
  10. package/dist/cjs/node_modules/hosted-git-info/git-host.cjs.map +1 -1
  11. package/dist/cjs/node_modules/hosted-git-info/index.cjs +157 -238
  12. package/dist/cjs/node_modules/hosted-git-info/index.cjs.map +1 -1
  13. package/dist/cjs/node_modules/load-json-file/index.cjs +7 -7
  14. package/dist/cjs/node_modules/lru-cache/index.cjs +343 -332
  15. package/dist/cjs/node_modules/lru-cache/index.cjs.map +1 -1
  16. package/dist/cjs/node_modules/npm-package-arg/npa.cjs +95 -141
  17. package/dist/cjs/node_modules/npm-package-arg/npa.cjs.map +1 -1
  18. package/dist/cjs/node_modules/semver/classes/comparator.cjs +6 -7
  19. package/dist/cjs/node_modules/semver/classes/comparator.cjs.map +1 -1
  20. package/dist/cjs/node_modules/semver/classes/range.cjs +6 -7
  21. package/dist/cjs/node_modules/semver/classes/range.cjs.map +1 -1
  22. package/dist/cjs/node_modules/semver/classes/semver.cjs +301 -292
  23. package/dist/cjs/node_modules/semver/classes/semver.cjs.map +1 -1
  24. package/dist/cjs/node_modules/semver/functions/clean.cjs +18 -8
  25. package/dist/cjs/node_modules/semver/functions/clean.cjs.map +1 -1
  26. package/dist/cjs/node_modules/semver/functions/cmp.cjs +60 -50
  27. package/dist/cjs/node_modules/semver/functions/cmp.cjs.map +1 -1
  28. package/dist/cjs/node_modules/semver/functions/coerce.cjs +67 -58
  29. package/dist/cjs/node_modules/semver/functions/coerce.cjs.map +1 -1
  30. package/dist/cjs/node_modules/semver/functions/compare-build.cjs +18 -8
  31. package/dist/cjs/node_modules/semver/functions/compare-build.cjs.map +1 -1
  32. package/dist/cjs/node_modules/semver/functions/compare-loose.cjs +15 -5
  33. package/dist/cjs/node_modules/semver/functions/compare-loose.cjs.map +1 -1
  34. package/dist/cjs/node_modules/semver/functions/compare.cjs +15 -5
  35. package/dist/cjs/node_modules/semver/functions/compare.cjs.map +1 -1
  36. package/dist/cjs/node_modules/semver/functions/diff.cjs +35 -25
  37. package/dist/cjs/node_modules/semver/functions/diff.cjs.map +1 -1
  38. package/dist/cjs/node_modules/semver/functions/eq.cjs +15 -5
  39. package/dist/cjs/node_modules/semver/functions/eq.cjs.map +1 -1
  40. package/dist/cjs/node_modules/semver/functions/gt.cjs +15 -5
  41. package/dist/cjs/node_modules/semver/functions/gt.cjs.map +1 -1
  42. package/dist/cjs/node_modules/semver/functions/gte.cjs +15 -5
  43. package/dist/cjs/node_modules/semver/functions/gte.cjs.map +1 -1
  44. package/dist/cjs/node_modules/semver/functions/inc.cjs +27 -17
  45. package/dist/cjs/node_modules/semver/functions/inc.cjs.map +1 -1
  46. package/dist/cjs/node_modules/semver/functions/lt.cjs +15 -5
  47. package/dist/cjs/node_modules/semver/functions/lt.cjs.map +1 -1
  48. package/dist/cjs/node_modules/semver/functions/lte.cjs +15 -5
  49. package/dist/cjs/node_modules/semver/functions/lte.cjs.map +1 -1
  50. package/dist/cjs/node_modules/semver/functions/major.cjs +14 -4
  51. package/dist/cjs/node_modules/semver/functions/major.cjs.map +1 -1
  52. package/dist/cjs/node_modules/semver/functions/minor.cjs +14 -4
  53. package/dist/cjs/node_modules/semver/functions/minor.cjs.map +1 -1
  54. package/dist/cjs/node_modules/semver/functions/neq.cjs +15 -5
  55. package/dist/cjs/node_modules/semver/functions/neq.cjs.map +1 -1
  56. package/dist/cjs/node_modules/semver/functions/parse.cjs +48 -39
  57. package/dist/cjs/node_modules/semver/functions/parse.cjs.map +1 -1
  58. package/dist/cjs/node_modules/semver/functions/patch.cjs +14 -4
  59. package/dist/cjs/node_modules/semver/functions/patch.cjs.map +1 -1
  60. package/dist/cjs/node_modules/semver/functions/prerelease.cjs +18 -8
  61. package/dist/cjs/node_modules/semver/functions/prerelease.cjs.map +1 -1
  62. package/dist/cjs/node_modules/semver/functions/rcompare.cjs +15 -5
  63. package/dist/cjs/node_modules/semver/functions/rcompare.cjs.map +1 -1
  64. package/dist/cjs/node_modules/semver/functions/rsort.cjs +15 -5
  65. package/dist/cjs/node_modules/semver/functions/rsort.cjs.map +1 -1
  66. package/dist/cjs/node_modules/semver/functions/satisfies.cjs +21 -11
  67. package/dist/cjs/node_modules/semver/functions/satisfies.cjs.map +1 -1
  68. package/dist/cjs/node_modules/semver/functions/sort.cjs +15 -5
  69. package/dist/cjs/node_modules/semver/functions/sort.cjs.map +1 -1
  70. package/dist/cjs/node_modules/semver/functions/valid.cjs +18 -8
  71. package/dist/cjs/node_modules/semver/functions/valid.cjs.map +1 -1
  72. package/dist/cjs/node_modules/semver/index.cjs +60 -51
  73. package/dist/cjs/node_modules/semver/index.cjs.map +1 -1
  74. package/dist/cjs/node_modules/semver/internal/constants.cjs +25 -15
  75. package/dist/cjs/node_modules/semver/internal/constants.cjs.map +1 -1
  76. package/dist/cjs/node_modules/semver/internal/debug.cjs +19 -9
  77. package/dist/cjs/node_modules/semver/internal/debug.cjs.map +1 -1
  78. package/dist/cjs/node_modules/semver/internal/identifiers.cjs +35 -25
  79. package/dist/cjs/node_modules/semver/internal/identifiers.cjs.map +1 -1
  80. package/dist/cjs/node_modules/semver/internal/parse-options.cjs +22 -12
  81. package/dist/cjs/node_modules/semver/internal/parse-options.cjs.map +1 -1
  82. package/dist/cjs/node_modules/semver/internal/re.cjs +172 -161
  83. package/dist/cjs/node_modules/semver/internal/re.cjs.map +1 -1
  84. package/dist/cjs/node_modules/semver/ranges/gtr.cjs +16 -6
  85. package/dist/cjs/node_modules/semver/ranges/gtr.cjs.map +1 -1
  86. package/dist/cjs/node_modules/semver/ranges/intersects.cjs +18 -8
  87. package/dist/cjs/node_modules/semver/ranges/intersects.cjs.map +1 -1
  88. package/dist/cjs/node_modules/semver/ranges/ltr.cjs +16 -6
  89. package/dist/cjs/node_modules/semver/ranges/ltr.cjs.map +1 -1
  90. package/dist/cjs/node_modules/semver/ranges/max-satisfying.cjs +35 -25
  91. package/dist/cjs/node_modules/semver/ranges/max-satisfying.cjs.map +1 -1
  92. package/dist/cjs/node_modules/semver/ranges/min-satisfying.cjs +35 -25
  93. package/dist/cjs/node_modules/semver/ranges/min-satisfying.cjs.map +1 -1
  94. package/dist/cjs/node_modules/semver/ranges/min-version.cjs +66 -56
  95. package/dist/cjs/node_modules/semver/ranges/min-version.cjs.map +1 -1
  96. package/dist/cjs/node_modules/semver/ranges/outside.cjs +86 -76
  97. package/dist/cjs/node_modules/semver/ranges/outside.cjs.map +1 -1
  98. package/dist/cjs/node_modules/semver/ranges/simplify.cjs +59 -49
  99. package/dist/cjs/node_modules/semver/ranges/simplify.cjs.map +1 -1
  100. package/dist/cjs/node_modules/semver/ranges/subset.cjs +259 -249
  101. package/dist/cjs/node_modules/semver/ranges/subset.cjs.map +1 -1
  102. package/dist/cjs/node_modules/semver/ranges/to-comparators.cjs +17 -7
  103. package/dist/cjs/node_modules/semver/ranges/to-comparators.cjs.map +1 -1
  104. package/dist/cjs/node_modules/semver/ranges/valid.cjs +22 -12
  105. package/dist/cjs/node_modules/semver/ranges/valid.cjs.map +1 -1
  106. package/dist/cjs/node_modules/supports-color/index.cjs +3 -3
  107. package/dist/cjs/node_modules/validate-npm-package-name/index.cjs +118 -108
  108. package/dist/cjs/node_modules/validate-npm-package-name/index.cjs.map +1 -1
  109. package/dist/cjs/node_modules/write-pkg/index.cjs +3 -3
  110. package/dist/cjs/node_modules/write-pkg/node_modules/make-dir/index.cjs +3 -3
  111. package/dist/cjs/node_modules/write-pkg/node_modules/make-dir/index.cjs.map +1 -1
  112. package/dist/cjs/node_modules/write-pkg/node_modules/write-file-atomic/index.cjs +3 -3
  113. package/dist/cjs/node_modules/write-pkg/node_modules/write-json-file/index.cjs +3 -3
  114. package/dist/cjs/node_modules/yallist/yallist.cjs +435 -425
  115. package/dist/cjs/node_modules/yallist/yallist.cjs.map +1 -1
  116. package/dist/cjs/update-config.cjs +2 -2
  117. package/dist/esm/_virtual/git-host-info.mjs +4 -0
  118. package/dist/esm/_virtual/git-host-info.mjs.map +1 -0
  119. package/dist/esm/_virtual/index3.mjs +2 -2
  120. package/dist/esm/_virtual/index4.mjs +2 -2
  121. package/dist/esm/node_modules/@lerna/package/index.mjs +2 -3
  122. package/dist/esm/node_modules/@lerna/package/index.mjs.map +1 -1
  123. package/dist/esm/node_modules/hosted-git-info/git-host-info.mjs +87 -183
  124. package/dist/esm/node_modules/hosted-git-info/git-host-info.mjs.map +1 -1
  125. package/dist/esm/node_modules/hosted-git-info/git-host.mjs +165 -111
  126. package/dist/esm/node_modules/hosted-git-info/git-host.mjs.map +1 -1
  127. package/dist/esm/node_modules/hosted-git-info/index.mjs +159 -242
  128. package/dist/esm/node_modules/hosted-git-info/index.mjs.map +1 -1
  129. package/dist/esm/node_modules/load-json-file/index.mjs +2 -2
  130. package/dist/esm/node_modules/load-json-file/index.mjs.map +1 -1
  131. package/dist/esm/node_modules/lru-cache/index.mjs +343 -334
  132. package/dist/esm/node_modules/lru-cache/index.mjs.map +1 -1
  133. package/dist/esm/node_modules/npm-package-arg/npa.mjs +93 -139
  134. package/dist/esm/node_modules/npm-package-arg/npa.mjs.map +1 -1
  135. package/dist/esm/node_modules/semver/classes/comparator.mjs +11 -12
  136. package/dist/esm/node_modules/semver/classes/comparator.mjs.map +1 -1
  137. package/dist/esm/node_modules/semver/classes/range.mjs +21 -22
  138. package/dist/esm/node_modules/semver/classes/range.mjs.map +1 -1
  139. package/dist/esm/node_modules/semver/classes/semver.mjs +301 -294
  140. package/dist/esm/node_modules/semver/classes/semver.mjs.map +1 -1
  141. package/dist/esm/node_modules/semver/functions/clean.mjs +16 -8
  142. package/dist/esm/node_modules/semver/functions/clean.mjs.map +1 -1
  143. package/dist/esm/node_modules/semver/functions/cmp.mjs +69 -61
  144. package/dist/esm/node_modules/semver/functions/cmp.mjs.map +1 -1
  145. package/dist/esm/node_modules/semver/functions/coerce.mjs +66 -59
  146. package/dist/esm/node_modules/semver/functions/coerce.mjs.map +1 -1
  147. package/dist/esm/node_modules/semver/functions/compare-build.mjs +17 -9
  148. package/dist/esm/node_modules/semver/functions/compare-build.mjs.map +1 -1
  149. package/dist/esm/node_modules/semver/functions/compare-loose.mjs +13 -5
  150. package/dist/esm/node_modules/semver/functions/compare-loose.mjs.map +1 -1
  151. package/dist/esm/node_modules/semver/functions/compare.mjs +14 -6
  152. package/dist/esm/node_modules/semver/functions/compare.mjs.map +1 -1
  153. package/dist/esm/node_modules/semver/functions/diff.mjs +33 -25
  154. package/dist/esm/node_modules/semver/functions/diff.mjs.map +1 -1
  155. package/dist/esm/node_modules/semver/functions/eq.mjs +13 -5
  156. package/dist/esm/node_modules/semver/functions/eq.mjs.map +1 -1
  157. package/dist/esm/node_modules/semver/functions/gt.mjs +13 -5
  158. package/dist/esm/node_modules/semver/functions/gt.mjs.map +1 -1
  159. package/dist/esm/node_modules/semver/functions/gte.mjs +13 -5
  160. package/dist/esm/node_modules/semver/functions/gte.mjs.map +1 -1
  161. package/dist/esm/node_modules/semver/functions/inc.mjs +26 -18
  162. package/dist/esm/node_modules/semver/functions/inc.mjs.map +1 -1
  163. package/dist/esm/node_modules/semver/functions/lt.mjs +13 -5
  164. package/dist/esm/node_modules/semver/functions/lt.mjs.map +1 -1
  165. package/dist/esm/node_modules/semver/functions/lte.mjs +13 -5
  166. package/dist/esm/node_modules/semver/functions/lte.mjs.map +1 -1
  167. package/dist/esm/node_modules/semver/functions/major.mjs +13 -5
  168. package/dist/esm/node_modules/semver/functions/major.mjs.map +1 -1
  169. package/dist/esm/node_modules/semver/functions/minor.mjs +13 -5
  170. package/dist/esm/node_modules/semver/functions/minor.mjs.map +1 -1
  171. package/dist/esm/node_modules/semver/functions/neq.mjs +13 -5
  172. package/dist/esm/node_modules/semver/functions/neq.mjs.map +1 -1
  173. package/dist/esm/node_modules/semver/functions/parse.mjs +48 -41
  174. package/dist/esm/node_modules/semver/functions/parse.mjs.map +1 -1
  175. package/dist/esm/node_modules/semver/functions/patch.mjs +13 -5
  176. package/dist/esm/node_modules/semver/functions/patch.mjs.map +1 -1
  177. package/dist/esm/node_modules/semver/functions/prerelease.mjs +16 -8
  178. package/dist/esm/node_modules/semver/functions/prerelease.mjs.map +1 -1
  179. package/dist/esm/node_modules/semver/functions/rcompare.mjs +13 -5
  180. package/dist/esm/node_modules/semver/functions/rcompare.mjs.map +1 -1
  181. package/dist/esm/node_modules/semver/functions/rsort.mjs +13 -5
  182. package/dist/esm/node_modules/semver/functions/rsort.mjs.map +1 -1
  183. package/dist/esm/node_modules/semver/functions/satisfies.mjs +19 -11
  184. package/dist/esm/node_modules/semver/functions/satisfies.mjs.map +1 -1
  185. package/dist/esm/node_modules/semver/functions/sort.mjs +13 -5
  186. package/dist/esm/node_modules/semver/functions/sort.mjs.map +1 -1
  187. package/dist/esm/node_modules/semver/functions/valid.mjs +16 -8
  188. package/dist/esm/node_modules/semver/functions/valid.mjs.map +1 -1
  189. package/dist/esm/node_modules/semver/index.mjs +96 -89
  190. package/dist/esm/node_modules/semver/index.mjs.map +1 -1
  191. package/dist/esm/node_modules/semver/internal/constants.mjs +23 -15
  192. package/dist/esm/node_modules/semver/internal/constants.mjs.map +1 -1
  193. package/dist/esm/node_modules/semver/internal/debug.mjs +17 -9
  194. package/dist/esm/node_modules/semver/internal/debug.mjs.map +1 -1
  195. package/dist/esm/node_modules/semver/internal/identifiers.mjs +28 -20
  196. package/dist/esm/node_modules/semver/internal/identifiers.mjs.map +1 -1
  197. package/dist/esm/node_modules/semver/internal/parse-options.mjs +20 -12
  198. package/dist/esm/node_modules/semver/internal/parse-options.mjs.map +1 -1
  199. package/dist/esm/node_modules/semver/internal/re.mjs +175 -166
  200. package/dist/esm/node_modules/semver/internal/re.mjs.map +1 -1
  201. package/dist/esm/node_modules/semver/ranges/gtr.mjs +14 -6
  202. package/dist/esm/node_modules/semver/ranges/gtr.mjs.map +1 -1
  203. package/dist/esm/node_modules/semver/ranges/intersects.mjs +16 -8
  204. package/dist/esm/node_modules/semver/ranges/intersects.mjs.map +1 -1
  205. package/dist/esm/node_modules/semver/ranges/ltr.mjs +14 -6
  206. package/dist/esm/node_modules/semver/ranges/ltr.mjs.map +1 -1
  207. package/dist/esm/node_modules/semver/ranges/max-satisfying.mjs +34 -26
  208. package/dist/esm/node_modules/semver/ranges/max-satisfying.mjs.map +1 -1
  209. package/dist/esm/node_modules/semver/ranges/min-satisfying.mjs +34 -26
  210. package/dist/esm/node_modules/semver/ranges/min-satisfying.mjs.map +1 -1
  211. package/dist/esm/node_modules/semver/ranges/min-version.mjs +65 -57
  212. package/dist/esm/node_modules/semver/ranges/min-version.mjs.map +1 -1
  213. package/dist/esm/node_modules/semver/ranges/outside.mjs +85 -77
  214. package/dist/esm/node_modules/semver/ranges/outside.mjs.map +1 -1
  215. package/dist/esm/node_modules/semver/ranges/simplify.mjs +57 -49
  216. package/dist/esm/node_modules/semver/ranges/simplify.mjs.map +1 -1
  217. package/dist/esm/node_modules/semver/ranges/subset.mjs +257 -249
  218. package/dist/esm/node_modules/semver/ranges/subset.mjs.map +1 -1
  219. package/dist/esm/node_modules/semver/ranges/to-comparators.mjs +15 -7
  220. package/dist/esm/node_modules/semver/ranges/to-comparators.mjs.map +1 -1
  221. package/dist/esm/node_modules/semver/ranges/valid.mjs +20 -12
  222. package/dist/esm/node_modules/semver/ranges/valid.mjs.map +1 -1
  223. package/dist/esm/node_modules/supports-color/index.mjs +2 -2
  224. package/dist/esm/node_modules/validate-npm-package-name/index.mjs +114 -107
  225. package/dist/esm/node_modules/validate-npm-package-name/index.mjs.map +1 -1
  226. package/dist/esm/node_modules/write-pkg/index.mjs +2 -2
  227. package/dist/esm/node_modules/write-pkg/index.mjs.map +1 -1
  228. package/dist/esm/node_modules/write-pkg/node_modules/make-dir/index.mjs +2 -2
  229. package/dist/esm/node_modules/write-pkg/node_modules/make-dir/index.mjs.map +1 -1
  230. package/dist/esm/node_modules/write-pkg/node_modules/write-file-atomic/index.mjs +2 -2
  231. package/dist/esm/node_modules/write-pkg/node_modules/write-file-atomic/index.mjs.map +1 -1
  232. package/dist/esm/node_modules/write-pkg/node_modules/write-json-file/index.mjs +2 -2
  233. package/dist/esm/node_modules/write-pkg/node_modules/write-json-file/index.mjs.map +1 -1
  234. package/dist/esm/node_modules/yallist/yallist.mjs +433 -425
  235. package/dist/esm/node_modules/yallist/yallist.mjs.map +1 -1
  236. package/package.json +4 -4
@@ -1,337 +1,346 @@
1
- import yallist from '../yallist/yallist.mjs';
2
-
3
- // A linked list to keep track of recently-used-ness
4
- const Yallist = yallist;
5
-
6
- const MAX = Symbol('max');
7
- const LENGTH = Symbol('length');
8
- const LENGTH_CALCULATOR = Symbol('lengthCalculator');
9
- const ALLOW_STALE = Symbol('allowStale');
10
- const MAX_AGE = Symbol('maxAge');
11
- const DISPOSE = Symbol('dispose');
12
- const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet');
13
- const LRU_LIST = Symbol('lruList');
14
- const CACHE = Symbol('cache');
15
- const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet');
16
-
17
- const naiveLength = () => 1;
18
-
19
- // lruList is a yallist where the head is the youngest
20
- // item, and the tail is the oldest. the list contains the Hit
21
- // objects as the entries.
22
- // Each Hit object has a reference to its Yallist.Node. This
23
- // never changes.
24
- //
25
- // cache is a Map (or PseudoMap) that matches the keys to
26
- // the Yallist.Node object.
27
- class LRUCache {
28
- constructor (options) {
29
- if (typeof options === 'number')
30
- options = { max: options };
31
-
32
- if (!options)
33
- options = {};
34
-
35
- if (options.max && (typeof options.max !== 'number' || options.max < 0))
36
- throw new TypeError('max must be a non-negative number')
37
- // Kind of weird to have a default max of Infinity, but oh well.
38
- this[MAX] = options.max || Infinity;
39
-
40
- const lc = options.length || naiveLength;
41
- this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc;
42
- this[ALLOW_STALE] = options.stale || false;
43
- if (options.maxAge && typeof options.maxAge !== 'number')
44
- throw new TypeError('maxAge must be a number')
45
- this[MAX_AGE] = options.maxAge || 0;
46
- this[DISPOSE] = options.dispose;
47
- this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false;
48
- this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false;
49
- this.reset();
50
- }
51
-
52
- // resize the cache when the max changes.
53
- set max (mL) {
54
- if (typeof mL !== 'number' || mL < 0)
55
- throw new TypeError('max must be a non-negative number')
56
-
57
- this[MAX] = mL || Infinity;
58
- trim(this);
59
- }
60
- get max () {
61
- return this[MAX]
62
- }
63
-
64
- set allowStale (allowStale) {
65
- this[ALLOW_STALE] = !!allowStale;
66
- }
67
- get allowStale () {
68
- return this[ALLOW_STALE]
69
- }
70
-
71
- set maxAge (mA) {
72
- if (typeof mA !== 'number')
73
- throw new TypeError('maxAge must be a non-negative number')
74
-
75
- this[MAX_AGE] = mA;
76
- trim(this);
77
- }
78
- get maxAge () {
79
- return this[MAX_AGE]
80
- }
81
-
82
- // resize the cache when the lengthCalculator changes.
83
- set lengthCalculator (lC) {
84
- if (typeof lC !== 'function')
85
- lC = naiveLength;
86
-
87
- if (lC !== this[LENGTH_CALCULATOR]) {
88
- this[LENGTH_CALCULATOR] = lC;
89
- this[LENGTH] = 0;
90
- this[LRU_LIST].forEach(hit => {
91
- hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key);
92
- this[LENGTH] += hit.length;
93
- });
94
- }
95
- trim(this);
96
- }
97
- get lengthCalculator () { return this[LENGTH_CALCULATOR] }
98
-
99
- get length () { return this[LENGTH] }
100
- get itemCount () { return this[LRU_LIST].length }
101
-
102
- rforEach (fn, thisp) {
103
- thisp = thisp || this;
104
- for (let walker = this[LRU_LIST].tail; walker !== null;) {
105
- const prev = walker.prev;
106
- forEachStep(this, fn, walker, thisp);
107
- walker = prev;
108
- }
109
- }
110
-
111
- forEach (fn, thisp) {
112
- thisp = thisp || this;
113
- for (let walker = this[LRU_LIST].head; walker !== null;) {
114
- const next = walker.next;
115
- forEachStep(this, fn, walker, thisp);
116
- walker = next;
117
- }
118
- }
119
-
120
- keys () {
121
- return this[LRU_LIST].toArray().map(k => k.key)
122
- }
123
-
124
- values () {
125
- return this[LRU_LIST].toArray().map(k => k.value)
126
- }
127
-
128
- reset () {
129
- if (this[DISPOSE] &&
130
- this[LRU_LIST] &&
131
- this[LRU_LIST].length) {
132
- this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value));
133
- }
134
-
135
- this[CACHE] = new Map(); // hash of items by key
136
- this[LRU_LIST] = new Yallist(); // list of items in order of use recency
137
- this[LENGTH] = 0; // length of items in the list
138
- }
139
-
140
- dump () {
141
- return this[LRU_LIST].map(hit =>
142
- isStale(this, hit) ? false : {
143
- k: hit.key,
144
- v: hit.value,
145
- e: hit.now + (hit.maxAge || 0)
146
- }).toArray().filter(h => h)
147
- }
148
-
149
- dumpLru () {
150
- return this[LRU_LIST]
151
- }
152
-
153
- set (key, value, maxAge) {
154
- maxAge = maxAge || this[MAX_AGE];
155
-
156
- if (maxAge && typeof maxAge !== 'number')
157
- throw new TypeError('maxAge must be a number')
158
-
159
- const now = maxAge ? Date.now() : 0;
160
- const len = this[LENGTH_CALCULATOR](value, key);
161
-
162
- if (this[CACHE].has(key)) {
163
- if (len > this[MAX]) {
164
- del(this, this[CACHE].get(key));
165
- return false
166
- }
167
-
168
- const node = this[CACHE].get(key);
169
- const item = node.value;
170
-
171
- // dispose of the old one before overwriting
172
- // split out into 2 ifs for better coverage tracking
173
- if (this[DISPOSE]) {
174
- if (!this[NO_DISPOSE_ON_SET])
175
- this[DISPOSE](key, item.value);
176
- }
177
-
178
- item.now = now;
179
- item.maxAge = maxAge;
180
- item.value = value;
181
- this[LENGTH] += len - item.length;
182
- item.length = len;
183
- this.get(key);
184
- trim(this);
185
- return true
186
- }
187
-
188
- const hit = new Entry(key, value, len, now, maxAge);
189
-
190
- // oversized objects fall out of cache automatically.
191
- if (hit.length > this[MAX]) {
192
- if (this[DISPOSE])
193
- this[DISPOSE](key, value);
194
-
195
- return false
196
- }
197
-
198
- this[LENGTH] += hit.length;
199
- this[LRU_LIST].unshift(hit);
200
- this[CACHE].set(key, this[LRU_LIST].head);
201
- trim(this);
202
- return true
203
- }
204
-
205
- has (key) {
206
- if (!this[CACHE].has(key)) return false
207
- const hit = this[CACHE].get(key).value;
208
- return !isStale(this, hit)
209
- }
210
-
211
- get (key) {
212
- return get(this, key, true)
213
- }
214
-
215
- peek (key) {
216
- return get(this, key, false)
217
- }
218
-
219
- pop () {
220
- const node = this[LRU_LIST].tail;
221
- if (!node)
222
- return null
223
-
224
- del(this, node);
225
- return node.value
226
- }
227
-
228
- del (key) {
229
- del(this, this[CACHE].get(key));
230
- }
231
-
232
- load (arr) {
233
- // reset the cache
234
- this.reset();
235
-
236
- const now = Date.now();
237
- // A previous serialized cache has the most recent items first
238
- for (let l = arr.length - 1; l >= 0; l--) {
239
- const hit = arr[l];
240
- const expiresAt = hit.e || 0;
241
- if (expiresAt === 0)
242
- // the item was created without expiration in a non aged cache
243
- this.set(hit.k, hit.v);
244
- else {
245
- const maxAge = expiresAt - now;
246
- // dont add already expired items
247
- if (maxAge > 0) {
248
- this.set(hit.k, hit.v, maxAge);
249
- }
250
- }
251
- }
252
- }
253
-
254
- prune () {
255
- this[CACHE].forEach((value, key) => get(this, key, false));
256
- }
1
+ import { __require as requireYallist } from '../yallist/yallist.mjs';
2
+
3
+ var lruCache;
4
+ var hasRequiredLruCache;
5
+
6
+ function requireLruCache () {
7
+ if (hasRequiredLruCache) return lruCache;
8
+ hasRequiredLruCache = 1;
9
+
10
+ // A linked list to keep track of recently-used-ness
11
+ const Yallist = requireYallist();
12
+
13
+ const MAX = Symbol('max');
14
+ const LENGTH = Symbol('length');
15
+ const LENGTH_CALCULATOR = Symbol('lengthCalculator');
16
+ const ALLOW_STALE = Symbol('allowStale');
17
+ const MAX_AGE = Symbol('maxAge');
18
+ const DISPOSE = Symbol('dispose');
19
+ const NO_DISPOSE_ON_SET = Symbol('noDisposeOnSet');
20
+ const LRU_LIST = Symbol('lruList');
21
+ const CACHE = Symbol('cache');
22
+ const UPDATE_AGE_ON_GET = Symbol('updateAgeOnGet');
23
+
24
+ const naiveLength = () => 1;
25
+
26
+ // lruList is a yallist where the head is the youngest
27
+ // item, and the tail is the oldest. the list contains the Hit
28
+ // objects as the entries.
29
+ // Each Hit object has a reference to its Yallist.Node. This
30
+ // never changes.
31
+ //
32
+ // cache is a Map (or PseudoMap) that matches the keys to
33
+ // the Yallist.Node object.
34
+ class LRUCache {
35
+ constructor (options) {
36
+ if (typeof options === 'number')
37
+ options = { max: options };
38
+
39
+ if (!options)
40
+ options = {};
41
+
42
+ if (options.max && (typeof options.max !== 'number' || options.max < 0))
43
+ throw new TypeError('max must be a non-negative number')
44
+ // Kind of weird to have a default max of Infinity, but oh well.
45
+ this[MAX] = options.max || Infinity;
46
+
47
+ const lc = options.length || naiveLength;
48
+ this[LENGTH_CALCULATOR] = (typeof lc !== 'function') ? naiveLength : lc;
49
+ this[ALLOW_STALE] = options.stale || false;
50
+ if (options.maxAge && typeof options.maxAge !== 'number')
51
+ throw new TypeError('maxAge must be a number')
52
+ this[MAX_AGE] = options.maxAge || 0;
53
+ this[DISPOSE] = options.dispose;
54
+ this[NO_DISPOSE_ON_SET] = options.noDisposeOnSet || false;
55
+ this[UPDATE_AGE_ON_GET] = options.updateAgeOnGet || false;
56
+ this.reset();
57
+ }
58
+
59
+ // resize the cache when the max changes.
60
+ set max (mL) {
61
+ if (typeof mL !== 'number' || mL < 0)
62
+ throw new TypeError('max must be a non-negative number')
63
+
64
+ this[MAX] = mL || Infinity;
65
+ trim(this);
66
+ }
67
+ get max () {
68
+ return this[MAX]
69
+ }
70
+
71
+ set allowStale (allowStale) {
72
+ this[ALLOW_STALE] = !!allowStale;
73
+ }
74
+ get allowStale () {
75
+ return this[ALLOW_STALE]
76
+ }
77
+
78
+ set maxAge (mA) {
79
+ if (typeof mA !== 'number')
80
+ throw new TypeError('maxAge must be a non-negative number')
81
+
82
+ this[MAX_AGE] = mA;
83
+ trim(this);
84
+ }
85
+ get maxAge () {
86
+ return this[MAX_AGE]
87
+ }
88
+
89
+ // resize the cache when the lengthCalculator changes.
90
+ set lengthCalculator (lC) {
91
+ if (typeof lC !== 'function')
92
+ lC = naiveLength;
93
+
94
+ if (lC !== this[LENGTH_CALCULATOR]) {
95
+ this[LENGTH_CALCULATOR] = lC;
96
+ this[LENGTH] = 0;
97
+ this[LRU_LIST].forEach(hit => {
98
+ hit.length = this[LENGTH_CALCULATOR](hit.value, hit.key);
99
+ this[LENGTH] += hit.length;
100
+ });
101
+ }
102
+ trim(this);
103
+ }
104
+ get lengthCalculator () { return this[LENGTH_CALCULATOR] }
105
+
106
+ get length () { return this[LENGTH] }
107
+ get itemCount () { return this[LRU_LIST].length }
108
+
109
+ rforEach (fn, thisp) {
110
+ thisp = thisp || this;
111
+ for (let walker = this[LRU_LIST].tail; walker !== null;) {
112
+ const prev = walker.prev;
113
+ forEachStep(this, fn, walker, thisp);
114
+ walker = prev;
115
+ }
116
+ }
117
+
118
+ forEach (fn, thisp) {
119
+ thisp = thisp || this;
120
+ for (let walker = this[LRU_LIST].head; walker !== null;) {
121
+ const next = walker.next;
122
+ forEachStep(this, fn, walker, thisp);
123
+ walker = next;
124
+ }
125
+ }
126
+
127
+ keys () {
128
+ return this[LRU_LIST].toArray().map(k => k.key)
129
+ }
130
+
131
+ values () {
132
+ return this[LRU_LIST].toArray().map(k => k.value)
133
+ }
134
+
135
+ reset () {
136
+ if (this[DISPOSE] &&
137
+ this[LRU_LIST] &&
138
+ this[LRU_LIST].length) {
139
+ this[LRU_LIST].forEach(hit => this[DISPOSE](hit.key, hit.value));
140
+ }
141
+
142
+ this[CACHE] = new Map(); // hash of items by key
143
+ this[LRU_LIST] = new Yallist(); // list of items in order of use recency
144
+ this[LENGTH] = 0; // length of items in the list
145
+ }
146
+
147
+ dump () {
148
+ return this[LRU_LIST].map(hit =>
149
+ isStale(this, hit) ? false : {
150
+ k: hit.key,
151
+ v: hit.value,
152
+ e: hit.now + (hit.maxAge || 0)
153
+ }).toArray().filter(h => h)
154
+ }
155
+
156
+ dumpLru () {
157
+ return this[LRU_LIST]
158
+ }
159
+
160
+ set (key, value, maxAge) {
161
+ maxAge = maxAge || this[MAX_AGE];
162
+
163
+ if (maxAge && typeof maxAge !== 'number')
164
+ throw new TypeError('maxAge must be a number')
165
+
166
+ const now = maxAge ? Date.now() : 0;
167
+ const len = this[LENGTH_CALCULATOR](value, key);
168
+
169
+ if (this[CACHE].has(key)) {
170
+ if (len > this[MAX]) {
171
+ del(this, this[CACHE].get(key));
172
+ return false
173
+ }
174
+
175
+ const node = this[CACHE].get(key);
176
+ const item = node.value;
177
+
178
+ // dispose of the old one before overwriting
179
+ // split out into 2 ifs for better coverage tracking
180
+ if (this[DISPOSE]) {
181
+ if (!this[NO_DISPOSE_ON_SET])
182
+ this[DISPOSE](key, item.value);
183
+ }
184
+
185
+ item.now = now;
186
+ item.maxAge = maxAge;
187
+ item.value = value;
188
+ this[LENGTH] += len - item.length;
189
+ item.length = len;
190
+ this.get(key);
191
+ trim(this);
192
+ return true
193
+ }
194
+
195
+ const hit = new Entry(key, value, len, now, maxAge);
196
+
197
+ // oversized objects fall out of cache automatically.
198
+ if (hit.length > this[MAX]) {
199
+ if (this[DISPOSE])
200
+ this[DISPOSE](key, value);
201
+
202
+ return false
203
+ }
204
+
205
+ this[LENGTH] += hit.length;
206
+ this[LRU_LIST].unshift(hit);
207
+ this[CACHE].set(key, this[LRU_LIST].head);
208
+ trim(this);
209
+ return true
210
+ }
211
+
212
+ has (key) {
213
+ if (!this[CACHE].has(key)) return false
214
+ const hit = this[CACHE].get(key).value;
215
+ return !isStale(this, hit)
216
+ }
217
+
218
+ get (key) {
219
+ return get(this, key, true)
220
+ }
221
+
222
+ peek (key) {
223
+ return get(this, key, false)
224
+ }
225
+
226
+ pop () {
227
+ const node = this[LRU_LIST].tail;
228
+ if (!node)
229
+ return null
230
+
231
+ del(this, node);
232
+ return node.value
233
+ }
234
+
235
+ del (key) {
236
+ del(this, this[CACHE].get(key));
237
+ }
238
+
239
+ load (arr) {
240
+ // reset the cache
241
+ this.reset();
242
+
243
+ const now = Date.now();
244
+ // A previous serialized cache has the most recent items first
245
+ for (let l = arr.length - 1; l >= 0; l--) {
246
+ const hit = arr[l];
247
+ const expiresAt = hit.e || 0;
248
+ if (expiresAt === 0)
249
+ // the item was created without expiration in a non aged cache
250
+ this.set(hit.k, hit.v);
251
+ else {
252
+ const maxAge = expiresAt - now;
253
+ // dont add already expired items
254
+ if (maxAge > 0) {
255
+ this.set(hit.k, hit.v, maxAge);
256
+ }
257
+ }
258
+ }
259
+ }
260
+
261
+ prune () {
262
+ this[CACHE].forEach((value, key) => get(this, key, false));
263
+ }
264
+ }
265
+
266
+ const get = (self, key, doUse) => {
267
+ const node = self[CACHE].get(key);
268
+ if (node) {
269
+ const hit = node.value;
270
+ if (isStale(self, hit)) {
271
+ del(self, node);
272
+ if (!self[ALLOW_STALE])
273
+ return undefined
274
+ } else {
275
+ if (doUse) {
276
+ if (self[UPDATE_AGE_ON_GET])
277
+ node.value.now = Date.now();
278
+ self[LRU_LIST].unshiftNode(node);
279
+ }
280
+ }
281
+ return hit.value
282
+ }
283
+ };
284
+
285
+ const isStale = (self, hit) => {
286
+ if (!hit || (!hit.maxAge && !self[MAX_AGE]))
287
+ return false
288
+
289
+ const diff = Date.now() - hit.now;
290
+ return hit.maxAge ? diff > hit.maxAge
291
+ : self[MAX_AGE] && (diff > self[MAX_AGE])
292
+ };
293
+
294
+ const trim = self => {
295
+ if (self[LENGTH] > self[MAX]) {
296
+ for (let walker = self[LRU_LIST].tail;
297
+ self[LENGTH] > self[MAX] && walker !== null;) {
298
+ // We know that we're about to delete this one, and also
299
+ // what the next least recently used key will be, so just
300
+ // go ahead and set it now.
301
+ const prev = walker.prev;
302
+ del(self, walker);
303
+ walker = prev;
304
+ }
305
+ }
306
+ };
307
+
308
+ const del = (self, node) => {
309
+ if (node) {
310
+ const hit = node.value;
311
+ if (self[DISPOSE])
312
+ self[DISPOSE](hit.key, hit.value);
313
+
314
+ self[LENGTH] -= hit.length;
315
+ self[CACHE].delete(hit.key);
316
+ self[LRU_LIST].removeNode(node);
317
+ }
318
+ };
319
+
320
+ class Entry {
321
+ constructor (key, value, length, now, maxAge) {
322
+ this.key = key;
323
+ this.value = value;
324
+ this.length = length;
325
+ this.now = now;
326
+ this.maxAge = maxAge || 0;
327
+ }
328
+ }
329
+
330
+ const forEachStep = (self, fn, node, thisp) => {
331
+ let hit = node.value;
332
+ if (isStale(self, hit)) {
333
+ del(self, node);
334
+ if (!self[ALLOW_STALE])
335
+ hit = undefined;
336
+ }
337
+ if (hit)
338
+ fn.call(thisp, hit.value, hit.key, self);
339
+ };
340
+
341
+ lruCache = LRUCache;
342
+ return lruCache;
257
343
  }
258
344
 
259
- const get = (self, key, doUse) => {
260
- const node = self[CACHE].get(key);
261
- if (node) {
262
- const hit = node.value;
263
- if (isStale(self, hit)) {
264
- del(self, node);
265
- if (!self[ALLOW_STALE])
266
- return undefined
267
- } else {
268
- if (doUse) {
269
- if (self[UPDATE_AGE_ON_GET])
270
- node.value.now = Date.now();
271
- self[LRU_LIST].unshiftNode(node);
272
- }
273
- }
274
- return hit.value
275
- }
276
- };
277
-
278
- const isStale = (self, hit) => {
279
- if (!hit || (!hit.maxAge && !self[MAX_AGE]))
280
- return false
281
-
282
- const diff = Date.now() - hit.now;
283
- return hit.maxAge ? diff > hit.maxAge
284
- : self[MAX_AGE] && (diff > self[MAX_AGE])
285
- };
286
-
287
- const trim = self => {
288
- if (self[LENGTH] > self[MAX]) {
289
- for (let walker = self[LRU_LIST].tail;
290
- self[LENGTH] > self[MAX] && walker !== null;) {
291
- // We know that we're about to delete this one, and also
292
- // what the next least recently used key will be, so just
293
- // go ahead and set it now.
294
- const prev = walker.prev;
295
- del(self, walker);
296
- walker = prev;
297
- }
298
- }
299
- };
300
-
301
- const del = (self, node) => {
302
- if (node) {
303
- const hit = node.value;
304
- if (self[DISPOSE])
305
- self[DISPOSE](hit.key, hit.value);
306
-
307
- self[LENGTH] -= hit.length;
308
- self[CACHE].delete(hit.key);
309
- self[LRU_LIST].removeNode(node);
310
- }
311
- };
312
-
313
- class Entry {
314
- constructor (key, value, length, now, maxAge) {
315
- this.key = key;
316
- this.value = value;
317
- this.length = length;
318
- this.now = now;
319
- this.maxAge = maxAge || 0;
320
- }
321
- }
322
-
323
- const forEachStep = (self, fn, node, thisp) => {
324
- let hit = node.value;
325
- if (isStale(self, hit)) {
326
- del(self, node);
327
- if (!self[ALLOW_STALE])
328
- hit = undefined;
329
- }
330
- if (hit)
331
- fn.call(thisp, hit.value, hit.key, self);
332
- };
333
-
334
- var lruCache = LRUCache;
335
-
336
- export { lruCache as default };
345
+ export { requireLruCache as __require };
337
346
  //# sourceMappingURL=index.mjs.map