{"_id":"@arcmantle/reflect-metadata","_rev":"5-48a067174a571c7bed10eacbab6dd884","name":"@arcmantle/reflect-metadata","dist-tags":{"latest":"1.0.4"},"versions":{"1.0.0":{"name":"@arcmantle/reflect-metadata","version":"1.0.0","author":{"url":"https://github.com/arcmantle","name":"Kristoffer Roen-Lie"},"license":"Apache-2.0","_id":"@arcmantle/reflect-metadata@1.0.0","maintainers":[{"name":"roenlie","email":"kristofferroenlie@gmail.com"}],"dist":{"shasum":"cc22a820a3db0b0ac26fd63960c9747c4486b8b5","tarball":"https://registry.npmjs.org/@arcmantle/reflect-metadata/-/reflect-metadata-1.0.0.tgz","fileCount":13,"integrity":"sha512-4YkLA+Sr46F1AGtE9k7etLGMGSe+oAh2aD0ju6VVbTltMVI57Z9oOscPdokyr9OTjzohmFO2Vlq1LrHqUxOUsw==","signatures":[{"sig":"MEQCIENWFo3BVAnKHBrlFiiNutBVd4YQTkv8peAQIKiIjdMCAiB7YH3Yt32rinsRMWLhov2JJLJfC+ryrfooLaHClxCUHg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":27804},"type":"module","_from":"file:arcmantle-reflect-metadata-1.0.0.tgz","exports":{".":"./dist/index.js"},"scripts":{"test":"vitest --run","build":"rimraf dist && tsc --project ./src/tsconfig.json"},"_npmUser":{"name":"roenlie","actor":{"name":"roenlie","type":"user","email":"kristofferroenlie@gmail.com"},"email":"kristofferroenlie@gmail.com"},"_resolved":"/tmp/0e06f16e25ec6fae9548a65e672bb6cd/arcmantle-reflect-metadata-1.0.0.tgz","_integrity":"sha512-4YkLA+Sr46F1AGtE9k7etLGMGSe+oAh2aD0ju6VVbTltMVI57Z9oOscPdokyr9OTjzohmFO2Vlq1LrHqUxOUsw==","_npmVersion":"11.4.2","description":"Lightweight, partial implementation of TC39 Reflect Metadata proposal with function-activated shim","directories":{},"sideEffects":false,"_nodeVersion":"24.3.0","_hasShrinkwrap":false,"devDependencies":{"rimraf":"^6.0.1","typescript":"^5.8.3","@types/node":"^24.0.10","@arcmantle/tsconfig":"^1.0.0"},"_npmOperationalInternal":{"tmp":"tmp/reflect-metadata_1.0.0_1751579565299_0.4504243500164382","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@arcmantle/reflect-metadata","version":"1.0.1","author":{"name":"Kristoffer Roen-Lie"},"license":"Apache-2.0","_id":"@arcmantle/reflect-metadata@1.0.1","maintainers":[{"name":"roenlie","email":"kristofferroenlie@gmail.com"}],"dist":{"shasum":"b81781a6e456119780264e8281f07cba6e46aa71","tarball":"https://registry.npmjs.org/@arcmantle/reflect-metadata/-/reflect-metadata-1.0.1.tgz","fileCount":13,"integrity":"sha512-6xa726ywSxkK2uTpXPIAC8uUDZX+bMpe6SXZu4Fg83JubZwyxsWrmFjcTITW3Mzi9mfHUi5KCBaqziD4oS6TLA==","signatures":[{"sig":"MEYCIQDwvCT8ycXmRBHydnmE8a9NFpDLK7gHtnul7CyAr9uoNwIhAPS6/m9qWTC0m2NMOT1VDEDSATKoxBIqzoHNXLBP+xA9","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":27743},"type":"module","_from":"file:arcmantle-reflect-metadata-1.0.1.tgz","exports":{".":"./dist/index.js"},"scripts":{"test":"vitest --run","build":"rimraf dist && tsc --project ./src/tsconfig.json"},"_npmUser":{"name":"roenlie","email":"kristofferroenlie@gmail.com"},"_resolved":"/tmp/48b3caa2ea25d0b633da96be51fa29d0/arcmantle-reflect-metadata-1.0.1.tgz","_integrity":"sha512-6xa726ywSxkK2uTpXPIAC8uUDZX+bMpe6SXZu4Fg83JubZwyxsWrmFjcTITW3Mzi9mfHUi5KCBaqziD4oS6TLA==","_npmVersion":"11.4.2","description":"Lightweight, partial implementation of TC39 Reflect Metadata proposal with function-activated shim","directories":{},"sideEffects":false,"_nodeVersion":"24.4.1","_hasShrinkwrap":false,"devDependencies":{"rimraf":"^6.0.1","typescript":"^5.8.3","@types/node":"^24.0.14","@arcmantle/tsconfig":"^1.0.5"},"_npmOperationalInternal":{"tmp":"tmp/reflect-metadata_1.0.1_1752757864676_0.08493233350564466","host":"s3://npm-registry-packages-npm-production"}},"1.0.2":{"name":"@arcmantle/reflect-metadata","version":"1.0.2","author":{"name":"Kristoffer Roen-Lie"},"license":"Apache-2.0","_id":"@arcmantle/reflect-metadata@1.0.2","maintainers":[{"name":"roenlie","email":"kristofferroenlie@gmail.com"}],"homepage":"https://github.com/arcmantle/reflect-metadata#readme","bugs":{"url":"https://github.com/arcmantle/reflect-metadata/issues"},"dist":{"shasum":"1d5bb6e7f3820a151ae8ed5fd14a29c2e40cd0ea","tarball":"https://registry.npmjs.org/@arcmantle/reflect-metadata/-/reflect-metadata-1.0.2.tgz","fileCount":13,"integrity":"sha512-W1NirRrW5TvFcP95b5y0x5qZOkDRITfynTF5elgkqrzRgQWHb3HxaRwm4w+wvCy0j8Y45LBs61ZZpxzhLsfQ6A==","signatures":[{"sig":"MEYCIQDPmLzzY2ieCUHA64oRHNF0x9gwaHbL5IP9t5LBMrQ+IgIhAKgwW3jo0yc3VXWYKwluUJQdbR/cvy6mYYzF1nuA/9yl","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":27848},"type":"module","_from":"file:arcmantle-reflect-metadata-1.0.2.tgz","exports":{".":"./dist/index.js"},"scripts":{"test":"vitest --run","build":"rimraf dist && tsc --project ./src/tsconfig.json"},"_npmUser":{"name":"roenlie","email":"kristofferroenlie@gmail.com"},"_resolved":"/tmp/02ddc945a1a80f5f0c74548301eb7261/arcmantle-reflect-metadata-1.0.2.tgz","_integrity":"sha512-W1NirRrW5TvFcP95b5y0x5qZOkDRITfynTF5elgkqrzRgQWHb3HxaRwm4w+wvCy0j8Y45LBs61ZZpxzhLsfQ6A==","repository":{"url":"git+https://github.com/arcmantle/reflect-metadata.git","type":"git"},"_npmVersion":"11.4.2","description":"Lightweight, partial implementation of TC39 Reflect Metadata proposal with function-activated shim","directories":{},"sideEffects":false,"_nodeVersion":"24.4.1","_hasShrinkwrap":false,"devDependencies":{"rimraf":"^6.0.1","typescript":"^5.8.3","@types/node":"^24.0.14","@arcmantle/tsconfig":"^1.0.6"},"_npmOperationalInternal":{"tmp":"tmp/reflect-metadata_1.0.2_1752781597804_0.5018109051914323","host":"s3://npm-registry-packages-npm-production"}},"1.0.3":{"name":"@arcmantle/reflect-metadata","version":"1.0.3","author":{"name":"Kristoffer Roen-Lie"},"license":"Apache-2.0","_id":"@arcmantle/reflect-metadata@1.0.3","maintainers":[{"name":"roenlie","email":"kristofferroenlie@gmail.com"}],"homepage":"https://github.com/arcmantle/reflect-metadata#readme","bugs":{"url":"https://github.com/arcmantle/reflect-metadata/issues"},"dist":{"shasum":"b251e121e54acaa74fa9d9250483aa22a4106b3d","tarball":"https://registry.npmjs.org/@arcmantle/reflect-metadata/-/reflect-metadata-1.0.3.tgz","fileCount":13,"integrity":"sha512-5N3wIEseTqnXTHAJ1dCmuQSLaYTgAaxqF9Bms5yW0kADctFrwrGvG/hDJMeldwbYBt747cvOxRbbBhn8bzjs0Q==","signatures":[{"sig":"MEUCIFTFHgop1JhJlNzh7/Nl2lE+yWh5CGlYe+vHon67MSS7AiEAuwWAu3/GTbQLuWqY54gKAItkmDS4tviRrROymopiO/M=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":27848},"type":"module","_from":"file:arcmantle-reflect-metadata-1.0.3.tgz","exports":{".":"./dist/index.js"},"scripts":{"test":"vitest --run","build":"rimraf dist && tsc --project ./src/tsconfig.json"},"_npmUser":{"name":"roenlie","email":"kristofferroenlie@gmail.com"},"_resolved":"/tmp/df193efda4183dfc8a0be94b52b8a088/arcmantle-reflect-metadata-1.0.3.tgz","_integrity":"sha512-5N3wIEseTqnXTHAJ1dCmuQSLaYTgAaxqF9Bms5yW0kADctFrwrGvG/hDJMeldwbYBt747cvOxRbbBhn8bzjs0Q==","repository":{"url":"git+https://github.com/arcmantle/reflect-metadata.git","type":"git"},"_npmVersion":"11.4.2","description":"Lightweight, partial implementation of TC39 Reflect Metadata proposal with function-activated shim","directories":{},"sideEffects":false,"_nodeVersion":"24.4.1","_hasShrinkwrap":false,"devDependencies":{"rimraf":"^6.0.1","typescript":"^5.8.3","@types/node":"^24.0.14","@arcmantle/tsconfig":"^1.0.9"},"_npmOperationalInternal":{"tmp":"tmp/reflect-metadata_1.0.3_1752792916958_0.7749473507435383","host":"s3://npm-registry-packages-npm-production"}},"1.0.4":{"name":"@arcmantle/reflect-metadata","version":"1.0.4","description":"Lightweight, partial implementation of TC39 Reflect Metadata proposal with function-activated shim","repository":{"type":"git","url":"git+https://github.com/arcmantle/reflect-metadata.git"},"license":"Apache-2.0","author":{"name":"Kristoffer Roen-Lie"},"sideEffects":false,"type":"module","exports":{".":"./dist/index.js"},"devDependencies":{"@arcmantle/tsconfig":"^1.0.9","@types/node":"^24.5.2","rimraf":"^6.0.1","typescript":"^5.9.2"},"scripts":{"build":"rimraf dist && tsc --project ./src/tsconfig.json","test":"vitest --run"},"_id":"@arcmantle/reflect-metadata@1.0.4","bugs":{"url":"https://github.com/arcmantle/reflect-metadata/issues"},"homepage":"https://github.com/arcmantle/reflect-metadata#readme","_integrity":"sha512-0mRvQ5Tz/QTmwfHPfkzznEtZzmb7dbHlDR9qqCRz4vx9aUHmYgD6YwPhQrzJWPG5w9yWwdj4ofwwKe2azIgp+g==","_resolved":"/tmp/18610ff259c56ddb060d74f378eee236/arcmantle-reflect-metadata-1.0.4.tgz","_from":"file:arcmantle-reflect-metadata-1.0.4.tgz","_nodeVersion":"24.8.0","_npmVersion":"11.6.0","dist":{"integrity":"sha512-0mRvQ5Tz/QTmwfHPfkzznEtZzmb7dbHlDR9qqCRz4vx9aUHmYgD6YwPhQrzJWPG5w9yWwdj4ofwwKe2azIgp+g==","shasum":"db110bac61280a076a3f5a52740105736db0f96e","tarball":"https://registry.npmjs.org/@arcmantle/reflect-metadata/-/reflect-metadata-1.0.4.tgz","fileCount":13,"unpackedSize":27847,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQD1pdiReOSjO0scLqHH3JO/4KYOFV6wR0WZDSurHcbrXwIhAJ3RdkhyZ94DsMSN1Xm5erWlcsfv7wjFAGYlZmJbHBuG"}]},"_npmUser":{"name":"roenlie","email":"kristofferroenlie@gmail.com"},"directories":{},"maintainers":[{"name":"roenlie","email":"kristofferroenlie@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/reflect-metadata_1.0.4_1758839252336_0.7815662456594179"},"_hasShrinkwrap":false}},"time":{"created":"2025-07-03T21:52:45.176Z","modified":"2025-09-25T22:27:32.773Z","1.0.0":"2025-07-03T21:52:45.473Z","1.0.1":"2025-07-17T13:11:04.835Z","1.0.2":"2025-07-17T19:46:37.959Z","1.0.3":"2025-07-17T22:55:17.131Z","1.0.4":"2025-09-25T22:27:32.567Z"},"bugs":{"url":"https://github.com/arcmantle/reflect-metadata/issues"},"author":{"name":"Kristoffer Roen-Lie"},"license":"Apache-2.0","homepage":"https://github.com/arcmantle/reflect-metadata#readme","repository":{"type":"git","url":"git+https://github.com/arcmantle/reflect-metadata.git"},"description":"Lightweight, partial implementation of TC39 Reflect Metadata proposal with function-activated shim","maintainers":[{"name":"roenlie","email":"kristofferroenlie@gmail.com"}],"readme":"# @arcmantle/reflect-metadata\n\n[![License](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)\n[![TypeScript](https://img.shields.io/badge/TypeScript-5.0%2B-blue.svg)](https://www.typescriptlang.org/)\n\nA lightweight, partial implementation of the [TC39 Reflect Metadata proposal](https://github.com/tc39/proposal-reflect-metadata). This library provides reflection metadata functionality with a focus on performance and bundle size.\n\n## ✨ Features\n\n- 🪶 **Lightweight**: Only ~3.2KB unminified, 1.7KB minified, 0.7KB gzipped\n- 🚀 **Performance optimized**: WeakMap-based storage for optimal memory usage\n- 🔧 **Function-activated**: Extends the global Reflect object with metadata APIs\n- 🛡️ **Safe**: Won't override existing reflect-metadata implementations\n- 📦 **ESM native**: Built for modern JavaScript environments\n- 🎯 **TypeScript ready**: Full type definitions included\n\n## 📦 Installation\n\n```bash\nnpm install @arcmantle/reflect-metadata\n```\n\n```bash\npnpm add @arcmantle/reflect-metadata\n```\n\n```bash\nyarn add @arcmantle/reflect-metadata\n```\n\n## 🚀 Quick Start\n\n### Extend Global Reflect\n\nExtend the global Reflect object with metadata APIs:\n\n#### TypeScript/JavaScript\n\n```typescript\nimport { useReflectMetadata } from '@arcmantle/reflect-metadata';\n\n// Extend the global Reflect with metadata APIs\nconst Reflect = useReflectMetadata();\n\n// Now you can use Reflect metadata APIs (global Reflect is extended)\nReflect.defineMetadata('custom:key', 'value', target);\nconst value = Reflect.getMetadata('custom:key', target);\n```\n\n#### HTML\n\n```html\n<script type=\"module\">\n import { useReflectMetadata } from '@arcmantle/reflect-metadata';\n\n const Reflect = useReflectMetadata();\n // Reflect metadata APIs are now available globally\n</script>\n```\n\n## 📚 API Reference\n\nThis library implements the following Reflect metadata APIs:\n\n### `Reflect.defineMetadata(key, value, target[, propertyKey])`\n\nDefines metadata for a target object or property.\n\n```typescript\nconst Reflect = useReflectMetadata();\nReflect.defineMetadata('custom:type', 'string', MyClass, 'propertyName');\n```\n\n### `Reflect.getMetadata(key, target[, propertyKey])`\n\nRetrieves metadata from a target object or property, including inherited metadata.\n\n```typescript\nconst Reflect = useReflectMetadata();\nconst type = Reflect.getMetadata('custom:type', MyClass, 'propertyName');\n```\n\n### `Reflect.getOwnMetadata(key, target[, propertyKey])`\n\nRetrieves own metadata from a target object or property (no inheritance).\n\n```typescript\nconst Reflect = useReflectMetadata();\nconst ownType = Reflect.getOwnMetadata('custom:type', MyClass, 'propertyName');\n```\n\n### `Reflect.hasMetadata(key, target[, propertyKey])`\n\nChecks if metadata exists for a target object or property (including inherited).\n\n```typescript\nconst Reflect = useReflectMetadata();\nconst hasType = Reflect.hasMetadata('custom:type', MyClass, 'propertyName');\n```\n\n### `Reflect.hasOwnMetadata(key, target[, propertyKey])`\n\nChecks if own metadata exists for a target object or property (no inheritance).\n\n```typescript\nconst Reflect = useReflectMetadata();\nconst hasOwnType = Reflect.hasOwnMetadata('custom:type', MyClass, 'propertyName');\n```\n\n### `Reflect.metadata(key, value)`\n\nCreates a metadata decorator function.\n\n```typescript\nconst Reflect = useReflectMetadata();\nconst Type = (type: string) => Reflect.metadata('custom:type', type);\n\nclass MyClass {\n @Type('string')\n propertyName: string;\n}\n```\n\n### `Reflect.decorate(decorators, target[, propertyKey, descriptor])`\n\nApplies decorators to a target.\n\n```typescript\nconst Reflect = useReflectMetadata();\nconst decoratedClass = Reflect.decorate([MyDecorator], MyClass);\n```\n\n## 🔧 Usage Examples\n\n### Basic Metadata Storage\n\n```typescript\nimport { useReflectMetadata } from '@arcmantle/reflect-metadata';\n\nconst Reflect = useReflectMetadata();\n\nclass User {\n name: string;\n email: string;\n}\n\n// Store metadata\nReflect.defineMetadata('validation:required', true, User, 'name');\nReflect.defineMetadata('validation:email', true, User, 'email');\n\n// Retrieve metadata\nconst isNameRequired = Reflect.getMetadata('validation:required', User, 'name');\nconst isEmailValidation = Reflect.getMetadata('validation:email', User, 'email');\n```\n\n### Custom Decorators\n\n```typescript\nimport { useReflectMetadata } from '@arcmantle/reflect-metadata';\n\nconst Reflect = useReflectMetadata();\n\n// Create a validation decorator\nfunction Required(target: any, propertyKey: string) {\n Reflect.defineMetadata('validation:required', true, target, propertyKey);\n}\n\nfunction Email(target: any, propertyKey: string) {\n Reflect.defineMetadata('validation:email', true, target, propertyKey);\n}\n\nclass User {\n @Required\n name: string;\n\n @Required\n @Email\n email: string;\n}\n\n// Validation logic\nfunction validate(instance: any) {\n const constructor = instance.constructor;\n\n for (const property of Object.keys(instance)) {\n  const isRequired = Reflect.getMetadata('validation:required', constructor, property);\n  const isEmail = Reflect.getMetadata('validation:email', constructor, property);\n\n  if (isRequired && !instance[property]) {\n   throw new Error(`${property} is required`);\n  }\n\n  if (isEmail && !instance[property].includes('@')) {\n   throw new Error(`${property} must be a valid email`);\n  }\n }\n}\n```\n\n## ⚠️ Important Notes\n\n- **Safe activation**: Multiple calls to `useReflectMetadata()` return the same extended global Reflect\n- **Non-destructive**: Won't override existing reflect-metadata implementations\n- **Global extension**: Extends the global Reflect object with metadata methods\n- **ESM only**: This package is ESM-only and requires Node.js 14+ or modern browsers\n- **Partial implementation**: Only implements the most commonly used metadata APIs\n\n## 🤝 Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## 📄 License\n\nThis project is licensed under the Apache 2.0 License - see the [LICENSE](LICENSE) file for details.\n\n## 🔗 Related Projects\n\n- [TC39 Reflect Metadata Proposal](https://github.com/tc39/proposal-reflect-metadata)\n- [reflect-metadata](https://github.com/rbuckton/reflect-metadata) - Full implementation\n\n---\n","readmeFilename":"readme.md"}