fortify2-js
Version:
MOST POWERFUL JavaScript Security Library! Military-grade cryptography + 19 enhanced object methods + quantum-resistant algorithms + perfect TypeScript support. More powerful than Lodash with built-in security.
52 lines (49 loc) • 1.77 kB
JavaScript
;
/**
* Global type definitions for FortifyJS
*
* This file contains polyfills and type definitions for modern JavaScript features
* that may not be available in all environments.
*/
/**
* Runtime polyfills for WeakRef and FinalizationRegistry
*/
function initializePolyfills() {
// Check if WeakRef is available
if (typeof globalThis.WeakRef === "undefined") {
// Simple polyfill for WeakRef
globalThis.WeakRef = class WeakRef {
constructor(target) {
this.target = target;
}
deref() {
return this.target;
}
};
}
// Check if FinalizationRegistry is available
if (typeof globalThis.FinalizationRegistry === "undefined") {
// Simple polyfill for FinalizationRegistry
globalThis.FinalizationRegistry = class FinalizationRegistry {
constructor(cleanupCallback) {
this.registrations = new Map();
this.cleanupCallback = cleanupCallback;
}
register(target, heldValue, unregisterToken) {
this.registrations.set(target, heldValue);
// Simple timeout-based cleanup (not perfect but better than nothing)
setTimeout(() => {
if (this.registrations.has(target)) {
this.cleanupCallback(heldValue);
this.registrations.delete(target);
}
}, 30000); // 30 seconds
}
unregister(unregisterToken) {
return this.registrations.delete(unregisterToken);
}
};
}
}
exports.initializePolyfills = initializePolyfills;
//# sourceMappingURL=global.js.map