{"_id":"@alwatr/lazy","_rev":"8-fb4cf79bd58e419c5330671caf1460fb","name":"@alwatr/lazy","dist-tags":{"latest":"10.2.0"},"versions":{"9.19.0":{"name":"@alwatr/lazy","version":"9.19.0","keywords":["alwatr","browser","cache","cross-platform","deferred","ECMAScript","esm","gc","javascript","lazy","lazy-evaluation","lazy-initialization","lazy-loading","memoize","memoization","module","nanolib","node","nodejs","performance","typescript","util","utility","utils"],"author":{"url":"https://ali.mihandoost.com","name":"S. Ali Mihandoost","email":"ali.mihandoost@gmail.com"},"license":"MPL-2.0","_id":"@alwatr/lazy@9.19.0","maintainers":[{"name":"alimd","email":"ali.mihan.doost@gmail.com"}],"homepage":"https://github.com/Alwatr/alwatr/tree/next/pkg/nanolib/lazy#readme","bugs":{"url":"https://github.com/Alwatr/alwatr/issues"},"dist":{"shasum":"7c87612ebdd4f9a5b444960833fee7f6e767451a","tarball":"https://registry.npmjs.org/@alwatr/lazy/-/lazy-9.19.0.tgz","fileCount":11,"integrity":"sha512-VGENNuSkJ+5vPK3ZeYXrJQh+0CvPTlBmpp/yIP6Srao/Gj2CQtlcESNi5cBKjNH36LJ7cpHYzePt9L+5Cio8dA==","signatures":[{"sig":"MEUCIQCWsY1u6DcC3t55C/iTkKSckGFAUekdxPLz0KDaoDqy7QIgdV0ZCjuXSRYQoz/QRadLrACBL2zLmPXldO1o4qWB71Y=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":40244},"type":"module","exports":{".":{"types":"./dist/main.d.ts","import":"./dist/main.js","default":"./dist/main.js"}},"gitHead":"20106a8e95925e2b6f895325afe1c7b7c263e2cc","scripts":{"b":"bun run build","t":"bun run test","w":"bun run watch","cl":"bun run clean","lint":"eslint src/ --ext .ts","test":"ALWATR_DEBUG=0 bun test","build":"bun run build:ts && bun run build:es","clean":"rm -rfv dist *.tsbuildinfo","watch":"bun run watch:ts & bun run watch:es","format":"prettier --write \"src/**/*.ts\"","build:es":"nano-build --preset=module src/main.ts","build:ts":"tsc --build","watch:es":"bun run build:es --watch","watch:ts":"bun run build:ts --watch --preserveWatchOutput"},"_npmUser":{"name":"alimd","email":"ali.mihan.doost@gmail.com"},"repository":{"url":"git+https://github.com/Alwatr/alwatr.git","type":"git","directory":"pkg/nanolib/lazy"},"_npmVersion":"lerna/5.2.0/node@v20.20.2+x64 (linux)","description":"A generic, memory-efficient lazy evaluation wrapper. Defers execution of expensive initializers until the value is first accessed, then caches the result and frees the closure reference for GC.","directories":{},"sideEffects":false,"_nodeVersion":"20.20.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^6.0.3","@alwatr/standard":"9.16.0","@alwatr/nano-build":"9.14.0"},"_npmOperationalInternal":{"tmp":"tmp/lazy_9.19.0_1777402486098_0.03647387745787012","host":"s3://npm-registry-packages-npm-production"}},"9.25.0":{"name":"@alwatr/lazy","version":"9.25.0","keywords":["alwatr","browser","cache","cross-platform","deferred","ECMAScript","esm","gc","javascript","lazy","lazy-evaluation","lazy-initialization","lazy-loading","memoize","memoization","module","nanolib","node","nodejs","performance","typescript","util","utility","utils"],"author":{"url":"https://ali.mihandoost.com","name":"S. Ali Mihandoost","email":"ali.mihandoost@gmail.com"},"license":"MPL-2.0","_id":"@alwatr/lazy@9.25.0","maintainers":[{"name":"alimd","email":"ali.mihan.doost@gmail.com"}],"homepage":"https://github.com/Alwatr/alwatr/tree/next/pkg/nanolib/lazy#readme","bugs":{"url":"https://github.com/Alwatr/alwatr/issues"},"dist":{"shasum":"bd58171807b7c85301fb72b62e9fb3cec335d557","tarball":"https://registry.npmjs.org/@alwatr/lazy/-/lazy-9.25.0.tgz","fileCount":11,"integrity":"sha512-hdKnwaUc3i4L5X8UbRP92oCwdvZs+HFfPc+PeJOq90YRlFF0FYyTEoEhUGzhqmC+Bp/zZfVlug0UrZnoonoS8w==","signatures":[{"sig":"MEUCIBy0niSG5D01BVkB6sYvZtIwMVChVmHJK5JeUknWv+Z9AiEAqVVuu9XH0K7+gV9JYVyg3VP/r4jJ09j6kAtYnt80Bsg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":40371},"type":"module","exports":{".":{"types":"./dist/main.d.ts","import":"./dist/main.js","default":"./dist/main.js"}},"gitHead":"a49ae304180faab79539b5ddfe62d18ac91a232e","scripts":{"b":"bun run build","t":"bun run test","w":"bun run watch","cl":"bun run clean","lint":"eslint src/ --ext .ts","test":"ALWATR_DEBUG=0 bun test","build":"bun run build:ts && bun run build:es","clean":"rm -rfv dist *.tsbuildinfo","watch":"bun run watch:ts & bun run watch:es","format":"prettier --write \"src/**/*.ts\"","build:es":"nano-build --preset=module src/main.ts","build:ts":"tsc --build","watch:es":"bun run build:es --watch","watch:ts":"bun run build:ts --watch --preserveWatchOutput"},"_npmUser":{"name":"alimd","email":"ali.mihan.doost@gmail.com"},"repository":{"url":"git+https://github.com/Alwatr/alwatr.git","type":"git","directory":"pkg/nanolib/lazy"},"_npmVersion":"lerna/5.2.1/node@v20.20.2+x64 (linux)","description":"A generic, memory-efficient lazy evaluation wrapper. Defers execution of expensive initializers until the value is first accessed, then caches the result and frees the closure reference for GC.","directories":{},"sideEffects":false,"_nodeVersion":"20.20.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^6.0.3","@alwatr/standard":"9.16.0","@alwatr/nano-build":"9.25.0"},"_npmOperationalInternal":{"tmp":"tmp/lazy_9.25.0_1779366166243_0.7956235714676076","host":"s3://npm-registry-packages-npm-production"}},"9.33.0":{"name":"@alwatr/lazy","version":"9.33.0","keywords":["alwatr","browser","cache","cross-platform","deferred","ECMAScript","esm","gc","javascript","lazy","lazy-evaluation","lazy-initialization","lazy-loading","memoize","memoization","module","nanolib","node","nodejs","performance","typescript","util","utility","utils"],"author":{"url":"https://ali.mihandoost.com","name":"S. Ali Mihandoost","email":"ali.mihandoost@gmail.com"},"license":"MPL-2.0","_id":"@alwatr/lazy@9.33.0","maintainers":[{"name":"alimd","email":"ali.mihan.doost@gmail.com"}],"homepage":"https://github.com/Alwatr/alwatr/tree/next/pkg/nanolib/lazy#readme","bugs":{"url":"https://github.com/Alwatr/alwatr/issues"},"dist":{"shasum":"f3c05b408962b6c00ce958030d48b10fed8ab755","tarball":"https://registry.npmjs.org/@alwatr/lazy/-/lazy-9.33.0.tgz","fileCount":11,"integrity":"sha512-VqROo/lUyKfZW/JquHEa1v2JgF3kKa5zmQNWEGT5vkvXX49PVzkSSGheB8oWc5d8eiBLBIAU/FOBrXKLZ6QdoA==","signatures":[{"sig":"MEYCIQCjoeTc37Z71l3VkgJ9F52b8P8yEhAHxej3XARquhf8CgIhAIQ2+ZkxhUc8C6LNCZOkMW63JanJPLoJp4OWI3cobv7i","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":40371},"type":"module","exports":{".":{"types":"./dist/main.d.ts","import":"./dist/main.js","default":"./dist/main.js"}},"gitHead":"ba7e63efa62c86c7845269f94c4cc9924c38ff21","scripts":{"b":"bun run build","t":"bun run test","w":"bun run watch","cl":"bun run clean","lint":"eslint src/ --ext .ts","test":"ALWATR_DEBUG=0 bun test","build":"bun run build:ts && bun run build:es","clean":"rm -rfv dist *.tsbuildinfo","watch":"bun run watch:ts & bun run watch:es","format":"prettier --write \"src/**/*.ts\"","build:es":"nano-build --preset=module src/main.ts","build:ts":"tsc --build","watch:es":"bun run build:es --watch","watch:ts":"bun run build:ts --watch --preserveWatchOutput"},"_npmUser":{"name":"alimd","email":"ali.mihan.doost@gmail.com"},"repository":{"url":"git+https://github.com/Alwatr/alwatr.git","type":"git","directory":"pkg/nanolib/lazy"},"_npmVersion":"lerna/5.3.0/node@v22.22.3+x64 (linux)","description":"A generic, memory-efficient lazy evaluation wrapper. Defers execution of expensive initializers until the value is first accessed, then caches the result and frees the closure reference for GC.","directories":{},"sideEffects":false,"_nodeVersion":"22.22.3","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^6.0.3","@alwatr/standard":"9.33.0","@alwatr/nano-build":"9.25.0"},"_npmOperationalInternal":{"tmp":"tmp/lazy_9.33.0_1781057071666_0.5186114507562294","host":"s3://npm-registry-packages-npm-production"}},"9.33.1":{"name":"@alwatr/lazy","version":"9.33.1","keywords":["alwatr","browser","cache","cross-platform","deferred","ECMAScript","esm","gc","javascript","lazy","lazy-evaluation","lazy-initialization","lazy-loading","memoize","memoization","module","nanolib","node","nodejs","performance","typescript","util","utility","utils"],"author":{"url":"https://ali.mihandoost.com","name":"S. Ali Mihandoost","email":"ali.mihandoost@gmail.com"},"license":"MPL-2.0","_id":"@alwatr/lazy@9.33.1","maintainers":[{"name":"alimd","email":"ali.mihan.doost@gmail.com"}],"homepage":"https://github.com/Alwatr/alwatr/tree/next/pkg/nanolib/lazy#readme","bugs":{"url":"https://github.com/Alwatr/alwatr/issues"},"dist":{"shasum":"d7f70df07074de2143f75209ada8e28a6d815fa7","tarball":"https://registry.npmjs.org/@alwatr/lazy/-/lazy-9.33.1.tgz","fileCount":13,"integrity":"sha512-ZReu+fQ7Z+0TeiLtZ3DunhKGhsBTAEX/OLF3wFLPF7iW3NOY4yc2cvqe1qO101dmjWePQFEKq/+egqfvkJeQfw==","signatures":[{"sig":"MEUCIQCocr3BynMs95QfJrda2hOsjaKwzBHU2kpM47GvaZQIhwIgCIxJRfIrPfwRYRkM8bo1GZ4t6WjvEGK00R1FfJYmpfg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":45427},"type":"module","exports":{".":{"types":"./dist/main.d.ts","import":"./dist/main.js","default":"./dist/main.js","development":"./dist/dev/main.js"}},"gitHead":"84fba5b7b428188be17aaaaf062b0b7eaae96555","scripts":{"b":"bun run build","t":"bun run test","w":"bun run watch","cl":"bun run clean","lint":"eslint src/ --ext .ts","test":"bun test","build":"bun run build:ts && bun run build:es","clean":"rm -rfv dist *.tsbuildinfo","watch":"bun run watch:ts & bun run watch:es","format":"prettier --write \"src/**/*.ts\"","build:es":"bun run build:es:dev && bun run build:es:prod","build:ts":"tsc --build","watch:es":"bun run build:es:dev --watch","watch:ts":"bun run build:ts --watch --preserveWatchOutput","build:es:dev":"nano-build --preset=module --outdir=dist/dev src/main.ts","build:es:prod":"NODE_ENV=production nano-build --preset=module --outdir=dist src/main.ts"},"_npmUser":{"name":"alimd","email":"ali.mihan.doost@gmail.com"},"repository":{"url":"git+https://github.com/Alwatr/alwatr.git","type":"git","directory":"pkg/nanolib/lazy"},"_npmVersion":"lerna/5.3.0/node@v22.22.3+x64 (linux)","description":"A generic, memory-efficient lazy evaluation wrapper. Defers execution of expensive initializers until the value is first accessed, then caches the result and frees the closure reference for GC.","directories":{},"sideEffects":false,"_nodeVersion":"22.22.3","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^6.0.3","@alwatr/standard":"9.33.0","@alwatr/nano-build":"9.33.1"},"_npmOperationalInternal":{"tmp":"tmp/lazy_9.33.1_1781089510273_0.2219281928098631","host":"s3://npm-registry-packages-npm-production"}},"9.38.1":{"name":"@alwatr/lazy","version":"9.38.1","keywords":["alwatr","browser","cache","cross-platform","deferred","ECMAScript","esm","gc","javascript","lazy","lazy-evaluation","lazy-initialization","lazy-loading","memoize","memoization","module","nanolib","node","nodejs","performance","typescript","util","utility","utils"],"author":{"url":"https://ali.mihandoost.com","name":"S. Ali Mihandoost","email":"ali.mihandoost@gmail.com"},"license":"MPL-2.0","_id":"@alwatr/lazy@9.38.1","maintainers":[{"name":"alimd","email":"ali.mihan.doost@gmail.com"}],"homepage":"https://github.com/Alwatr/alwatr/tree/next/pkg/nanolib/lazy#readme","bugs":{"url":"https://github.com/Alwatr/alwatr/issues"},"dist":{"shasum":"d9628137ffc50840bcb05daed9ce64df9ad770e9","tarball":"https://registry.npmjs.org/@alwatr/lazy/-/lazy-9.38.1.tgz","fileCount":13,"integrity":"sha512-0Kcd8cTxOGV1YHMOgpY1U9fFiOWj2usXA+KZZGlOWnndWUlTiseZB4dqgRhe3yKlWFAQZeBG/8I0ldjy39nBQw==","signatures":[{"sig":"MEQCIEfFNksi3zy3mP7QvTzmOCCkYDO0NRWeceDrZcZLqlHnAiBClDxZVxZTYwyX/S0ZF03l02B9sdCT0uDrcY7DWIRxAg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":45427},"type":"module","exports":{".":{"types":"./dist/main.d.ts","import":"./dist/main.js","default":"./dist/main.js","development":"./dist/dev/main.js"}},"gitHead":"918e99e7142b84f69eaa703ce9e27c3ac9d9300b","scripts":{"b":"bun run build","t":"bun run test","w":"bun run watch","cl":"bun run clean","lint":"eslint src/ --ext .ts","test":"bun test","build":"bun run build:ts && bun run build:es","clean":"rm -rfv dist *.tsbuildinfo","watch":"bun run watch:ts & bun run watch:es","format":"prettier --write \"src/**/*.ts\"","build:es":"bun run build:es:dev && bun run build:es:prod","build:ts":"tsc --build","watch:es":"bun run build:es:dev --watch","watch:ts":"bun run build:ts --watch --preserveWatchOutput","build:es:dev":"nano-build --preset=module --outdir=dist/dev src/main.ts","build:es:prod":"NODE_ENV=production nano-build --preset=module --outdir=dist src/main.ts"},"_npmUser":{"name":"alimd","email":"ali.mihan.doost@gmail.com"},"repository":{"url":"git+https://github.com/Alwatr/alwatr.git","type":"git","directory":"pkg/nanolib/lazy"},"_npmVersion":"lerna/5.3.0/node@v22.23.0+x64 (linux)","description":"A generic, memory-efficient lazy evaluation wrapper. Defers execution of expensive initializers until the value is first accessed, then caches the result and frees the closure reference for GC.","directories":{},"sideEffects":false,"_nodeVersion":"22.23.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^6.0.3","@alwatr/standard":"9.38.1","@alwatr/nano-build":"9.38.1"},"_npmOperationalInternal":{"tmp":"tmp/lazy_9.38.1_1782630638871_0.7828806588572055","host":"s3://npm-registry-packages-npm-production"}},"9.38.2":{"name":"@alwatr/lazy","version":"9.38.2","keywords":["alwatr","browser","cache","cross-platform","deferred","ECMAScript","esm","gc","javascript","lazy","lazy-evaluation","lazy-initialization","lazy-loading","memoize","memoization","module","nanolib","node","nodejs","performance","typescript","util","utility","utils"],"author":{"url":"https://ali.mihandoost.com","name":"S. Ali Mihandoost","email":"ali.mihandoost@gmail.com"},"license":"MPL-2.0","_id":"@alwatr/lazy@9.38.2","maintainers":[{"name":"alimd","email":"ali.mihan.doost@gmail.com"}],"homepage":"https://github.com/Alwatr/alwatr/tree/next/pkg/nanolib/lazy#readme","bugs":{"url":"https://github.com/Alwatr/alwatr/issues"},"dist":{"shasum":"fa59abe587237f66db03d31a18ed6f3ed7a304b7","tarball":"https://registry.npmjs.org/@alwatr/lazy/-/lazy-9.38.2.tgz","fileCount":13,"integrity":"sha512-qlDWxKxauLUCqSBnMs/K2W3ZhTEWelFBjDVhlQk9Y6/yif87m1vRSoL1nAZqiujxC14/RQG89QqeLXVv59cECA==","signatures":[{"sig":"MEYCIQCQ7Tto9/5rc2D9nR7fsZXX2adDJ2sJUbEiJGfYi/ZkaQIhAKe8O3pWZiJJUkLvtRnVAHWcEcYozyyVu2ac7TWsTVmj","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":45441},"type":"module","exports":{".":{"types":"./dist/main.d.ts","import":"./dist/main.js","default":"./dist/main.js","development":"./dist/dev/main.js"}},"gitHead":"69569fc5d7a66d5f027d5d4f58af4289280d5e5d","scripts":{"b":"bun run build","t":"bun run test","w":"bun run watch","cl":"bun run clean","lint":"eslint src/ --ext .ts","test":"bun test","build":"bun run build:ts && bun run build:es","clean":"rm -rfv dist *.tsbuildinfo","watch":"bun run watch:ts & bun run watch:es","format":"prettier --write \"src/**/*.ts\"","build:es":"bun run build:es:dev && bun run build:es:prod","build:ts":"tsc --build","watch:es":"bun run build:es:dev --watch","watch:ts":"bun run build:ts --watch --preserveWatchOutput","build:es:dev":"nano-build --preset=module --outdir=dist/dev src/main.ts","build:es:prod":"NODE_ENV=production nano-build --preset=module --outdir=dist src/main.ts"},"_npmUser":{"name":"alimd","email":"ali.mihan.doost@gmail.com"},"repository":{"url":"git+https://github.com/Alwatr/alwatr.git","type":"git","directory":"pkg/nanolib/lazy"},"_npmVersion":"lerna/5.4.0/node@v22.23.1+x64 (linux)","description":"A generic, memory-efficient lazy evaluation wrapper. Defers execution of expensive initializers until the value is first accessed, then caches the result and frees the closure reference for GC.","directories":{},"sideEffects":false,"_nodeVersion":"22.23.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^7.0.2","@alwatr/standard":"9.38.2","@alwatr/nano-build":"9.38.1"},"_npmOperationalInternal":{"tmp":"tmp/lazy_9.38.2_1783856600659_0.978374220016885","host":"s3://npm-registry-packages-npm-production"}},"10.0.0":{"name":"@alwatr/lazy","version":"10.0.0","keywords":["alwatr","browser","cache","cross-platform","deferred","ECMAScript","esm","gc","javascript","lazy","lazy-evaluation","lazy-initialization","lazy-loading","memoization","memoize","module","nanolib","node","nodejs","performance","typescript","util","utility","utils"],"author":{"url":"https://ali.mihandoost.com","name":"S. Ali Mihandoost","email":"ali.mihandoost@gmail.com"},"license":"MPL-2.0","_id":"@alwatr/lazy@10.0.0","maintainers":[{"name":"alimd","email":"ali.mihan.doost@gmail.com"}],"homepage":"https://github.com/Alwatr/alwatr/tree/next/pkg/nanolib/lazy#readme","bugs":{"url":"https://github.com/Alwatr/alwatr/issues"},"dist":{"shasum":"1c087b67d2dc253bc15619ca69c4d333b4f236be","tarball":"https://registry.npmjs.org/@alwatr/lazy/-/lazy-10.0.0.tgz","fileCount":13,"integrity":"sha512-04k/DFohbz6O10bjUvr7ztz8+Gb+0Scr9sMe8bkrtf/8ngUH5sU78Wd3axl2dSEzt5zz/0bdJm/Pg2ac4WwPOw==","signatures":[{"sig":"MEUCIQC9EiWmWF39HrK6nt7JbIyBxQyWCS6dVmDUQvnTZWpGGwIgXx9V63FRXtODExz+R9+OTXCS0fVrE7NfiALgbohG/tg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":45441},"type":"module","exports":{".":{"types":"./dist/main.d.ts","import":"./dist/main.js","default":"./dist/main.js","development":"./dist/dev/main.js"}},"gitHead":"ad367007af237263a64306c359d05fea63fb2dc7","scripts":{"b":"bun run build","t":"bun run test","w":"bun run watch","cl":"bun run clean","lint":"eslint src/ --ext .ts","test":"bun test","build":"bun run build:ts && bun run build:es","clean":"rm -rfv dist *.tsbuildinfo","watch":"bun run watch:ts & bun run watch:es","format":"prettier --write \"src/**/*.ts\"","build:es":"bun run build:es:dev && bun run build:es:prod","build:ts":"tsc --build","watch:es":"bun run build:es:dev --watch","watch:ts":"bun run build:ts --watch --preserveWatchOutput","build:es:dev":"nano-build --preset=module --outdir=dist/dev src/main.ts","build:es:prod":"NODE_ENV=production nano-build --preset=module --outdir=dist src/main.ts"},"_npmUser":{"name":"alimd","email":"ali.mihan.doost@gmail.com"},"repository":{"url":"git+https://github.com/Alwatr/alwatr.git","type":"git","directory":"pkg/nanolib/lazy"},"_npmVersion":"lerna/5.4.2/node@v22.23.1+x64 (linux)","description":"A generic, memory-efficient lazy evaluation wrapper. Defers execution of expensive initializers until the value is first accessed, then caches the result and frees the closure reference for GC.","directories":{},"sideEffects":false,"_nodeVersion":"22.23.1","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^7.0.2","@alwatr/standard":"10.0.0","@alwatr/nano-build":"10.0.0"},"_npmOperationalInternal":{"tmp":"tmp/lazy_10.0.0_1785075706058_0.3903191518050966","host":"s3://npm-registry-packages-npm-production"}},"10.2.0":{"name":"@alwatr/lazy","version":"10.2.0","description":"A generic, memory-efficient lazy evaluation wrapper. Defers execution of expensive initializers until the value is first accessed, then caches the result and frees the closure reference for GC.","license":"MPL-2.0","author":{"name":"S. Ali Mihandoost","email":"ali.mihandoost@gmail.com","url":"https://ali.mihandoost.com"},"type":"module","repository":{"type":"git","url":"git+https://github.com/Alwatr/alwatr.git","directory":"pkg/nanolib/lazy"},"homepage":"https://github.com/Alwatr/alwatr/tree/next/pkg/nanolib/lazy#readme","bugs":{"url":"https://github.com/Alwatr/alwatr/issues"},"exports":{".":{"types":"./dist/main.d.ts","development":"./dist/dev/main.js","import":"./dist/main.js","default":"./dist/main.js"}},"sideEffects":false,"devDependencies":{"@alwatr/nano-build":"10.0.0","@alwatr/standard":"10.0.0","typescript":"^7.0.2"},"scripts":{"b":"bun run build","build":"bun run build:ts && bun run build:es","build:es":"bun run build:es:dev && bun run build:es:prod","build:es:dev":"nano-build --preset=module --outdir=dist/dev src/main.ts","build:es:prod":"NODE_ENV=production nano-build --preset=module --outdir=dist src/main.ts","build:ts":"tsc --build","cl":"bun run clean","clean":"rm -rfv dist *.tsbuildinfo","format":"prettier --write \"src/**/*.ts\"","lint":"eslint src/ --ext .ts","t":"bun run test","test":"ALWATR_DEBUG=0 bun test","w":"bun run watch","watch":"bun run watch:ts & bun run watch:es","watch:es":"bun run build:es:dev --watch","watch:ts":"bun run build:ts --watch --preserveWatchOutput"},"publishConfig":{"access":"public"},"keywords":["alwatr","browser","cache","cross-platform","deferred","ECMAScript","esm","gc","javascript","lazy","lazy-evaluation","lazy-initialization","lazy-loading","memoization","memoize","module","nanolib","node","nodejs","performance","typescript","util","utility","utils"],"gitHead":"2a0a52415ec6af039244806419c3b79734994c71","_id":"@alwatr/lazy@10.2.0","_nodeVersion":"22.23.2","_npmVersion":"lerna/5.6.1/node@v22.23.2+x64 (linux)","dist":{"integrity":"sha512-ryzQyZ0Ld1pHpVVXoiLB5DLCsClp7Y43YL+bSj4hWcCG9gzxX02rC1UkXymGqovbpGGcXkyfrOv1VjHVoUfwKg==","shasum":"75872f6680caca7419c6278461e30d8ffb08c874","tarball":"https://registry.npmjs.org/@alwatr/lazy/-/lazy-10.2.0.tgz","fileCount":13,"unpackedSize":45456,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDoDDAGZm423DC/6GJSSISJgOVwiQZ23cWJUadS2+gMhgIgXPz/6OSyAZs7sujo+Yu6ErZl1qtfDzMy8lDRxUXRDG0="}]},"_npmUser":{"name":"alimd","email":"ali.mihan.doost@gmail.com"},"directories":{},"maintainers":[{"name":"alimd","email":"ali.mihan.doost@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/lazy_10.2.0_1788887073499_0.7074269384094058"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-28T18:54:45.972Z","modified":"2026-09-08T17:04:33.833Z","9.19.0":"2026-04-28T18:54:46.268Z","9.25.0":"2026-05-21T12:22:46.398Z","9.33.0":"2026-06-10T02:04:31.850Z","9.33.1":"2026-06-10T11:05:10.411Z","9.38.1":"2026-06-28T07:10:39.018Z","9.38.2":"2026-07-12T11:43:20.796Z","10.0.0":"2026-07-26T14:21:46.215Z","10.2.0":"2026-09-08T17:04:33.652Z"},"bugs":{"url":"https://github.com/Alwatr/alwatr/issues"},"author":{"name":"S. Ali Mihandoost","email":"ali.mihandoost@gmail.com","url":"https://ali.mihandoost.com"},"license":"MPL-2.0","homepage":"https://github.com/Alwatr/alwatr/tree/next/pkg/nanolib/lazy#readme","keywords":["alwatr","browser","cache","cross-platform","deferred","ECMAScript","esm","gc","javascript","lazy","lazy-evaluation","lazy-initialization","lazy-loading","memoization","memoize","module","nanolib","node","nodejs","performance","typescript","util","utility","utils"],"repository":{"type":"git","url":"git+https://github.com/Alwatr/alwatr.git","directory":"pkg/nanolib/lazy"},"description":"A generic, memory-efficient lazy evaluation wrapper. Defers execution of expensive initializers until the value is first accessed, then caches the result and frees the closure reference for GC.","maintainers":[{"name":"alimd","email":"ali.mihan.doost@gmail.com"}],"readme":"# `@alwatr/lazy`\n\nA generic, memory-efficient **lazy evaluation** wrapper for TypeScript/ESM projects.\n\nDefers execution of an expensive initializer until the value is first accessed, caches the result permanently, and immediately releases the initializer closure so the garbage collector can reclaim any captured memory.\n\n---\n\n## Why This Package Exists\n\nModern JavaScript applications — especially SPAs and micro-frontends — suffer from **main-thread congestion at boot time**. Every module that eagerly instantiates services, parses configs, or opens connections adds to the critical path before the first frame is painted.\n\nThe standard solution is _lazy initialization_: defer work until it is actually needed. But rolling this pattern by hand every time leads to repetitive boilerplate:\n\n```ts\n// ❌ Repeated boilerplate — error-prone and verbose\nlet _db: DatabaseConnection | undefined;\nfunction getDb() {\n  if (!_db) _db = new DatabaseConnection(config);\n  return _db;\n}\n```\n\n`@alwatr/lazy` encapsulates this pattern in a single, type-safe, zero-dependency class that also handles an important detail most hand-rolled versions miss: **freeing the initializer closure after first use**.\n\n### The GC Optimization\n\nWhen you write `new Lazy(() => new ExpensiveService(config))`, the arrow function captures `config` (and potentially much more) in its closure. Once the service is created, that closure is dead weight — but it stays alive as long as the `Lazy` instance holds a reference to it.\n\n`@alwatr/lazy` solves this by using `delete this.initializer__` (not just `= undefined`) after the first access. This removes the property from the object's hidden class, giving V8 a strong signal to release the closure and everything it captured.\n\n---\n\n## Architecture\n\n```\n┌─────────────────────────────────────────────────────┐\n│                    Lazy<T>                          │\n│                                                     │\n│  constructor(initializer: () => T)                  │\n│    └─ stores initializer__ reference                │\n│                                                     │\n│  get instance(): T                                  │\n│    ├─ [first access]                                │\n│    │    1. call initializer__()                     │\n│    │    2. cache result in instance__               │\n│    │    3. delete initializer__  ← GC hint          │\n│    │    4. return instance__                        │\n│    └─ [subsequent accesses]                         │\n│         return instance__  (O(1), no function call) │\n│                                                     │\n│  isInitialized(): boolean                           │\n│    └─ initializer__ === undefined                   │\n└─────────────────────────────────────────────────────┘\n```\n\n**State machine:**\n\n```\n  [constructed]\n       │\n       │  first .instance access\n       ▼\n  [initializing]  ──→  initializer__() runs\n       │\n       │  result cached, initializer__ deleted\n       ▼\n  [initialized]   ──→  all subsequent .instance reads return cache\n```\n\n---\n\n## Installation\n\n```sh\nbun add @alwatr/lazy\n# or\nnpm install @alwatr/lazy\n```\n\n---\n\n## Usage\n\n### Class API\n\n```ts\nimport {Lazy} from '@alwatr/lazy';\n\n// The DatabaseConnection is NOT created here.\nconst db = new Lazy(() => new DatabaseConnection(config));\n\nconsole.log(db.isInitialized()); // false\n\n// Created on first access, cached for all future accesses.\nconst connection = db.instance; // DatabaseConnection instantiated here\nconsole.log(db.isInitialized()); // true\nconsole.log(db.instance === connection); // true — same reference\n```\n\n### Factory Function (preferred)\n\nThe `lazy()` factory function is preferred over `new Lazy(...)` because TypeScript\ninfers `T` from the initializer's return type without requiring an explicit type parameter.\n\n```ts\nimport {lazy} from '@alwatr/lazy';\n\nconst config = lazy(() => loadAndParseConfig('./config.json'));\n// T is inferred as the return type of loadAndParseConfig — no annotation needed.\n```\n\n### Conditional Initialization Guard\n\n```ts\nimport {lazy} from '@alwatr/lazy';\n\nconst analyticsClient = lazy(() => new AnalyticsClient(apiKey));\n\nfunction trackEvent(name: string) {\n  if (!analyticsClient.isInitialized()) {\n    // Analytics not yet started — skip silently during boot\n    return;\n  }\n  analyticsClient.instance.track(name);\n}\n```\n\n### Module-Level Singletons\n\nA common pattern is to export a `Lazy`-wrapped singleton from a module. Consumers\npay zero initialization cost unless they actually use the service:\n\n```ts\n// services/database.ts\nimport {lazy} from '@alwatr/lazy';\nimport {DatabaseConnection} from './connection.js';\n\nexport const database = lazy(() => new DatabaseConnection(process.env.DB_URL!));\n```\n\n```ts\n// routes/users.ts — only pays the init cost when this route is first hit\nimport {database} from '../services/database.js';\n\nexport async function getUsers() {\n  return database.instance.query('SELECT * FROM users');\n}\n```\n\n### With `@alwatr/signal` (Reactive Lazy)\n\nCombine with `StateSignal` to initialize a service only when a signal is first subscribed to:\n\n```ts\nimport {lazy} from '@alwatr/lazy';\nimport {StateSignal} from '@alwatr/signal';\n\nconst cartService = lazy(() => new CartService());\n\nconst cartSignal = new StateSignal<CartState>('cart', {items: []});\n\ncartSignal.subscribe((state) => {\n  // cartService is initialized on the first subscription, not at module load.\n  cartService.instance.syncToStorage(state);\n});\n```\n\n---\n\n## API Reference\n\n### `class Lazy<T>`\n\n#### `constructor(initializer: () => T)`\n\nCreates a new `Lazy` wrapper. The `initializer` is **not** called at this point.\n\n#### `get instance(): T`\n\nReturns the lazily-initialized value. Calls `initializer` on the first access,\ncaches the result, and deletes the initializer reference. All subsequent accesses\nreturn the cached value in O(1) with no function call overhead.\n\n#### `isInitialized(): boolean`\n\nReturns `true` if the initializer has already been executed (i.e., `.instance` has\nbeen accessed at least once). Returns `false` otherwise.\n\n---\n\n### `function lazy<T>(initializer: () => T): Lazy<T>`\n\nFactory function. Equivalent to `new Lazy(initializer)` but with better type\ninference — TypeScript derives `T` from the return type of `initializer` automatically.\n\n---\n\n## Design Decisions\n\n| Decision                                               | Rationale                                                                                                                                                                                                |\n| ------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `delete this.initializer__` instead of `= undefined`   | Removes the property from the V8 hidden class, giving a stronger GC hint than a simple `undefined` assignment.                                                                                           |\n| `instance__` uses `undefined` as sentinel (not `null`) | Allows `T` to be `null` without ambiguity — `lazy(() => null).instance` correctly returns `null`.                                                                                                        |\n| No `reset()` method                                    | Lazy values are intended to be permanent singletons. A reset would reintroduce the initializer, complicating the GC story and the state machine. If you need resettable state, use `@alwatr/signal`.     |\n| No async support                                       | Async initialization belongs in `@alwatr/flatomise` (deferred promises) or `@alwatr/signal` (reactive state). Mixing `Promise` into `Lazy` would complicate the synchronous `.instance` getter contract. |\n| `sideEffects: false`                                   | The package has no module-level side effects, enabling full tree-shaking.                                                                                                                                |\n\n---\n\n## Relation to Other Packages\n\n| Package             | When to use instead                                                          |\n| ------------------- | ---------------------------------------------------------------------------- |\n| `@alwatr/flatomise` | You need a **Promise** that can be resolved externally (async lazy).         |\n| `@alwatr/signal`    | You need **reactive** state that notifies subscribers on change.             |\n| `@alwatr/debounce`  | You need to **throttle** repeated function calls, not defer a one-time init. |\n\n---\n\n## License\n\n[MPL-2.0](https://mozilla.org/MPL/2.0/) © [Alwatr](https://github.com/Alwatr)\n","readmeFilename":"README.md"}