deployable-awscdk-app-ts 0.1.206 → 0.1.208
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/.jsii +43 -22
- package/.projenrc.ts +3 -0
- package/API.md +16 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +18 -2
- package/lib/types.d.ts +8 -0
- package/lib/types.js +1 -1
- package/node_modules/semver/LICENSE +15 -0
- package/node_modules/semver/README.md +637 -0
- package/node_modules/semver/bin/semver.js +197 -0
- package/node_modules/semver/classes/comparator.js +141 -0
- package/node_modules/semver/classes/index.js +5 -0
- package/node_modules/semver/classes/range.js +539 -0
- package/node_modules/semver/classes/semver.js +302 -0
- package/node_modules/semver/functions/clean.js +6 -0
- package/node_modules/semver/functions/cmp.js +52 -0
- package/node_modules/semver/functions/coerce.js +52 -0
- package/node_modules/semver/functions/compare-build.js +7 -0
- package/node_modules/semver/functions/compare-loose.js +3 -0
- package/node_modules/semver/functions/compare.js +5 -0
- package/node_modules/semver/functions/diff.js +65 -0
- package/node_modules/semver/functions/eq.js +3 -0
- package/node_modules/semver/functions/gt.js +3 -0
- package/node_modules/semver/functions/gte.js +3 -0
- package/node_modules/semver/functions/inc.js +19 -0
- package/node_modules/semver/functions/lt.js +3 -0
- package/node_modules/semver/functions/lte.js +3 -0
- package/node_modules/semver/functions/major.js +3 -0
- package/node_modules/semver/functions/minor.js +3 -0
- package/node_modules/semver/functions/neq.js +3 -0
- package/node_modules/semver/functions/parse.js +16 -0
- package/node_modules/semver/functions/patch.js +3 -0
- package/node_modules/semver/functions/prerelease.js +6 -0
- package/node_modules/semver/functions/rcompare.js +3 -0
- package/node_modules/semver/functions/rsort.js +3 -0
- package/node_modules/semver/functions/satisfies.js +10 -0
- package/node_modules/semver/functions/sort.js +3 -0
- package/node_modules/semver/functions/valid.js +6 -0
- package/node_modules/semver/index.js +89 -0
- package/node_modules/semver/internal/constants.js +35 -0
- package/node_modules/semver/internal/debug.js +9 -0
- package/node_modules/semver/internal/identifiers.js +23 -0
- package/node_modules/semver/internal/parse-options.js +15 -0
- package/node_modules/semver/internal/re.js +212 -0
- package/node_modules/semver/node_modules/lru-cache/LICENSE +15 -0
- package/node_modules/semver/node_modules/lru-cache/README.md +166 -0
- package/node_modules/semver/node_modules/lru-cache/index.js +334 -0
- package/node_modules/semver/node_modules/lru-cache/package.json +34 -0
- package/node_modules/semver/node_modules/yallist/LICENSE +15 -0
- package/node_modules/semver/node_modules/yallist/README.md +204 -0
- package/node_modules/semver/node_modules/yallist/iterator.js +8 -0
- package/node_modules/semver/node_modules/yallist/package.json +29 -0
- package/node_modules/semver/node_modules/yallist/yallist.js +426 -0
- package/node_modules/semver/package.json +87 -0
- package/node_modules/semver/preload.js +2 -0
- package/node_modules/semver/range.bnf +16 -0
- package/node_modules/semver/ranges/gtr.js +4 -0
- package/node_modules/semver/ranges/intersects.js +7 -0
- package/node_modules/semver/ranges/ltr.js +4 -0
- package/node_modules/semver/ranges/max-satisfying.js +25 -0
- package/node_modules/semver/ranges/min-satisfying.js +24 -0
- package/node_modules/semver/ranges/min-version.js +61 -0
- package/node_modules/semver/ranges/outside.js +80 -0
- package/node_modules/semver/ranges/simplify.js +47 -0
- package/node_modules/semver/ranges/subset.js +247 -0
- package/node_modules/semver/ranges/to-comparators.js +8 -0
- package/node_modules/semver/ranges/valid.js +11 -0
- package/package.json +7 -3
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// just pre-load all the stuff that index.js lazily exports
|
|
2
|
+
const internalRe = require('./internal/re')
|
|
3
|
+
const constants = require('./internal/constants')
|
|
4
|
+
const SemVer = require('./classes/semver')
|
|
5
|
+
const identifiers = require('./internal/identifiers')
|
|
6
|
+
const parse = require('./functions/parse')
|
|
7
|
+
const valid = require('./functions/valid')
|
|
8
|
+
const clean = require('./functions/clean')
|
|
9
|
+
const inc = require('./functions/inc')
|
|
10
|
+
const diff = require('./functions/diff')
|
|
11
|
+
const major = require('./functions/major')
|
|
12
|
+
const minor = require('./functions/minor')
|
|
13
|
+
const patch = require('./functions/patch')
|
|
14
|
+
const prerelease = require('./functions/prerelease')
|
|
15
|
+
const compare = require('./functions/compare')
|
|
16
|
+
const rcompare = require('./functions/rcompare')
|
|
17
|
+
const compareLoose = require('./functions/compare-loose')
|
|
18
|
+
const compareBuild = require('./functions/compare-build')
|
|
19
|
+
const sort = require('./functions/sort')
|
|
20
|
+
const rsort = require('./functions/rsort')
|
|
21
|
+
const gt = require('./functions/gt')
|
|
22
|
+
const lt = require('./functions/lt')
|
|
23
|
+
const eq = require('./functions/eq')
|
|
24
|
+
const neq = require('./functions/neq')
|
|
25
|
+
const gte = require('./functions/gte')
|
|
26
|
+
const lte = require('./functions/lte')
|
|
27
|
+
const cmp = require('./functions/cmp')
|
|
28
|
+
const coerce = require('./functions/coerce')
|
|
29
|
+
const Comparator = require('./classes/comparator')
|
|
30
|
+
const Range = require('./classes/range')
|
|
31
|
+
const satisfies = require('./functions/satisfies')
|
|
32
|
+
const toComparators = require('./ranges/to-comparators')
|
|
33
|
+
const maxSatisfying = require('./ranges/max-satisfying')
|
|
34
|
+
const minSatisfying = require('./ranges/min-satisfying')
|
|
35
|
+
const minVersion = require('./ranges/min-version')
|
|
36
|
+
const validRange = require('./ranges/valid')
|
|
37
|
+
const outside = require('./ranges/outside')
|
|
38
|
+
const gtr = require('./ranges/gtr')
|
|
39
|
+
const ltr = require('./ranges/ltr')
|
|
40
|
+
const intersects = require('./ranges/intersects')
|
|
41
|
+
const simplifyRange = require('./ranges/simplify')
|
|
42
|
+
const subset = require('./ranges/subset')
|
|
43
|
+
module.exports = {
|
|
44
|
+
parse,
|
|
45
|
+
valid,
|
|
46
|
+
clean,
|
|
47
|
+
inc,
|
|
48
|
+
diff,
|
|
49
|
+
major,
|
|
50
|
+
minor,
|
|
51
|
+
patch,
|
|
52
|
+
prerelease,
|
|
53
|
+
compare,
|
|
54
|
+
rcompare,
|
|
55
|
+
compareLoose,
|
|
56
|
+
compareBuild,
|
|
57
|
+
sort,
|
|
58
|
+
rsort,
|
|
59
|
+
gt,
|
|
60
|
+
lt,
|
|
61
|
+
eq,
|
|
62
|
+
neq,
|
|
63
|
+
gte,
|
|
64
|
+
lte,
|
|
65
|
+
cmp,
|
|
66
|
+
coerce,
|
|
67
|
+
Comparator,
|
|
68
|
+
Range,
|
|
69
|
+
satisfies,
|
|
70
|
+
toComparators,
|
|
71
|
+
maxSatisfying,
|
|
72
|
+
minSatisfying,
|
|
73
|
+
minVersion,
|
|
74
|
+
validRange,
|
|
75
|
+
outside,
|
|
76
|
+
gtr,
|
|
77
|
+
ltr,
|
|
78
|
+
intersects,
|
|
79
|
+
simplifyRange,
|
|
80
|
+
subset,
|
|
81
|
+
SemVer,
|
|
82
|
+
re: internalRe.re,
|
|
83
|
+
src: internalRe.src,
|
|
84
|
+
tokens: internalRe.t,
|
|
85
|
+
SEMVER_SPEC_VERSION: constants.SEMVER_SPEC_VERSION,
|
|
86
|
+
RELEASE_TYPES: constants.RELEASE_TYPES,
|
|
87
|
+
compareIdentifiers: identifiers.compareIdentifiers,
|
|
88
|
+
rcompareIdentifiers: identifiers.rcompareIdentifiers,
|
|
89
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
// Note: this is the semver.org version of the spec that it implements
|
|
2
|
+
// Not necessarily the package version of this code.
|
|
3
|
+
const SEMVER_SPEC_VERSION = '2.0.0'
|
|
4
|
+
|
|
5
|
+
const MAX_LENGTH = 256
|
|
6
|
+
const MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER ||
|
|
7
|
+
/* istanbul ignore next */ 9007199254740991
|
|
8
|
+
|
|
9
|
+
// Max safe segment length for coercion.
|
|
10
|
+
const MAX_SAFE_COMPONENT_LENGTH = 16
|
|
11
|
+
|
|
12
|
+
// Max safe length for a build identifier. The max length minus 6 characters for
|
|
13
|
+
// the shortest version with a build 0.0.0+BUILD.
|
|
14
|
+
const MAX_SAFE_BUILD_LENGTH = MAX_LENGTH - 6
|
|
15
|
+
|
|
16
|
+
const RELEASE_TYPES = [
|
|
17
|
+
'major',
|
|
18
|
+
'premajor',
|
|
19
|
+
'minor',
|
|
20
|
+
'preminor',
|
|
21
|
+
'patch',
|
|
22
|
+
'prepatch',
|
|
23
|
+
'prerelease',
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
module.exports = {
|
|
27
|
+
MAX_LENGTH,
|
|
28
|
+
MAX_SAFE_COMPONENT_LENGTH,
|
|
29
|
+
MAX_SAFE_BUILD_LENGTH,
|
|
30
|
+
MAX_SAFE_INTEGER,
|
|
31
|
+
RELEASE_TYPES,
|
|
32
|
+
SEMVER_SPEC_VERSION,
|
|
33
|
+
FLAG_INCLUDE_PRERELEASE: 0b001,
|
|
34
|
+
FLAG_LOOSE: 0b010,
|
|
35
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const numeric = /^[0-9]+$/
|
|
2
|
+
const compareIdentifiers = (a, b) => {
|
|
3
|
+
const anum = numeric.test(a)
|
|
4
|
+
const bnum = numeric.test(b)
|
|
5
|
+
|
|
6
|
+
if (anum && bnum) {
|
|
7
|
+
a = +a
|
|
8
|
+
b = +b
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return a === b ? 0
|
|
12
|
+
: (anum && !bnum) ? -1
|
|
13
|
+
: (bnum && !anum) ? 1
|
|
14
|
+
: a < b ? -1
|
|
15
|
+
: 1
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const rcompareIdentifiers = (a, b) => compareIdentifiers(b, a)
|
|
19
|
+
|
|
20
|
+
module.exports = {
|
|
21
|
+
compareIdentifiers,
|
|
22
|
+
rcompareIdentifiers,
|
|
23
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// parse out just the options we care about
|
|
2
|
+
const looseOption = Object.freeze({ loose: true })
|
|
3
|
+
const emptyOpts = Object.freeze({ })
|
|
4
|
+
const parseOptions = options => {
|
|
5
|
+
if (!options) {
|
|
6
|
+
return emptyOpts
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
if (typeof options !== 'object') {
|
|
10
|
+
return looseOption
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return options
|
|
14
|
+
}
|
|
15
|
+
module.exports = parseOptions
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
const {
|
|
2
|
+
MAX_SAFE_COMPONENT_LENGTH,
|
|
3
|
+
MAX_SAFE_BUILD_LENGTH,
|
|
4
|
+
MAX_LENGTH,
|
|
5
|
+
} = require('./constants')
|
|
6
|
+
const debug = require('./debug')
|
|
7
|
+
exports = module.exports = {}
|
|
8
|
+
|
|
9
|
+
// The actual regexps go on exports.re
|
|
10
|
+
const re = exports.re = []
|
|
11
|
+
const safeRe = exports.safeRe = []
|
|
12
|
+
const src = exports.src = []
|
|
13
|
+
const t = exports.t = {}
|
|
14
|
+
let R = 0
|
|
15
|
+
|
|
16
|
+
const LETTERDASHNUMBER = '[a-zA-Z0-9-]'
|
|
17
|
+
|
|
18
|
+
// Replace some greedy regex tokens to prevent regex dos issues. These regex are
|
|
19
|
+
// used internally via the safeRe object since all inputs in this library get
|
|
20
|
+
// normalized first to trim and collapse all extra whitespace. The original
|
|
21
|
+
// regexes are exported for userland consumption and lower level usage. A
|
|
22
|
+
// future breaking change could export the safer regex only with a note that
|
|
23
|
+
// all input should have extra whitespace removed.
|
|
24
|
+
const safeRegexReplacements = [
|
|
25
|
+
['\\s', 1],
|
|
26
|
+
['\\d', MAX_LENGTH],
|
|
27
|
+
[LETTERDASHNUMBER, MAX_SAFE_BUILD_LENGTH],
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
const makeSafeRegex = (value) => {
|
|
31
|
+
for (const [token, max] of safeRegexReplacements) {
|
|
32
|
+
value = value
|
|
33
|
+
.split(`${token}*`).join(`${token}{0,${max}}`)
|
|
34
|
+
.split(`${token}+`).join(`${token}{1,${max}}`)
|
|
35
|
+
}
|
|
36
|
+
return value
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const createToken = (name, value, isGlobal) => {
|
|
40
|
+
const safe = makeSafeRegex(value)
|
|
41
|
+
const index = R++
|
|
42
|
+
debug(name, index, value)
|
|
43
|
+
t[name] = index
|
|
44
|
+
src[index] = value
|
|
45
|
+
re[index] = new RegExp(value, isGlobal ? 'g' : undefined)
|
|
46
|
+
safeRe[index] = new RegExp(safe, isGlobal ? 'g' : undefined)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// The following Regular Expressions can be used for tokenizing,
|
|
50
|
+
// validating, and parsing SemVer version strings.
|
|
51
|
+
|
|
52
|
+
// ## Numeric Identifier
|
|
53
|
+
// A single `0`, or a non-zero digit followed by zero or more digits.
|
|
54
|
+
|
|
55
|
+
createToken('NUMERICIDENTIFIER', '0|[1-9]\\d*')
|
|
56
|
+
createToken('NUMERICIDENTIFIERLOOSE', '\\d+')
|
|
57
|
+
|
|
58
|
+
// ## Non-numeric Identifier
|
|
59
|
+
// Zero or more digits, followed by a letter or hyphen, and then zero or
|
|
60
|
+
// more letters, digits, or hyphens.
|
|
61
|
+
|
|
62
|
+
createToken('NONNUMERICIDENTIFIER', `\\d*[a-zA-Z-]${LETTERDASHNUMBER}*`)
|
|
63
|
+
|
|
64
|
+
// ## Main Version
|
|
65
|
+
// Three dot-separated numeric identifiers.
|
|
66
|
+
|
|
67
|
+
createToken('MAINVERSION', `(${src[t.NUMERICIDENTIFIER]})\\.` +
|
|
68
|
+
`(${src[t.NUMERICIDENTIFIER]})\\.` +
|
|
69
|
+
`(${src[t.NUMERICIDENTIFIER]})`)
|
|
70
|
+
|
|
71
|
+
createToken('MAINVERSIONLOOSE', `(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
|
|
72
|
+
`(${src[t.NUMERICIDENTIFIERLOOSE]})\\.` +
|
|
73
|
+
`(${src[t.NUMERICIDENTIFIERLOOSE]})`)
|
|
74
|
+
|
|
75
|
+
// ## Pre-release Version Identifier
|
|
76
|
+
// A numeric identifier, or a non-numeric identifier.
|
|
77
|
+
|
|
78
|
+
createToken('PRERELEASEIDENTIFIER', `(?:${src[t.NUMERICIDENTIFIER]
|
|
79
|
+
}|${src[t.NONNUMERICIDENTIFIER]})`)
|
|
80
|
+
|
|
81
|
+
createToken('PRERELEASEIDENTIFIERLOOSE', `(?:${src[t.NUMERICIDENTIFIERLOOSE]
|
|
82
|
+
}|${src[t.NONNUMERICIDENTIFIER]})`)
|
|
83
|
+
|
|
84
|
+
// ## Pre-release Version
|
|
85
|
+
// Hyphen, followed by one or more dot-separated pre-release version
|
|
86
|
+
// identifiers.
|
|
87
|
+
|
|
88
|
+
createToken('PRERELEASE', `(?:-(${src[t.PRERELEASEIDENTIFIER]
|
|
89
|
+
}(?:\\.${src[t.PRERELEASEIDENTIFIER]})*))`)
|
|
90
|
+
|
|
91
|
+
createToken('PRERELEASELOOSE', `(?:-?(${src[t.PRERELEASEIDENTIFIERLOOSE]
|
|
92
|
+
}(?:\\.${src[t.PRERELEASEIDENTIFIERLOOSE]})*))`)
|
|
93
|
+
|
|
94
|
+
// ## Build Metadata Identifier
|
|
95
|
+
// Any combination of digits, letters, or hyphens.
|
|
96
|
+
|
|
97
|
+
createToken('BUILDIDENTIFIER', `${LETTERDASHNUMBER}+`)
|
|
98
|
+
|
|
99
|
+
// ## Build Metadata
|
|
100
|
+
// Plus sign, followed by one or more period-separated build metadata
|
|
101
|
+
// identifiers.
|
|
102
|
+
|
|
103
|
+
createToken('BUILD', `(?:\\+(${src[t.BUILDIDENTIFIER]
|
|
104
|
+
}(?:\\.${src[t.BUILDIDENTIFIER]})*))`)
|
|
105
|
+
|
|
106
|
+
// ## Full Version String
|
|
107
|
+
// A main version, followed optionally by a pre-release version and
|
|
108
|
+
// build metadata.
|
|
109
|
+
|
|
110
|
+
// Note that the only major, minor, patch, and pre-release sections of
|
|
111
|
+
// the version string are capturing groups. The build metadata is not a
|
|
112
|
+
// capturing group, because it should not ever be used in version
|
|
113
|
+
// comparison.
|
|
114
|
+
|
|
115
|
+
createToken('FULLPLAIN', `v?${src[t.MAINVERSION]
|
|
116
|
+
}${src[t.PRERELEASE]}?${
|
|
117
|
+
src[t.BUILD]}?`)
|
|
118
|
+
|
|
119
|
+
createToken('FULL', `^${src[t.FULLPLAIN]}$`)
|
|
120
|
+
|
|
121
|
+
// like full, but allows v1.2.3 and =1.2.3, which people do sometimes.
|
|
122
|
+
// also, 1.0.0alpha1 (prerelease without the hyphen) which is pretty
|
|
123
|
+
// common in the npm registry.
|
|
124
|
+
createToken('LOOSEPLAIN', `[v=\\s]*${src[t.MAINVERSIONLOOSE]
|
|
125
|
+
}${src[t.PRERELEASELOOSE]}?${
|
|
126
|
+
src[t.BUILD]}?`)
|
|
127
|
+
|
|
128
|
+
createToken('LOOSE', `^${src[t.LOOSEPLAIN]}$`)
|
|
129
|
+
|
|
130
|
+
createToken('GTLT', '((?:<|>)?=?)')
|
|
131
|
+
|
|
132
|
+
// Something like "2.*" or "1.2.x".
|
|
133
|
+
// Note that "x.x" is a valid xRange identifer, meaning "any version"
|
|
134
|
+
// Only the first item is strictly required.
|
|
135
|
+
createToken('XRANGEIDENTIFIERLOOSE', `${src[t.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`)
|
|
136
|
+
createToken('XRANGEIDENTIFIER', `${src[t.NUMERICIDENTIFIER]}|x|X|\\*`)
|
|
137
|
+
|
|
138
|
+
createToken('XRANGEPLAIN', `[v=\\s]*(${src[t.XRANGEIDENTIFIER]})` +
|
|
139
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
|
|
140
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIER]})` +
|
|
141
|
+
`(?:${src[t.PRERELEASE]})?${
|
|
142
|
+
src[t.BUILD]}?` +
|
|
143
|
+
`)?)?`)
|
|
144
|
+
|
|
145
|
+
createToken('XRANGEPLAINLOOSE', `[v=\\s]*(${src[t.XRANGEIDENTIFIERLOOSE]})` +
|
|
146
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
|
|
147
|
+
`(?:\\.(${src[t.XRANGEIDENTIFIERLOOSE]})` +
|
|
148
|
+
`(?:${src[t.PRERELEASELOOSE]})?${
|
|
149
|
+
src[t.BUILD]}?` +
|
|
150
|
+
`)?)?`)
|
|
151
|
+
|
|
152
|
+
createToken('XRANGE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAIN]}$`)
|
|
153
|
+
createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`)
|
|
154
|
+
|
|
155
|
+
// Coercion.
|
|
156
|
+
// Extract anything that could conceivably be a part of a valid semver
|
|
157
|
+
createToken('COERCE', `${'(^|[^\\d])' +
|
|
158
|
+
'(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` +
|
|
159
|
+
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
|
|
160
|
+
`(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` +
|
|
161
|
+
`(?:$|[^\\d])`)
|
|
162
|
+
createToken('COERCERTL', src[t.COERCE], true)
|
|
163
|
+
|
|
164
|
+
// Tilde ranges.
|
|
165
|
+
// Meaning is "reasonably at or greater than"
|
|
166
|
+
createToken('LONETILDE', '(?:~>?)')
|
|
167
|
+
|
|
168
|
+
createToken('TILDETRIM', `(\\s*)${src[t.LONETILDE]}\\s+`, true)
|
|
169
|
+
exports.tildeTrimReplace = '$1~'
|
|
170
|
+
|
|
171
|
+
createToken('TILDE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAIN]}$`)
|
|
172
|
+
createToken('TILDELOOSE', `^${src[t.LONETILDE]}${src[t.XRANGEPLAINLOOSE]}$`)
|
|
173
|
+
|
|
174
|
+
// Caret ranges.
|
|
175
|
+
// Meaning is "at least and backwards compatible with"
|
|
176
|
+
createToken('LONECARET', '(?:\\^)')
|
|
177
|
+
|
|
178
|
+
createToken('CARETTRIM', `(\\s*)${src[t.LONECARET]}\\s+`, true)
|
|
179
|
+
exports.caretTrimReplace = '$1^'
|
|
180
|
+
|
|
181
|
+
createToken('CARET', `^${src[t.LONECARET]}${src[t.XRANGEPLAIN]}$`)
|
|
182
|
+
createToken('CARETLOOSE', `^${src[t.LONECARET]}${src[t.XRANGEPLAINLOOSE]}$`)
|
|
183
|
+
|
|
184
|
+
// A simple gt/lt/eq thing, or just "" to indicate "any version"
|
|
185
|
+
createToken('COMPARATORLOOSE', `^${src[t.GTLT]}\\s*(${src[t.LOOSEPLAIN]})$|^$`)
|
|
186
|
+
createToken('COMPARATOR', `^${src[t.GTLT]}\\s*(${src[t.FULLPLAIN]})$|^$`)
|
|
187
|
+
|
|
188
|
+
// An expression to strip any whitespace between the gtlt and the thing
|
|
189
|
+
// it modifies, so that `> 1.2.3` ==> `>1.2.3`
|
|
190
|
+
createToken('COMPARATORTRIM', `(\\s*)${src[t.GTLT]
|
|
191
|
+
}\\s*(${src[t.LOOSEPLAIN]}|${src[t.XRANGEPLAIN]})`, true)
|
|
192
|
+
exports.comparatorTrimReplace = '$1$2$3'
|
|
193
|
+
|
|
194
|
+
// Something like `1.2.3 - 1.2.4`
|
|
195
|
+
// Note that these all use the loose form, because they'll be
|
|
196
|
+
// checked against either the strict or loose comparator form
|
|
197
|
+
// later.
|
|
198
|
+
createToken('HYPHENRANGE', `^\\s*(${src[t.XRANGEPLAIN]})` +
|
|
199
|
+
`\\s+-\\s+` +
|
|
200
|
+
`(${src[t.XRANGEPLAIN]})` +
|
|
201
|
+
`\\s*$`)
|
|
202
|
+
|
|
203
|
+
createToken('HYPHENRANGELOOSE', `^\\s*(${src[t.XRANGEPLAINLOOSE]})` +
|
|
204
|
+
`\\s+-\\s+` +
|
|
205
|
+
`(${src[t.XRANGEPLAINLOOSE]})` +
|
|
206
|
+
`\\s*$`)
|
|
207
|
+
|
|
208
|
+
// Star ranges basically just allow anything at all.
|
|
209
|
+
createToken('STAR', '(<|>)?=?\\s*\\*')
|
|
210
|
+
// >=0.0.0 is like a star
|
|
211
|
+
createToken('GTE0', '^\\s*>=\\s*0\\.0\\.0\\s*$')
|
|
212
|
+
createToken('GTE0PRE', '^\\s*>=\\s*0\\.0\\.0-0\\s*$')
|
|
@@ -0,0 +1,15 @@
|
|
|
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.
|
|
@@ -0,0 +1,166 @@
|
|
|
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
|