
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
deca-memory-utils
Advanced tools
TypeScript utility library providing memory management tools like UniquePtr
A TypeScript utility library providing memory management tools like UniquePtr and SharedPtr for better control over object ownership and lifecycle.
npm install deca-memory-utils
This package is distributed as an ES Module (ESM). Make sure your project is configured to handle ESM:
// package.json
{
"type": "module"
}
If you're using TypeScript, ensure your tsconfig.json includes:
{
"compilerOptions": {
"module": "esnext",
"moduleResolution": "node"
}
}
import { UniquePtr } from 'deca-memory-utils';
// Create a new unique pointer
const ptr1 = new UniquePtr({ name: "John", data: [1, 2, 3] });
// Access the value
console.log(ptr1.get()); // { name: "John", data: [1, 2, 3] }
// Transfer ownership
const ptr2 = ptr1.move();
console.log(ptr1.get()); // null (ownership transferred)
console.log(ptr2.get()); // { name: "John", data: [1, 2, 3] }
// Reset with new value
ptr2.reset({ name: "Jane", data: [4, 5, 6] });
// Release ownership
const releasedValue = ptr2.release();
console.log(releasedValue); // { name: "Jane", data: [4, 5, 6] }
console.log(ptr2.get()); // null
import { SharedPtr, WeakPtr } from 'deca-memory-utils';
// Create a shared pointer with a destructor
const cleanup = (value: object) => console.log('Cleaning up:', value);
const shared1 = new SharedPtr({ data: "shared resource" }, cleanup);
// Create another reference to the same resource
const shared2 = SharedPtr.fromSharedPtr(shared1);
console.log(shared1.useCount()); // 2
// Create a weak reference
const weak1 = new WeakPtr(shared1);
// Access the value through weak reference
const locked = weak1.lock();
if (locked) {
console.log(locked.get()); // { data: "shared resource" }
}
// Reset first shared pointer
shared1.reset();
console.log(shared2.useCount()); // 1
// Resource is still alive through shared2
console.log(shared2.get()); // { data: "shared resource" }
// Reset second shared pointer
shared2.reset();
// Destructor is called, resource is cleaned up
// Weak reference is now expired
console.log(weak1.expired()); // true
constructor(value: T | null = null): Creates a new UniquePtr instanceget(): T | null: Access the underlying objectrelease(): T | null: Release ownership and return the objectreset(newValue: T | null = null): void: Reset with a new valuemove(): UniquePtr<T>: Transfer ownership to a new UniquePtrconstructor(value?: NonNullable<T>, destructor?: Destructor<T>): Creates a new SharedPtr instancemake<T>(value: NonNullable<T>, destructor?: Destructor<T>): SharedPtr<T>: Create a new SharedPtrfromSharedPtr<T>(other: SharedPtr<T>): SharedPtr<T>: Create a new SharedPtr from an existing oneget(): NonNullable<T> | null: Access the underlying objectgetRaw(): NonNullable<T> | null: Get the raw pointer valueisValid(): boolean: Check if the pointer is validuseCount(): number: Get the current reference countreset(value?: NonNullable<T>, destructor?: Destructor<T>): void: Reset with a new valueswap(other: SharedPtr<T>): void: Swap managed resources with another SharedPtrrelease(): NonNullable<T> | null: Release ownership without calling destructordestroy(): void: Destroy the shared pointer and decrement reference countconstructor(shared?: SharedPtr<T>): Creates a new WeakPtr instancelock(): SharedPtr<T> | null: Create a SharedPtr if resource is still validreset(): void: Reset the weak pointerexpired(): boolean: Check if the referenced resource has been cleaned updeca-memory-utils/
├── .gitignore
├── .npmignore
├── package.json
├── tsconfig.json
├── jest.config.cjs
├── README.md
├── LICENSE
├── src/
│ ├── index.ts
│ ├── unique-ptr.ts
│ └── shared-ptr.ts
├── tests/
│ ├── unique-ptr.test.ts
│ └── shared-ptr.test.ts
└── examples/
├── unique-ptr-usage.ts
└── shared-ptr-usage.ts
# Clone the repository
git clone https://github.com/yourusername/deca-memory-utils.git
cd deca-memory-utils
# Install dependencies
npm install
# Run tests (uses Node.js experimental modules support)
npm test
# Build
npm run build
# Lint
npm run lint
The project uses Jest with ts-jest for testing. The setup includes:
.test.ts extensiontests directoryTo run tests:
npm test
Contributions are welcome! Please feel free to submit a Pull Request.
git checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)This project follows Semantic Versioning. For the versions available, see the tags on this repository.
MIT
FAQs
TypeScript utility library providing memory management tools like UniquePtr
We found that deca-memory-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 0 open source maintainers 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
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.