Create UUIDs for your application. The single purpose of this library is to test this simple code once and for all
- With npm:
npm i --save @elemental-concept/random-id
Simply use the service into your component:
@Component({selector: 'app-random-id-page',templateUrl: './random-id-page.component.html',styleUrls: ['./random-id-page.component.scss']})exportclassRandomIdPageComponentimplementsOnInit{result: string;constructor(privatereadonlyrandomIdService: RandomIdService){}ngOnInit(){// i.e.: 1410715640579this.result=this.randomIdService.getRandomIdTimestamp();// i.e.: as1f-qwe3r-rt5u-fghjthis.result=this.randomIdService.getRandomId();// i.e.: as1f_qwe3r_rt5uthis.result=this.randomIdService.getRandomId(3,'_');// i.e.: PREFIX-1410715640579-SUFFIXthis.result=this.randomIdService.getRandomIdTimestamp('-','PREFIX','SUFFIX');// i.e.: PREFIX_as1f_qwe3r_rt5u_fghj_SUFFIXthis.result=this.randomIdService.getRandomId(4,'_','PREFIX','SUFFIX');}}- By default
getRandomIdwill create4 segment on 4 chars/digitsseparated by-. - By default
prefixandsuffixarenull; - By default
getRandomIdTimestampwill use the separator (-by default) only ifprefixand/orsuffixare not nullnull;