deployable-awscdk-app-ts 0.1.383 → 0.1.384

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.
@@ -1,334 +0,0 @@
1
- 'use strict'
2
-
3
- // A linked list to keep track of recently-used-ness
4
- const Yallist = require('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
- const max = 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
- }
257
- }
258
-
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
- module.exports = LRUCache
@@ -1,34 +0,0 @@
1
- {
2
- "name": "lru-cache",
3
- "description": "A cache object that deletes the least-recently-used items.",
4
- "version": "6.0.0",
5
- "author": "Isaac Z. Schlueter <i@izs.me>",
6
- "keywords": [
7
- "mru",
8
- "lru",
9
- "cache"
10
- ],
11
- "scripts": {
12
- "test": "tap",
13
- "snap": "tap",
14
- "preversion": "npm test",
15
- "postversion": "npm publish",
16
- "prepublishOnly": "git push origin --follow-tags"
17
- },
18
- "main": "index.js",
19
- "repository": "git://github.com/isaacs/node-lru-cache.git",
20
- "devDependencies": {
21
- "benchmark": "^2.1.4",
22
- "tap": "^14.10.7"
23
- },
24
- "license": "ISC",
25
- "dependencies": {
26
- "yallist": "^4.0.0"
27
- },
28
- "files": [
29
- "index.js"
30
- ],
31
- "engines": {
32
- "node": ">=10"
33
- }
34
- }
@@ -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,204 +0,0 @@
1
- # yallist
2
-
3
- Yet Another Linked List
4
-
5
- There are many doubly-linked list implementations like it, but this
6
- one is mine.
7
-
8
- For when an array would be too big, and a Map can't be iterated in
9
- reverse order.
10
-
11
-
12
- [![Build Status](https://travis-ci.org/isaacs/yallist.svg?branch=master)](https://travis-ci.org/isaacs/yallist) [![Coverage Status](https://coveralls.io/repos/isaacs/yallist/badge.svg?service=github)](https://coveralls.io/github/isaacs/yallist)
13
-
14
- ## basic usage
15
-
16
- ```javascript
17
- var yallist = require('yallist')
18
- var myList = yallist.create([1, 2, 3])
19
- myList.push('foo')
20
- myList.unshift('bar')
21
- // of course pop() and shift() are there, too
22
- console.log(myList.toArray()) // ['bar', 1, 2, 3, 'foo']
23
- myList.forEach(function (k) {
24
- // walk the list head to tail
25
- })
26
- myList.forEachReverse(function (k, index, list) {
27
- // walk the list tail to head
28
- })
29
- var myDoubledList = myList.map(function (k) {
30
- return k + k
31
- })
32
- // now myDoubledList contains ['barbar', 2, 4, 6, 'foofoo']
33
- // mapReverse is also a thing
34
- var myDoubledListReverse = myList.mapReverse(function (k) {
35
- return k + k
36
- }) // ['foofoo', 6, 4, 2, 'barbar']
37
-
38
- var reduced = myList.reduce(function (set, entry) {
39
- set += entry
40
- return set
41
- }, 'start')
42
- console.log(reduced) // 'startfoo123bar'
43
- ```
44
-
45
- ## api
46
-
47
- The whole API is considered "public".
48
-
49
- Functions with the same name as an Array method work more or less the
50
- same way.
51
-
52
- There's reverse versions of most things because that's the point.
53
-
54
- ### Yallist
55
-
56
- Default export, the class that holds and manages a list.
57
-
58
- Call it with either a forEach-able (like an array) or a set of
59
- arguments, to initialize the list.
60
-
61
- The Array-ish methods all act like you'd expect. No magic length,
62
- though, so if you change that it won't automatically prune or add
63
- empty spots.
64
-
65
- ### Yallist.create(..)
66
-
67
- Alias for Yallist function. Some people like factories.
68
-
69
- #### yallist.head
70
-
71
- The first node in the list
72
-
73
- #### yallist.tail
74
-
75
- The last node in the list
76
-
77
- #### yallist.length
78
-
79
- The number of nodes in the list. (Change this at your peril. It is
80
- not magic like Array length.)
81
-
82
- #### yallist.toArray()
83
-
84
- Convert the list to an array.
85
-
86
- #### yallist.forEach(fn, [thisp])
87
-
88
- Call a function on each item in the list.
89
-
90
- #### yallist.forEachReverse(fn, [thisp])
91
-
92
- Call a function on each item in the list, in reverse order.
93
-
94
- #### yallist.get(n)
95
-
96
- Get the data at position `n` in the list. If you use this a lot,
97
- probably better off just using an Array.
98
-
99
- #### yallist.getReverse(n)
100
-
101
- Get the data at position `n`, counting from the tail.
102
-
103
- #### yallist.map(fn, thisp)
104
-
105
- Create a new Yallist with the result of calling the function on each
106
- item.
107
-
108
- #### yallist.mapReverse(fn, thisp)
109
-
110
- Same as `map`, but in reverse.
111
-
112
- #### yallist.pop()
113
-
114
- Get the data from the list tail, and remove the tail from the list.
115
-
116
- #### yallist.push(item, ...)
117
-
118
- Insert one or more items to the tail of the list.
119
-
120
- #### yallist.reduce(fn, initialValue)
121
-
122
- Like Array.reduce.
123
-
124
- #### yallist.reduceReverse
125
-
126
- Like Array.reduce, but in reverse.
127
-
128
- #### yallist.reverse
129
-
130
- Reverse the list in place.
131
-
132
- #### yallist.shift()
133
-
134
- Get the data from the list head, and remove the head from the list.
135
-
136
- #### yallist.slice([from], [to])
137
-
138
- Just like Array.slice, but returns a new Yallist.
139
-
140
- #### yallist.sliceReverse([from], [to])
141
-
142
- Just like yallist.slice, but the result is returned in reverse.
143
-
144
- #### yallist.toArray()
145
-
146
- Create an array representation of the list.
147
-
148
- #### yallist.toArrayReverse()
149
-
150
- Create a reversed array representation of the list.
151
-
152
- #### yallist.unshift(item, ...)
153
-
154
- Insert one or more items to the head of the list.
155
-
156
- #### yallist.unshiftNode(node)
157
-
158
- Move a Node object to the front of the list. (That is, pull it out of
159
- wherever it lives, and make it the new head.)
160
-
161
- If the node belongs to a different list, then that list will remove it
162
- first.
163
-
164
- #### yallist.pushNode(node)
165
-
166
- Move a Node object to the end of the list. (That is, pull it out of
167
- wherever it lives, and make it the new tail.)
168
-
169
- If the node belongs to a list already, then that list will remove it
170
- first.
171
-
172
- #### yallist.removeNode(node)
173
-
174
- Remove a node from the list, preserving referential integrity of head
175
- and tail and other nodes.
176
-
177
- Will throw an error if you try to have a list remove a node that
178
- doesn't belong to it.
179
-
180
- ### Yallist.Node
181
-
182
- The class that holds the data and is actually the list.
183
-
184
- Call with `var n = new Node(value, previousNode, nextNode)`
185
-
186
- Note that if you do direct operations on Nodes themselves, it's very
187
- easy to get into weird states where the list is broken. Be careful :)
188
-
189
- #### node.next
190
-
191
- The next node in the list.
192
-
193
- #### node.prev
194
-
195
- The previous node in the list.
196
-
197
- #### node.value
198
-
199
- The data the node contains.
200
-
201
- #### node.list
202
-
203
- The list to which this node belongs. (Null if it does not belong to
204
- any list.)
@@ -1,8 +0,0 @@
1
- 'use strict'
2
- module.exports = function (Yallist) {
3
- Yallist.prototype[Symbol.iterator] = function* () {
4
- for (let walker = this.head; walker; walker = walker.next) {
5
- yield walker.value
6
- }
7
- }
8
- }
@@ -1,29 +0,0 @@
1
- {
2
- "name": "yallist",
3
- "version": "4.0.0",
4
- "description": "Yet Another Linked List",
5
- "main": "yallist.js",
6
- "directories": {
7
- "test": "test"
8
- },
9
- "files": [
10
- "yallist.js",
11
- "iterator.js"
12
- ],
13
- "dependencies": {},
14
- "devDependencies": {
15
- "tap": "^12.1.0"
16
- },
17
- "scripts": {
18
- "test": "tap test/*.js --100",
19
- "preversion": "npm test",
20
- "postversion": "npm publish",
21
- "postpublish": "git push origin --all; git push origin --tags"
22
- },
23
- "repository": {
24
- "type": "git",
25
- "url": "git+https://github.com/isaacs/yallist.git"
26
- },
27
- "author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
28
- "license": "ISC"
29
- }