projen 0.54.10 → 0.54.13

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 (147) hide show
  1. package/.jsii +4 -4
  2. package/changelog.md +1 -6
  3. package/docs/deps.md +3 -0
  4. package/docs/node.md +38 -10
  5. package/lib/awscdk/auto-discover.js +4 -4
  6. package/lib/awscdk/awscdk-app-java.js +1 -1
  7. package/lib/awscdk/awscdk-app-py.js +1 -1
  8. package/lib/awscdk/awscdk-app-ts.js +1 -1
  9. package/lib/awscdk/awscdk-construct.js +2 -2
  10. package/lib/awscdk/awscdk-deps-java.js +1 -1
  11. package/lib/awscdk/awscdk-deps-js.js +1 -1
  12. package/lib/awscdk/awscdk-deps.js +1 -1
  13. package/lib/awscdk/cdk-config.js +1 -1
  14. package/lib/awscdk/cdk-tasks.js +1 -1
  15. package/lib/awscdk/integration-test.js +1 -1
  16. package/lib/awscdk/lambda-extension.js +1 -1
  17. package/lib/awscdk/lambda-function.js +2 -2
  18. package/lib/build/build-workflow.js +1 -1
  19. package/lib/cdk/auto-discover-base.js +2 -2
  20. package/lib/cdk/construct-lib.js +1 -1
  21. package/lib/cdk/integration-test-base.js +1 -1
  22. package/lib/cdk/jsii-docgen.js +1 -1
  23. package/lib/cdk/jsii-project.js +1 -1
  24. package/lib/cdk8s/auto-discover.js +2 -2
  25. package/lib/cdk8s/cdk8s-app-ts.js +1 -1
  26. package/lib/cdk8s/cdk8s-construct.js +1 -1
  27. package/lib/cdk8s/integration-test.js +1 -1
  28. package/lib/cdktf/cdktf-construct.js +1 -1
  29. package/lib/component.js +1 -1
  30. package/lib/dependencies.js +1 -1
  31. package/lib/dev-env.js +1 -1
  32. package/lib/docker-compose.js +2 -2
  33. package/lib/file.js +1 -1
  34. package/lib/gitattributes.js +1 -1
  35. package/lib/github/auto-approve.js +1 -1
  36. package/lib/github/auto-merge.js +1 -1
  37. package/lib/github/dependabot.js +1 -1
  38. package/lib/github/github-credentials.js +1 -1
  39. package/lib/github/github-project.js +1 -1
  40. package/lib/github/github.js +1 -1
  41. package/lib/github/mergify.js +1 -1
  42. package/lib/github/pr-template.js +1 -1
  43. package/lib/github/pull-request-lint.js +1 -1
  44. package/lib/github/stale.js +1 -1
  45. package/lib/github/task-workflow.js +1 -1
  46. package/lib/github/workflows.js +1 -1
  47. package/lib/gitlab/configuration.js +1 -1
  48. package/lib/gitlab/gitlab-configuration.js +1 -1
  49. package/lib/gitlab/nested-configuration.js +1 -1
  50. package/lib/gitpod.js +1 -1
  51. package/lib/ignore-file.js +1 -1
  52. package/lib/ini.js +1 -1
  53. package/lib/java/java-project.js +1 -1
  54. package/lib/java/junit.js +1 -1
  55. package/lib/java/maven-compile.js +1 -1
  56. package/lib/java/maven-packaging.js +1 -1
  57. package/lib/java/maven-sample.js +1 -1
  58. package/lib/java/pom.js +1 -1
  59. package/lib/java/projenrc.js +1 -1
  60. package/lib/javascript/bundler.js +1 -1
  61. package/lib/javascript/eslint.js +1 -1
  62. package/lib/javascript/jest.js +1 -1
  63. package/lib/javascript/node-package.js +1 -1
  64. package/lib/javascript/node-project.js +1 -1
  65. package/lib/javascript/npm-config.js +1 -1
  66. package/lib/javascript/prettier.js +1 -1
  67. package/lib/javascript/projenrc.js +1 -1
  68. package/lib/javascript/typescript-config.js +1 -1
  69. package/lib/javascript/upgrade-dependencies.js +2 -2
  70. package/lib/json.js +1 -1
  71. package/lib/license.js +1 -1
  72. package/lib/logger.js +1 -1
  73. package/lib/makefile.js +1 -1
  74. package/lib/object-file.js +1 -1
  75. package/lib/project-build.js +1 -1
  76. package/lib/project.js +1 -1
  77. package/lib/projects.js +1 -1
  78. package/lib/projenrc-json.js +1 -1
  79. package/lib/python/pip.js +1 -1
  80. package/lib/python/poetry.js +2 -2
  81. package/lib/python/projenrc.js +1 -1
  82. package/lib/python/pytest-sample.js +1 -1
  83. package/lib/python/pytest.js +1 -1
  84. package/lib/python/python-project.js +1 -1
  85. package/lib/python/python-sample.js +1 -1
  86. package/lib/python/requirements-file.js +1 -1
  87. package/lib/python/setuppy.js +1 -1
  88. package/lib/python/setuptools.js +1 -1
  89. package/lib/python/venv.js +1 -1
  90. package/lib/readme.js +1 -1
  91. package/lib/release/publisher.js +1 -1
  92. package/lib/release/release-trigger.js +1 -1
  93. package/lib/release/release.js +1 -1
  94. package/lib/sample-file.js +2 -2
  95. package/lib/semver.js +1 -1
  96. package/lib/source-code.js +1 -1
  97. package/lib/task-runtime.js +1 -1
  98. package/lib/task.js +1 -1
  99. package/lib/tasks.js +1 -1
  100. package/lib/testing.js +1 -1
  101. package/lib/textfile.js +1 -1
  102. package/lib/toml.js +1 -1
  103. package/lib/typescript/projenrc.js +1 -1
  104. package/lib/typescript/typescript-typedoc.js +1 -1
  105. package/lib/typescript/typescript.js +3 -3
  106. package/lib/version.js +1 -1
  107. package/lib/vscode/devcontainer.js +1 -1
  108. package/lib/vscode/launch-config.js +1 -1
  109. package/lib/vscode/vscode.js +1 -1
  110. package/lib/web/next.js +3 -3
  111. package/lib/web/postcss.js +1 -1
  112. package/lib/web/react.js +4 -4
  113. package/lib/web/tailwind.js +1 -1
  114. package/lib/xmlfile.js +1 -1
  115. package/lib/yaml.js +1 -1
  116. package/node_modules/{yallist → lru-cache}/LICENSE +1 -1
  117. package/node_modules/lru-cache/README.md +699 -0
  118. package/node_modules/lru-cache/index.js +815 -0
  119. package/node_modules/{semver/node_modules/lru-cache → lru-cache}/package.json +17 -7
  120. package/node_modules/semver/README.md +3 -1
  121. package/node_modules/semver/bin/semver.js +17 -8
  122. package/node_modules/semver/classes/comparator.js +3 -2
  123. package/node_modules/semver/classes/index.js +1 -1
  124. package/node_modules/semver/classes/range.js +31 -22
  125. package/node_modules/semver/functions/cmp.js +8 -4
  126. package/node_modules/semver/functions/coerce.js +3 -2
  127. package/node_modules/semver/functions/parse.js +1 -1
  128. package/node_modules/semver/internal/constants.js +2 -2
  129. package/node_modules/semver/internal/identifiers.js +1 -1
  130. package/node_modules/semver/internal/parse-options.js +3 -3
  131. package/node_modules/semver/internal/re.js +3 -3
  132. package/node_modules/semver/package.json +46 -13
  133. package/node_modules/semver/ranges/min-version.js +2 -1
  134. package/node_modules/semver/ranges/outside.js +1 -1
  135. package/node_modules/semver/ranges/simplify.js +15 -12
  136. package/node_modules/semver/ranges/subset.js +53 -31
  137. package/package.json +6 -6
  138. package/releasetag.txt +1 -1
  139. package/version.txt +1 -1
  140. package/node_modules/semver/CHANGELOG.md +0 -111
  141. package/node_modules/semver/node_modules/lru-cache/LICENSE +0 -15
  142. package/node_modules/semver/node_modules/lru-cache/README.md +0 -166
  143. package/node_modules/semver/node_modules/lru-cache/index.js +0 -334
  144. package/node_modules/yallist/README.md +0 -204
  145. package/node_modules/yallist/iterator.js +0 -8
  146. package/node_modules/yallist/package.json +0 -29
  147. package/node_modules/yallist/yallist.js +0 -426
