Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Files
F9313957
memo.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
memo.js
View Options
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
/* eslint-disable @typescript-eslint/no-explicit-any */
/**
* Helper to decycle json objects
*/
export
function
memoBuilder
()
{
var
hasWeakSet
=
typeof
WeakSet
===
'function'
;
var
inner
=
hasWeakSet
?
new
WeakSet
()
:
[];
function
memoize
(
obj
)
{
if
(
hasWeakSet
)
{
if
(
inner
.
has
(
obj
))
{
return
true
;
}
inner
.
add
(
obj
);
return
false
;
}
// eslint-disable-next-line @typescript-eslint/prefer-for-of
for
(
var
i
=
0
;
i
<
inner
.
length
;
i
++
)
{
var
value
=
inner
[
i
];
if
(
value
===
obj
)
{
return
true
;
}
}
inner
.
push
(
obj
);
return
false
;
}
function
unmemoize
(
obj
)
{
if
(
hasWeakSet
)
{
inner
.
delete
(
obj
);
}
else
{
for
(
var
i
=
0
;
i
<
inner
.
length
;
i
++
)
{
if
(
inner
[
i
]
===
obj
)
{
inner
.
splice
(
i
,
1
);
break
;
}
}
}
}
return
[
memoize
,
unmemoize
];
}
//# sourceMappingURL=memo.js.map
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jul 3, 12:03 PM (2 d, 21 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3325142
Attached To
rDWAPPS Web applications
Event Timeline
Log In to Comment