import { boundClass , StatedBeanClass } from '../core' ; import { getMetadataStorage } from '../metadata' ; export interface StatedBeanOptions { name ? : string | symbol ; singleton ? : boolean ; } export returns { ClassDecorator } export function StatedBean ( options ? ) { return ( target ) => { const name = typeof options === 'object' ? options . name : options ; const singleton = typeof options === 'object' ? options . singleton : false ; boundClass ( target ) ; Object . defineProperty ( target , StatedBeanClass , { writable : false , value : true , } ) ; getMetadataStorage ( ) . collectStatedBean ( { name , target , singleton , } ) ; } ; }