@@ -41,8 +41,9 @@ const compare = require('../functions/compare.js')
41
41
  // - Else return true
42
42
 
43
43
  const subset = (sub, dom, options = {}) => {
44
- if (sub === dom)
44
+ if (sub === dom) {
45
45
  return true
46
+ }
46
47
 
47
48
  sub = new Range(sub, options)
48
49
  dom = new Range(dom, options)
@@ -52,73 +53,84 @@ const subset = (sub, dom, options = {}) => {
52
53
  for (const simpleDom of dom.set) {
53
54
  const isSub = simpleSubset(simpleSub, simpleDom, options)
54
55
  sawNonNull = sawNonNull || isSub !== null
55
- if (isSub)
56
+ if (isSub) {
56
57
  continue OUTER
58
+ }
57
59
  }
58
60
  // the null set is a subset of everything, but null simple ranges in
59
61
  // a complex range should be ignored. so if we saw a non-null range,
60
62
  // then we know this isn't a subset, but if EVERY simple range was null,
61
63
  // then it is a subset.
62
- if (sawNonNull)
64
+ if (sawNonNull) {
63
65
  return false
66
+ }
64
67
  }
65
68
  return true
66
69
  }
67
70
 
68
71
  const simpleSubset = (sub, dom, options) => {
69
- if (sub === dom)
72
+ if (sub === dom) {
70
73
  return true
74
+ }
71
75
 
72
76
  if (sub.length === 1 && sub[0].semver === ANY) {
73
- if (dom.length === 1 && dom[0].semver === ANY)
77
+ if (dom.length === 1 && dom[0].semver === ANY) {
74
78
  return true
75
- else if (options.includePrerelease)
76
- sub = [ new Comparator('>=0.0.0-0') ]
77
- else
78
- sub = [ new Comparator('>=0.0.0') ]
79
+ } else if (options.includePrerelease) {
80
+ sub = [new Comparator('>=0.0.0-0')]
81
+ } else {
82
+ sub = [new Comparator('>=0.0.0')]
83
+ }
79
84
  }
80
85
 
81
86
  if (dom.length === 1 && dom[0].semver === ANY) {
82
- if (options.includePrerelease)
87
+ if (options.includePrerelease) {
83
88
  return true
84
- else
85
- dom = [ new Comparator('>=0.0.0') ]
89
+ } else {
90
+ dom = [new Comparator('>=0.0.0')]
91
+ }
86
92
  }
87
93
 
88
94
  const eqSet = new Set()
89
95
  let gt, lt
90
96
  for (const c of sub) {
91
- if (c.operator === '>' || c.operator === '>=')
97
+ if (c.operator === '>' || c.operator === '>=') {
92
98
  gt = higherGT(gt, c, options)
93
- else if (c.operator === '<' || c.operator === '<=')
99
+ } else if (c.operator === '<' || c.operator === '<=') {
94
100
  lt = lowerLT(lt, c, options)
95
- else
101
+ } else {
96
102
  eqSet.add(c.semver)
103
+ }
97
104
  }
98
105
 
99
- if (eqSet.size > 1)
106
+ if (eqSet.size > 1) {
100
107
  return null
108
+ }
101
109
 
102
110
  let gtltComp
103
111
  if (gt && lt) {
104
112
  gtltComp = compare(gt.semver, lt.semver, options)
105
- if (gtltComp > 0)
113
+ if (gtltComp > 0) {
106
114
  return null
107
- else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<='))
115
+ } else if (gtltComp === 0 && (gt.operator !== '>=' || lt.operator !== '<=')) {
108
116
  return null
117
+ }
109
118
  }
110
119
 
111
120
  // will iterate one or zero times
112
121
  for (const eq of eqSet) {
113
- if (gt && !satisfies(eq, String(gt), options))
122
+ if (gt && !satisfies(eq, String(gt), options)) {
114
123
  return null
124
+ }
115
125
 
116
- if (lt && !satisfies(eq, String(lt), options))
126
+ if (lt && !satisfies(eq, String(lt), options)) {
117
127
  return null
128
+ }
118
129
 
119
130
  for (const c of dom) {
120
- if (!satisfies(eq, String(c), options))
131
+ if (!satisfies(eq, String(c), options)) {
121
132
  return false
133
+ }
122
134
  }
123
135
 
124
136
  return true
@@ -154,10 +166,12 @@ const simpleSubset = (sub, dom, options) => {
154
166
  }
155
167
  if (c.operator === '>' || c.operator === '>=') {
156
168
  higher = higherGT(gt, c, options)
157
- if (higher === c && higher !== gt)
169
+ if (higher === c && higher !== gt) {
158
170
  return false
159
- } else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options))
171
+ }
172
+ } else if (gt.operator === '>=' && !satisfies(gt.semver, String(c), options)) {
160
173
  return false
174
+ }
161
175
  }
