create-docusaurus 0.0.0-4411 → 0.0.0-4420
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.
- package/package.json +3 -3
- package/templates/classic/package.json +3 -3
- package/templates/classic-typescript/package.json +4 -4
- package/templates/classic-typescript/src/components/HomepageFeatures.tsx +6 -1
- package/templates/facebook/package.json +3 -3
- package/templates/facebook/node_modules/hosted-git-info/LICENSE +0 -13
- package/templates/facebook/node_modules/hosted-git-info/README.md +0 -133
- package/templates/facebook/node_modules/hosted-git-info/git-host-info.js +0 -184
- package/templates/facebook/node_modules/hosted-git-info/git-host.js +0 -110
- package/templates/facebook/node_modules/hosted-git-info/index.js +0 -237
- package/templates/facebook/node_modules/hosted-git-info/package.json +0 -51
- package/templates/facebook/node_modules/lru-cache/LICENSE +0 -15
- package/templates/facebook/node_modules/lru-cache/README.md +0 -166
- package/templates/facebook/node_modules/lru-cache/index.js +0 -334
- package/templates/facebook/node_modules/lru-cache/package.json +0 -34
- package/templates/facebook/node_modules/normalize-package-data/AUTHORS +0 -4
- package/templates/facebook/node_modules/normalize-package-data/LICENSE +0 -15
- package/templates/facebook/node_modules/normalize-package-data/README.md +0 -108
- package/templates/facebook/node_modules/normalize-package-data/lib/extract_description.js +0 -22
- package/templates/facebook/node_modules/normalize-package-data/lib/fixer.js +0 -474
- package/templates/facebook/node_modules/normalize-package-data/lib/make_warning.js +0 -22
- package/templates/facebook/node_modules/normalize-package-data/lib/normalize.js +0 -48
- package/templates/facebook/node_modules/normalize-package-data/lib/safe_format.js +0 -11
- package/templates/facebook/node_modules/normalize-package-data/lib/typos.json +0 -25
- package/templates/facebook/node_modules/normalize-package-data/lib/warning_messages.json +0 -30
- package/templates/facebook/node_modules/normalize-package-data/package.json +0 -41
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
const url = require('url')
|
|
3
|
-
const gitHosts = require('./git-host-info.js')
|
|
4
|
-
const GitHost = module.exports = require('./git-host.js')
|
|
5
|
-
const LRU = require('lru-cache')
|
|
6
|
-
const cache = new LRU({ max: 1000 })
|
|
7
|
-
|
|
8
|
-
const protocolToRepresentationMap = {
|
|
9
|
-
'git+ssh:': 'sshurl',
|
|
10
|
-
'git+https:': 'https',
|
|
11
|
-
'ssh:': 'sshurl',
|
|
12
|
-
'git:': 'git'
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
function protocolToRepresentation (protocol) {
|
|
16
|
-
return protocolToRepresentationMap[protocol] || protocol.slice(0, -1)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const authProtocols = {
|
|
20
|
-
'git:': true,
|
|
21
|
-
'https:': true,
|
|
22
|
-
'git+https:': true,
|
|
23
|
-
'http:': true,
|
|
24
|
-
'git+http:': true
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const knownProtocols = Object.keys(gitHosts.byShortcut).concat(['http:', 'https:', 'git:', 'git+ssh:', 'git+https:', 'ssh:'])
|
|
28
|
-
|
|
29
|
-
module.exports.fromUrl = function (giturl, opts) {
|
|
30
|
-
if (typeof giturl !== 'string') {
|
|
31
|
-
return
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const key = giturl + JSON.stringify(opts || {})
|
|
35
|
-
|
|
36
|
-
if (!cache.has(key)) {
|
|
37
|
-
cache.set(key, fromUrl(giturl, opts))
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return cache.get(key)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function fromUrl (giturl, opts) {
|
|
44
|
-
if (!giturl) {
|
|
45
|
-
return
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const url = isGitHubShorthand(giturl) ? 'github:' + giturl : correctProtocol(giturl)
|
|
49
|
-
const parsed = parseGitUrl(url)
|
|
50
|
-
if (!parsed) {
|
|
51
|
-
return parsed
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const gitHostShortcut = gitHosts.byShortcut[parsed.protocol]
|
|
55
|
-
const gitHostDomain = gitHosts.byDomain[parsed.hostname.startsWith('www.') ? parsed.hostname.slice(4) : parsed.hostname]
|
|
56
|
-
const gitHostName = gitHostShortcut || gitHostDomain
|
|
57
|
-
if (!gitHostName) {
|
|
58
|
-
return
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const gitHostInfo = gitHosts[gitHostShortcut || gitHostDomain]
|
|
62
|
-
let auth = null
|
|
63
|
-
if (authProtocols[parsed.protocol] && (parsed.username || parsed.password)) {
|
|
64
|
-
auth = `${parsed.username}${parsed.password ? ':' + parsed.password : ''}`
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
let committish = null
|
|
68
|
-
let user = null
|
|
69
|
-
let project = null
|
|
70
|
-
let defaultRepresentation = null
|
|
71
|
-
|
|
72
|
-
try {
|
|
73
|
-
if (gitHostShortcut) {
|
|
74
|
-
let pathname = parsed.pathname.startsWith('/') ? parsed.pathname.slice(1) : parsed.pathname
|
|
75
|
-
const firstAt = pathname.indexOf('@')
|
|
76
|
-
// we ignore auth for shortcuts, so just trim it out
|
|
77
|
-
if (firstAt > -1) {
|
|
78
|
-
pathname = pathname.slice(firstAt + 1)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const lastSlash = pathname.lastIndexOf('/')
|
|
82
|
-
if (lastSlash > -1) {
|
|
83
|
-
user = decodeURIComponent(pathname.slice(0, lastSlash))
|
|
84
|
-
// we want nulls only, never empty strings
|
|
85
|
-
if (!user) {
|
|
86
|
-
user = null
|
|
87
|
-
}
|
|
88
|
-
project = decodeURIComponent(pathname.slice(lastSlash + 1))
|
|
89
|
-
} else {
|
|
90
|
-
project = decodeURIComponent(pathname)
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
if (project.endsWith('.git')) {
|
|
94
|
-
project = project.slice(0, -4)
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
if (parsed.hash) {
|
|
98
|
-
committish = decodeURIComponent(parsed.hash.slice(1))
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
defaultRepresentation = 'shortcut'
|
|
102
|
-
} else {
|
|
103
|
-
if (!gitHostInfo.protocols.includes(parsed.protocol)) {
|
|
104
|
-
return
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const segments = gitHostInfo.extract(parsed)
|
|
108
|
-
if (!segments) {
|
|
109
|
-
return
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
user = segments.user && decodeURIComponent(segments.user)
|
|
113
|
-
project = decodeURIComponent(segments.project)
|
|
114
|
-
committish = decodeURIComponent(segments.committish)
|
|
115
|
-
defaultRepresentation = protocolToRepresentation(parsed.protocol)
|
|
116
|
-
}
|
|
117
|
-
} catch (err) {
|
|
118
|
-
/* istanbul ignore else */
|
|
119
|
-
if (err instanceof URIError) {
|
|
120
|
-
return
|
|
121
|
-
} else {
|
|
122
|
-
throw err
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return new GitHost(gitHostName, user, auth, project, committish, defaultRepresentation, opts)
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// accepts input like git:github.com:user/repo and inserts the // after the first :
|
|
130
|
-
const correctProtocol = (arg) => {
|
|
131
|
-
const firstColon = arg.indexOf(':')
|
|
132
|
-
const proto = arg.slice(0, firstColon + 1)
|
|
133
|
-
if (knownProtocols.includes(proto)) {
|
|
134
|
-
return arg
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
const firstAt = arg.indexOf('@')
|
|
138
|
-
if (firstAt > -1) {
|
|
139
|
-
if (firstAt > firstColon) {
|
|
140
|
-
return `git+ssh://${arg}`
|
|
141
|
-
} else {
|
|
142
|
-
return arg
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
const doubleSlash = arg.indexOf('//')
|
|
147
|
-
if (doubleSlash === firstColon + 1) {
|
|
148
|
-
return arg
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return arg.slice(0, firstColon + 1) + '//' + arg.slice(firstColon + 1)
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// look for github shorthand inputs, such as npm/cli
|
|
155
|
-
const isGitHubShorthand = (arg) => {
|
|
156
|
-
// it cannot contain whitespace before the first #
|
|
157
|
-
// it cannot start with a / because that's probably an absolute file path
|
|
158
|
-
// but it must include a slash since repos are username/repository
|
|
159
|
-
// it cannot start with a . because that's probably a relative file path
|
|
160
|
-
// it cannot start with an @ because that's a scoped package if it passes the other tests
|
|
161
|
-
// it cannot contain a : before a # because that tells us that there's a protocol
|
|
162
|
-
// a second / may not exist before a #
|
|
163
|
-
const firstHash = arg.indexOf('#')
|
|
164
|
-
const firstSlash = arg.indexOf('/')
|
|
165
|
-
const secondSlash = arg.indexOf('/', firstSlash + 1)
|
|
166
|
-
const firstColon = arg.indexOf(':')
|
|
167
|
-
const firstSpace = /\s/.exec(arg)
|
|
168
|
-
const firstAt = arg.indexOf('@')
|
|
169
|
-
|
|
170
|
-
const spaceOnlyAfterHash = !firstSpace || (firstHash > -1 && firstSpace.index > firstHash)
|
|
171
|
-
const atOnlyAfterHash = firstAt === -1 || (firstHash > -1 && firstAt > firstHash)
|
|
172
|
-
const colonOnlyAfterHash = firstColon === -1 || (firstHash > -1 && firstColon > firstHash)
|
|
173
|
-
const secondSlashOnlyAfterHash = secondSlash === -1 || (firstHash > -1 && secondSlash > firstHash)
|
|
174
|
-
const hasSlash = firstSlash > 0
|
|
175
|
-
// if a # is found, what we really want to know is that the character immediately before # is not a /
|
|
176
|
-
const doesNotEndWithSlash = firstHash > -1 ? arg[firstHash - 1] !== '/' : !arg.endsWith('/')
|
|
177
|
-
const doesNotStartWithDot = !arg.startsWith('.')
|
|
178
|
-
|
|
179
|
-
return spaceOnlyAfterHash && hasSlash && doesNotEndWithSlash && doesNotStartWithDot && atOnlyAfterHash && colonOnlyAfterHash && secondSlashOnlyAfterHash
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
// attempt to correct an scp style url so that it will parse with `new URL()`
|
|
183
|
-
const correctUrl = (giturl) => {
|
|
184
|
-
const firstAt = giturl.indexOf('@')
|
|
185
|
-
const lastHash = giturl.lastIndexOf('#')
|
|
186
|
-
let firstColon = giturl.indexOf(':')
|
|
187
|
-
let lastColon = giturl.lastIndexOf(':', lastHash > -1 ? lastHash : Infinity)
|
|
188
|
-
|
|
189
|
-
let corrected
|
|
190
|
-
if (lastColon > firstAt) {
|
|
191
|
-
// the last : comes after the first @ (or there is no @)
|
|
192
|
-
// like it would in:
|
|
193
|
-
// proto://hostname.com:user/repo
|
|
194
|
-
// username@hostname.com:user/repo
|
|
195
|
-
// :password@hostname.com:user/repo
|
|
196
|
-
// username:password@hostname.com:user/repo
|
|
197
|
-
// proto://username@hostname.com:user/repo
|
|
198
|
-
// proto://:password@hostname.com:user/repo
|
|
199
|
-
// proto://username:password@hostname.com:user/repo
|
|
200
|
-
// then we replace the last : with a / to create a valid path
|
|
201
|
-
corrected = giturl.slice(0, lastColon) + '/' + giturl.slice(lastColon + 1)
|
|
202
|
-
// // and we find our new : positions
|
|
203
|
-
firstColon = corrected.indexOf(':')
|
|
204
|
-
lastColon = corrected.lastIndexOf(':')
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
if (firstColon === -1 && giturl.indexOf('//') === -1) {
|
|
208
|
-
// we have no : at all
|
|
209
|
-
// as it would be in:
|
|
210
|
-
// username@hostname.com/user/repo
|
|
211
|
-
// then we prepend a protocol
|
|
212
|
-
corrected = `git+ssh://${corrected}`
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
return corrected
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
// try to parse the url as its given to us, if that throws
|
|
219
|
-
// then we try to clean the url and parse that result instead
|
|
220
|
-
// THIS FUNCTION SHOULD NEVER THROW
|
|
221
|
-
const parseGitUrl = (giturl) => {
|
|
222
|
-
let result
|
|
223
|
-
try {
|
|
224
|
-
result = new url.URL(giturl)
|
|
225
|
-
} catch (err) {}
|
|
226
|
-
|
|
227
|
-
if (result) {
|
|
228
|
-
return result
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
const correctedUrl = correctUrl(giturl)
|
|
232
|
-
try {
|
|
233
|
-
result = new url.URL(correctedUrl)
|
|
234
|
-
} catch (err) {}
|
|
235
|
-
|
|
236
|
-
return result
|
|
237
|
-
}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "hosted-git-info",
|
|
3
|
-
"version": "4.1.0",
|
|
4
|
-
"description": "Provides metadata and conversions from repository urls for GitHub, Bitbucket and GitLab",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"repository": {
|
|
7
|
-
"type": "git",
|
|
8
|
-
"url": "git+https://github.com/npm/hosted-git-info.git"
|
|
9
|
-
},
|
|
10
|
-
"keywords": [
|
|
11
|
-
"git",
|
|
12
|
-
"github",
|
|
13
|
-
"bitbucket",
|
|
14
|
-
"gitlab"
|
|
15
|
-
],
|
|
16
|
-
"author": "Rebecca Turner <me@re-becca.org> (http://re-becca.org)",
|
|
17
|
-
"license": "ISC",
|
|
18
|
-
"bugs": {
|
|
19
|
-
"url": "https://github.com/npm/hosted-git-info/issues"
|
|
20
|
-
},
|
|
21
|
-
"homepage": "https://github.com/npm/hosted-git-info",
|
|
22
|
-
"scripts": {
|
|
23
|
-
"posttest": "standard",
|
|
24
|
-
"postversion": "npm publish",
|
|
25
|
-
"prepublishOnly": "git push origin --follow-tags",
|
|
26
|
-
"preversion": "npm test",
|
|
27
|
-
"snap": "tap",
|
|
28
|
-
"test": "tap",
|
|
29
|
-
"test:coverage": "tap --coverage-report=html"
|
|
30
|
-
},
|
|
31
|
-
"dependencies": {
|
|
32
|
-
"lru-cache": "^6.0.0"
|
|
33
|
-
},
|
|
34
|
-
"devDependencies": {
|
|
35
|
-
"standard": "^16.0.3",
|
|
36
|
-
"standard-version": "^9.1.0",
|
|
37
|
-
"tap": "^15.1.6"
|
|
38
|
-
},
|
|
39
|
-
"files": [
|
|
40
|
-
"index.js",
|
|
41
|
-
"git-host.js",
|
|
42
|
-
"git-host-info.js"
|
|
43
|
-
],
|
|
44
|
-
"engines": {
|
|
45
|
-
"node": ">=10"
|
|
46
|
-
},
|
|
47
|
-
"tap": {
|
|
48
|
-
"color": 1,
|
|
49
|
-
"coverage": true
|
|
50
|
-
}
|
|
51
|
-
}
|
|
@@ -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
|
-
[](https://travis-ci.org/isaacs/node-lru-cache) [](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
|