Skip to content

Commit d8fa7c5

Browse files
committed
Update readme
1 parent 348fe23 commit d8fa7c5

File tree

1 file changed

+38
-9
lines changed

1 file changed

+38
-9
lines changed

README.md

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,25 @@ import Enum from "enum-xyz";
2424
const { Summer, Autumn, Winter, Spring } = Enum.String();
2525
2626
console.log(Summer); // Outputs: "Summer"
27-
console.log(Autumn); // Outputs: "Autumn"
28-
console.log(Winter); // Outputs: "Winter"
29-
console.log(Spring); // Outputs: "Spring"
27+
```
28+
29+
#### Options for String Enums:
30+
31+
- `casing`: Transforms the string based on the specified casing style. Available options are `snakeCase`, `camelCase`, `PascalCase`, `kebabCase`, `lowercase`, and `uppercase`.
32+
- `transform`: Provide a custom function to transform the enum values. This function takes the original value and returns a transformed value.
33+
34+
##### Example:
35+
36+
```
37+
const { userId, userAddress } = Enum.String({ casing: 'kebabCase' });
38+
console.log(userId); // Outputs: "user-id"
39+
40+
const options = {
41+
casing: 'kebabCase',
42+
transform: (value) => `https://api.example.com/${value}`
43+
};
44+
const { userEndpoint, orderEndpoint } = Enum.String(options);
45+
console.log(userEndpoint); // Outputs: "https://api.example.com/user-endpoint"
3046
```
3147

3248
### Numeric Enums
@@ -39,16 +55,19 @@ import Enum from "enum-xyz";
3955
const { A, B, C, D } = Enum.Numeric();
4056
4157
console.log(A); // Outputs: 0
42-
console.log(B); // Outputs: 1
43-
console.log(C); // Outputs: 2
44-
console.log(D); // Outputs: 3
4558
```
4659

47-
To start from a different index:
60+
#### Options for Numeric Enums:
61+
62+
- `startIndex`: Start the numeric enum from a specific index.
63+
- `step`: Increment the numeric values by a specific step (e.g., 2, 5, 10).
64+
65+
##### Example:
4866

4967
```
50-
const { A, B, C, D } = Enum.Numeric(5);
68+
const { A, B, C } = Enum.Numeric({ startIndex: 5, step: 2 });
5169
console.log(A); // Outputs: 5
70+
console.log(B); // Outputs: 7
5271
```
5372

5473
### Symbol Enums
@@ -59,5 +78,15 @@ import Enum from "enum-xyz";
5978
const { blue, red } = Enum.Symbol();
6079
6180
console.log(blue); // Outputs: Symbol(blue)
62-
console.log(red); // Outputs: Symbol(red)
81+
```
82+
83+
#### Options for Symbol Enums:
84+
85+
- `global`: Create a global symbol using Symbol.for().
86+
87+
##### Example:
88+
89+
```
90+
const { blueGlobal } = Enum.Symbol({ global: true });
91+
console.log(blueGlobal); // Outputs: Symbol.for('blueGlobal')
6392
```

0 commit comments

Comments
 (0)