162
176
  if (lt) {
163
177
  if (needDomLTPre) {
@@ -170,37 +184,44 @@ const simpleSubset = (sub, dom, options) => {
170
184
  }
171
185
  if (c.operator === '<' || c.operator === '<=') {
172
186
  lower = lowerLT(lt, c, options)
173
- if (lower === c && lower !== lt)
187
+ if (lower === c && lower !== lt) {
174
188
  return false
175
- } else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options))
189
+ }
190
+ } else if (lt.operator === '<=' && !satisfies(lt.semver, String(c), options)) {
176
191
  return false
192
+ }
177
193
  }
178
- if (!c.operator && (lt || gt) && gtltComp !== 0)
194
+ if (!c.operator && (lt || gt) && gtltComp !== 0) {
179
195
  return false
196
+ }
180
197
  }
181
198
 
182
199
  // if there was a < or >, and nothing in the dom, then must be false
183
200
  // UNLESS it was limited by another range in the other direction.
184
201
  // Eg, >1.0.0 <1.0.1 is still a subset of <2.0.0
185
- if (gt && hasDomLT && !lt && gtltComp !== 0)
202
+ if (gt && hasDomLT && !lt && gtltComp !== 0) {
186
203
  return false
204
+ }
187
205
 
188
- if (lt && hasDomGT && !gt && gtltComp !== 0)
206
+ if (lt && hasDomGT && !gt && gtltComp !== 0) {
189
207
  return false
208
+ }
190
209
 
