Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
astro-wt
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
3a2d50c1
authored
2024-06-26 14:24:59 -0500
by
Adam Heath
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Switch from node-cache to @isaacs/ttlcache, which works in the browser.
1 parent
8a5e8d74
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
30 deletions
lib/cache.ts
lib/html.ts
package-lock.json
package.json
lib/cache.ts
View file @
3a2d50c
import
NodeCache
from
'node-
cache'
import
TTLCache
from
'@isaacs/ttl
cache'
export
const
selectorCache
=
new
NodeCache
({
stdTTL
:
10
*
60
,
useClones
:
false
,
export
const
selectorCache
=
new
TTLCache
({
ttl
:
10
*
60
,
})
export
const
parsedHtmlCache
=
new
NodeCache
({
stdTTL
:
10
*
60
,
useClones
:
false
,
export
const
parsedHtmlCache
=
new
TTLCache
({
ttl
:
10
*
60
,
})
export
const
findNodeCache
=
new
WeakMap
()
...
...
lib/html.ts
View file @
3a2d50c
import
nodeUtil
from
'util'
import
NodeCache
from
'node-
cache'
import
TTLCache
from
'@isaacs/ttl
cache'
import
type
{
NodeType
}
from
'ultrahtml'
import
{
...
...
@@ -319,7 +319,7 @@ export const findNode = (doc: NodeType, selector: string): NodeType => {
if
(
!
selector
)
return
doc
let
docCache
=
findNodeCache
.
get
(
doc
)
if
(
!
docCache
)
{
docCache
=
new
NodeCache
({
stdTTL
:
10
*
60
,
useClones
:
false
})
docCache
=
new
TTLCache
({
ttl
:
10
*
60
})
findNodeCache
.
set
(
doc
,
docCache
)
}
const
found
=
docCache
.
get
(
selector
)
...
...
package-lock.json
View file @
3a2d50c
...
...
@@ -6,8 +6,8 @@
""
:
{
"name"
:
"astro-wt"
,
"dependencies"
:
{
"@isaacs/ttlcache"
:
"^1.4.1"
,
"@reduxjs/toolkit"
:
"^2.2.5"
,
"node-cache"
:
"^5.1.2"
,
"parsel-js"
:
"^1.1.2"
,
"ultrahtml"
:
"^1.5.3"
},
...
...
@@ -1351,6 +1351,14 @@
"url"
:
"https://opencollective.com/libvips"
}
},
"node_modules/@isaacs/ttlcache"
:
{
"version"
:
"1.4.1"
,
"resolved"
:
"https://registry.npmjs.org/@isaacs/ttlcache/-/ttlcache-1.4.1.tgz"
,
"integrity"
:
"sha512-RQgQ4uQ+pLbqXfOmieB91ejmLwvSgv9nLx6sT6sD83s7umBypgg+OIBOBbEUiJXrfpnp9j0mRhYYdzp9uqq3lA=="
,
"engines"
:
{
"node"
:
">=12"
}
},
"node_modules/@jridgewell/gen-mapping"
:
{
"version"
:
"0.3.5"
,
"resolved"
:
"https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz"
,
...
...
@@ -2339,14 +2347,6 @@
"url"
:
"https://github.com/sponsors/sindresorhus"
}
},
"node_modules/clone"
:
{
"version"
:
"2.1.2"
,
"resolved"
:
"https://registry.npmjs.org/clone/-/clone-2.1.2.tgz"
,
"integrity"
:
"sha512-3Pe/CF1Nn94hyhIYpjtiLhdCoEoz0DqQ+988E9gmeEdQZlojxnOb74wctFyuwWQHzqyf9X7C7MG8juUpqBJT8w=="
,
"engines"
:
{
"node"
:
">=0.8"
}
},
"node_modules/clsx"
:
{
"version"
:
"2.1.1"
,
"resolved"
:
"https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz"
,
...
...
@@ -4575,17 +4575,6 @@
"url"
:
"https://opencollective.com/unified"
}
},
"node_modules/node-cache"
:
{
"version"
:
"5.1.2"
,
"resolved"
:
"https://registry.npmjs.org/node-cache/-/node-cache-5.1.2.tgz"
,
"integrity"
:
"sha512-t1QzWwnk4sjLWaQAS8CHgOJ+RAfmHpxFWmc36IWTiWHQfs0w5JDMBS1b1ZxQteo0vVVuWJvIUKHDkkeK7vIGCg=="
,
"dependencies"
:
{
"clone"
:
"2.x"
},
"engines"
:
{
"node"
:
">= 8.0.0"
}
},
"node_modules/node-releases"
:
{
"version"
:
"2.0.14"
,
"resolved"
:
"https://registry.npmjs.org/node-releases/-/node-releases-2.0.14.tgz"
,
...
...
package.json
View file @
3a2d50c
...
...
@@ -10,8 +10,8 @@
"dev"
:
"astro dev"
},
"dependencies"
:
{
"@isaacs/ttlcache"
:
"^1.4.1"
,
"@reduxjs/toolkit"
:
"^2.2.5"
,
"node-cache"
:
"^5.1.2"
,
"parsel-js"
:
"^1.1.2"
,
"ultrahtml"
:
"^1.5.3"
},
...
...
Please
register
or
sign in
to post a comment