@anteros/core 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/utils/func.ts +7 -3
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@anteros/core",
3
3
  "module": "index.ts",
4
- "version": "0.0.4",
4
+ "version": "0.0.5",
5
5
  "type": "module",
6
6
  "description": "Anteros Core",
7
7
  "private": false,
package/utils/func.ts CHANGED
@@ -409,8 +409,10 @@ export type GenerateRandomOptions = {
409
409
  useNumbers?: boolean;
410
410
  includeSymbols?: string;
411
411
  excludeSymbols?: string;
412
- startWith?: string;
413
- endWith?: string;
412
+ /** Préfixe (string fixe ou fonction qui reçoit la valeur générée). Ex: `(v) => 'BP-' + v` */
413
+ startWith?: string | ((value: string) => string);
414
+ /** Suffixe (string fixe ou fonction qui reçoit la valeur générée). Ex: `(v) => v + '-X'` */
415
+ endWith?: string | ((value: string) => string);
414
416
  toLowerCase?: boolean;
415
417
  toUpperCase?: boolean;
416
418
  toNumber?: boolean;
@@ -463,7 +465,9 @@ async function generateRandom(options: GenerateRandomOptions, ctx: {
463
465
  result += charset[randomIndex];
464
466
  }
465
467
 
466
- result = startWith + result + endWith;
468
+ const start = typeof startWith === 'function' ? startWith(result) : startWith;
469
+ const end = typeof endWith === 'function' ? endWith(result) : endWith;
470
+ result = start + result + end;
467
471
 
468
472
  if (toLowerCase) {
469
473
  result = result.toLowerCase();