Security News
NIST Misses 2024 Deadline to Clear NVD Backlog
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
circularmemo
Advanced tools
A convenience function to recursively iterates over a (like typescript's types) with memoization and without breaking circular references.
It requires your function to expect itself as the first argument, and returns a similar function, you can then pass your function to a Y-combinator to get a "normal" function.
This package also provides a spreading Y combinator and the MFN
type for this kind of
self-passed function.
import { Y, circularmemo, MFN } from 'circularmemo'
interface Node {
n: number,
left: Node,
}
const circle: Node = { n: 1, left: { n: 2, left: (null as unknown as Node) } }
circle.left.left = circle
const _plusX: MFN<[Node, number], Node> = (self, x, n) =>
({ n: x.n + n, left: self(x.left, n) })
const plusX = Y(circularmemo({
circularMarker: (_) => ({} as Node), // leave an empty object, which will be
replaceMarker: (marker, res) => Object.assign(marker, res) // fill up the object
}, _plusX))
const result = plusX(circle, 1)
assert(result.n === 2)
assert(result.left.n === 3)
assert(result.left.left === result) // maintained circular
The first arguments to circularmemo
is a Param object which accepts
the following functions.
circularMarker: (...args: Args) => Marker,
replaceMarker: (tmp: Marker, final: Res) => Res
useMarker?: (tmp: Marker) => Res,
useExisting?: (existing: Res) => Res,
shouldMemo?: (...args: Args) => boolean,
keyMaker?: (...args: Args) => Key,
FAQs
Memoization function with support for circular references.
The npm package circularmemo receives a total of 1 weekly downloads. As such, circularmemo popularity was classified as not popular.
We found that circularmemo demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.
Security News
Cloudflare has launched a setup wizard allowing users to easily create and manage a security.txt file for vulnerability disclosure on their websites.
Security News
The Socket Research team breaks down a malicious npm package targeting the legitimate DOMPurify library. It uses obfuscated code to hide that it is exfiltrating browser and crypto wallet data.