191
210
  // we needed a prerelease range in a specific tuple, but didn't get one
192
211
  // then this isn't a subset. eg >=1.2.3-pre is not a subset of >=1.0.0,
193
212
  // because it includes prereleases in the 1.2.3 tuple
194
- if (needDomGTPre || needDomLTPre)
213
+ if (needDomGTPre || needDomLTPre) {
195
214
  return false
215
+ }
196
216
 
197
217
  return true
198
218
  }
199
219
 
200
220
  // >=1.2.3 is lower than >1.2.3
201
221
  const higherGT = (a, b, options) => {
202
- if (!a)
222
+ if (!a) {
203
223
  return b
224
+ }
204
225
  const comp = compare(a.semver, b.semver, options)
205
226
  return comp > 0 ? a
206
227
  : comp < 0 ? b
@@ -210,8 +231,9 @@ const higherGT = (a, b, options) => {
210
231
 
211
232
  // <=1.2.3 is higher than <1.2.3
212
233
  const lowerLT = (a, b, options) => {
213
- if (!a)
234
+ if (!a) {
214
235
  return b
236
+ }
215
237
  const comp = compare(a.semver, b.semver, options)
216
238
  return comp < 0 ? a
217
239
  : comp > 0 ? b
package/package.json CHANGED
@@ -59,7 +59,7 @@
59
59
  "@typescript-eslint/eslint-plugin": "^5",
60
60
  "@typescript-eslint/parser": "^5",
61
61
  "all-contributors-cli": "^6.20.0",
62
- "esbuild": "^0.14.31",
62
+ "esbuild": "^0.14.34",
63
63
  "eslint": "^8",
64
64
  "eslint-config-prettier": "^8.5.0",
65
65
  "eslint-import-resolver-node": "^0.3.6",
@@ -68,10 +68,10 @@
68
68
  "eslint-plugin-prettier": "^4.0.0",
69
69
  "jest": "^27.5.1",
70
70
  "jest-junit": "^13",
71
- "jsii": "^1.55.1",
72
- "jsii-diff": "^1.55.1",
71
+ "jsii": "^1.56.0",
72
+ "jsii-diff": "^1.56.0",
73
73
  "jsii-docgen": "^1.8.110",
74
- "jsii-pacmak": "^1.55.1",
74
+ "jsii-pacmak": "^1.56.0",
75
75
  "json-schema": "^0.4.0",
76
76
  "markmac": "^0.1.146",
77
77
  "npm-check-updates": "^12",
@@ -88,7 +88,7 @@
88
88
  "fs-extra": "^9.1.0",
89
89
  "glob": "^7",
90
90
  "ini": "^2.0.0",
91
- "semver": "^7.3.5",
91
+ "semver": "^7.3.6",
92
92
  "shx": "^0.3.4",
93
93
  "xmlbuilder2": "^2.4.1",
94
94
  "yaml": "2.0.0-11",
@@ -121,7 +121,7 @@
121
121
  },
122
122
  "main": "lib/index.js",
123
123
  "license": "Apache-2.0",
124
- "version": "0.54.10",
124
+ "version": "0.54.13",
125
125
  "jest": {
126
126
  "testMatch": [
127
127
  "<rootDir>/src/**/__tests__/**/*.ts?(x)",
package/releasetag.txt CHANGED
@@ -1 +1 @@
1
- v0.54.10
1
+ v0.54.13
package/version.txt CHANGED
@@ -1 +1 @@
1
- 0.54.10
1
+ 0.54.13
@@ -1,111 +0,0 @@
1
- # changes log
2
-
3
- ## 7.3.0
4
-
5
- * Add `subset(r1, r2)` method to determine if `r1` range is entirely
6
- contained by `r2` range.
7
-
8
- ## 7.2.3
9
-
10
- * Fix handling of `includePrelease` mode where version ranges like `1.0.0 -
11
- 2.0.0` would include `3.0.0-pre` and not `1.0.0-pre`.
12
-
13
- ## 7.2.2
14
-
15
- * Fix bug where `2.0.0-pre` would be included in `^1.0.0` if
16
- `includePrerelease` was set to true.
17
-
18
- ## 7.2.0
19
-
20
- * Add `simplifyRange` method to attempt to generate a more human-readable
21
- range expression that is equivalent to a supplied range, for a given set
22
- of versions.
23
-
24
- ## 7.1.2
25
-
26
- * Remove fancy lazy-loading logic, as it was causing problems for webpack
27
- users.
28
-
29
- ## 7.1.0
30
-
31
- * Add `require('semver/preload')` to load the entire module without using
32
- lazy getter methods.
33
-
34
- ## 7.0.0
35
-
36
- * Refactor module into separate files for better tree-shaking
37
- * Drop support for very old node versions, use const/let, `=>` functions,
38
- and classes.
39
-
40
- ## 6.3.0
41
-
42
- * Expose the token enum on the exports
43
-
44
- ## 6.2.0
45
-
46
- * Coerce numbers to strings when passed to semver.coerce()
47
- * Add `rtl` option to coerce from right to left
48
-
49
- ## 6.1.3
50
-
51
- * Handle X-ranges properly in includePrerelease mode
52
-
53
- ## 6.1.2
54
-
55
- * Do not throw when testing invalid version strings
56
-
57
- ## 6.1.1
58
-
59
- * Add options support for semver.coerce()
60
- * Handle undefined version passed to Range.test
61
-
62
- ## 6.1.0
63
-
64
- * Add semver.compareBuild function
65
- * Support `*` in semver.intersects
66
-
67
- ## 6.0
68
-
69
- * Fix `intersects` logic.
70
-
71
- This is technically a bug fix, but since it is also a change to behavior
72
- that may require users updating their code, it is marked as a major
73
- version increment.
74
-
75
- ## 5.7
76
-
77
- * Add `minVersion` method
78
-
79
- ## 5.6
80
-
81
- * Move boolean `loose` param to an options object, with
82
- backwards-compatibility protection.
83
- * Add ability to opt out of special prerelease version handling with
84
- the `includePrerelease` option flag.
85
-
86
- ## 5.5
87
-
88
- * Add version coercion capabilities
89
-
90
- ## 5.4
91
-
92
- * Add intersection checking
93
-
94
- ## 5.3
95
-
96
- * Add `minSatisfying` method
97
-
98
- ## 5.2
99
-
100
- * Add `prerelease(v)` that returns prerelease components
101
-
102
- ## 5.1
103
-
104
- * Add Backus-Naur for ranges
105
- * Remove excessively cute inspection methods
106
-
107
- ## 5.0
108
-
109
- * Remove AMD/Browserified build artifacts
110
- * Fix ltr and gtr when using the `*` range
111
- * Fix for range `*` with a prerelease identifier
@@ -1,15 +0,0 @@
1
- The ISC License
2
-
3
- Copyright (c) Isaac Z. Schlueter and Contributors
4
-
5
- Permission to use, copy, modify, and/or distribute this software for any
6
- purpose with or without fee is hereby granted, provided that the above
7
- copyright notice and this permission notice appear in all copies.
8
-
9
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
15
- IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
@@ -1,166 +0,0 @@
1
- # lru cache
2
-
3
- A cache object that deletes the least-recently-used items.
4
-
5
- [![Build Status](https://travis-ci.org/isaacs/node-lru-cache.svg?branch=master)](https://travis-ci.org/isaacs/node-lru-cache) [![Coverage Status](https://coveralls.io/repos/isaacs/node-lru-cache/badge.svg?service=github)](https://coveralls.io/github/isaacs/node-lru-cache)
6
-
7
- ## Installation:
8
-
9
- ```javascript
10
- npm install lru-cache --save
11
- ```
12
-
13
- ## Usage:
14
-
15
- ```javascript
16
- var LRU = require("lru-cache")
17
- , options = { max: 500
18
- , length: function (n, key) { return n * 2 + key.length }
19
- , dispose: function (key, n) { n.close() }
20
- , maxAge: 1000 * 60 * 60 }
21
- , cache = new LRU(options)
22
- , otherCache = new LRU(50) // sets just the max size
23
-
24
- cache.set("key", "value")
25
- cache.get("key") // "value"
26
-
27
- // non-string keys ARE fully supported
28
- // but note that it must be THE SAME object, not
29
- // just a JSON-equivalent object.
30
- var someObject = { a: 1 }
31
- cache.set(someObject, 'a value')
32
- // Object keys are not toString()-ed
33
- cache.set('[object Object]', 'a different value')
34
- assert.equal(cache.get(someObject), 'a value')
35
- // A similar object with same keys/values won't work,
36
- // because it's a different object identity
37
- assert.equal(cache.get({ a: 1 }), undefined)
38
-
39
- cache.reset() // empty the cache
40
- ```
41
-
42
- If you put more stuff in it, then items will fall out.
43
-
44
- If you try to put an oversized thing in it, then it'll fall out right
45
- away.
46
-
47
- ## Options
48
-
49
- * `max` The maximum size of the cache, checked by applying the length
50
- function to all values in the cache. Not setting this is kind of
51
- silly, since that's the whole purpose of this lib, but it defaults
52
- to `Infinity`. Setting it to a non-number or negative number will
53
- throw a `TypeError`. Setting it to 0 makes it be `Infinity`.
54
- * `maxAge` Maximum age in ms. Items are not pro-actively pruned out
55
- as they age, but if you try to get an item that is too old, it'll
56
- drop it and return undefined instead of giving it to you.
57
- Setting this to a negative value will make everything seem old!
58
- Setting it to a non-number will throw a `TypeError`.
59
- * `length` Function that is used to calculate the length of stored
60
- items. If you're storing strings or buffers, then you probably want
61
- to do something like `function(n, key){return n.length}`. The default is
62
- `function(){return 1}`, which is fine if you want to store `max`
63
- like-sized things. The item is passed as the first argument, and
64
- the key is passed as the second argumnet.
65
- * `dispose` Function that is called on items when they are dropped
66
- from the cache. This can be handy if you want to close file
67
- descriptors or do other cleanup tasks when items are no longer
68
- accessible. Called with `key, value`. It's called *before*
69
- actually removing the item from the internal cache, so if you want
70
- to immediately put it back in, you'll have to do that in a
71
- `nextTick` or `setTimeout` callback or it won't do anything.
72
- * `stale` By default, if you set a `maxAge`, it'll only actually pull
73
- stale items out of the cache when you `get(key)`. (That is, it's
74
- not pre-emptively doing a `setTimeout` or anything.) If you set
75
- `stale:true`, it'll return the stale value before deleting it. If
76
- you don't set this, then it'll return `undefined` when you try to
77
- get a stale entry, as if it had already been deleted.
78
- * `noDisposeOnSet` By default, if you set a `dispose()` method, then
79
- it'll be called whenever a `set()` operation overwrites an existing
80
- key. If you set this option, `dispose()` will only be called when a
81
- key falls out of the cache, not when it is overwritten.
82
- * `updateAgeOnGet` When using time-expiring entries with `maxAge`,
83
- setting this to `true` will make each item's effective time update
84
- to the current time whenever it is retrieved from cache, causing it
85
- to not expire. (It can still fall out of cache based on recency of
86
- use, of course.)
87
-
88
- ## API
89
-
90
- * `set(key, value, maxAge)`
91
- * `get(key) => value`
92
-
93
- Both of these will update the "recently used"-ness of the key.
94
- They do what you think. `maxAge` is optional and overrides the
95
- cache `maxAge` option if provided.
96
-
97
- If the key is not found, `get()` will return `undefined`.
98
-
99
- The key and val can be any value.
100
-
101
- * `peek(key)`
102
-
103
- Returns the key value (or `undefined` if not found) without
104
- updating the "recently used"-ness of the key.
105
-
106
- (If you find yourself using this a lot, you *might* be using the
107
- wrong sort of data structure, but there are some use cases where
108
- it's handy.)
109
-
110
- * `del(key)`
111
-
112
- Deletes a key out of the cache.
113
-
114
- * `reset()`
115
-
116
- Clear the cache entirely, throwing away all values.
117
-
118
- * `has(key)`
119
-
120
- Check if a key is in the cache, without updating the recent-ness
121
- or deleting it for being stale.
122
-
123
- * `forEach(function(value,key,cache), [thisp])`
124
-
125
- Just like `Array.prototype.forEach`. Iterates over all the keys
126
- in the cache, in order of recent-ness. (Ie, more recently used
127
- items are iterated over first.)
128
-
129
- * `rforEach(function(value,key,cache), [thisp])`
130
-
131
- The same as `cache.forEach(...)` but items are iterated over in
132
- reverse order. (ie, less recently used items are iterated over
133
- first.)
134
-
135
- * `keys()`
136
-
137
- Return an array of the keys in the cache.
138
-
139
- * `values()`
140
-
141
- Return an array of the values in the cache.
142
-
143
- * `length`
144
-
145
- Return total length of objects in cache taking into account
146
- `length` options function.
147
-
148
- * `itemCount`
149
-
150
- Return total quantity of objects currently in cache. Note, that
151
- `stale` (see options) items are returned as part of this item
152
- count.
153
-
154
- * `dump()`
155
-
156
- Return an array of the cache entries ready for serialization and usage
157
- with 'destinationCache.load(arr)`.
158
-
159
- * `load(cacheEntriesArray)`
160
-
161
- Loads another cache entries array, obtained with `sourceCache.dump()`,
162
- into the cache. The destination cache is reset before loading new entries
163
-
164
- * `prune()`
165
-
166
- Manually iterates over the entire cache proactively pruning old entries