@xylabs/enum 5.0.94 → 5.0.96
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.
- package/README.md +66 -81
- package/package.json +9 -10
package/README.md
CHANGED
|
@@ -1,52 +1,59 @@
|
|
|
1
1
|
# @xylabs/enum
|
|
2
2
|
|
|
3
|
-
[![
|
|
3
|
+
[![npm][npm-badge]][npm-link]
|
|
4
|
+
[![license][license-badge]][license-link]
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
[![npm-badge][]][npm-link]
|
|
7
|
-
[![npm-downloads-badge][]][npm-link]
|
|
8
|
-
[![jsdelivr-badge][]][jsdelivr-link]
|
|
9
|
-
[![npm-license-badge][]](LICENSE)
|
|
10
|
-
[![codacy-badge][]][codacy-link]
|
|
11
|
-
[![codeclimate-badge][]][codeclimate-link]
|
|
12
|
-
[![snyk-badge][]][snyk-link]
|
|
13
|
-
[![socket-badge][]][socket-link]
|
|
6
|
+
> Base functionality used throughout XY Labs TypeScript/JavaScript libraries
|
|
14
7
|
|
|
8
|
+
## Install
|
|
15
9
|
|
|
16
|
-
|
|
10
|
+
Using npm:
|
|
17
11
|
|
|
12
|
+
```sh
|
|
13
|
+
npm install {{name}}
|
|
14
|
+
```
|
|
18
15
|
|
|
16
|
+
Using yarn:
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
```sh
|
|
19
|
+
yarn add {{name}}
|
|
20
|
+
```
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
Using pnpm:
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
```sh
|
|
25
|
+
pnpm add {{name}}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Using bun:
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
bun add {{name}}
|
|
32
|
+
```
|
|
25
33
|
|
|
26
|
-
## Type Aliases
|
|
27
34
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
35
|
+
## License
|
|
36
|
+
|
|
37
|
+
See the [LICENSE](LICENSE) file for license rights and limitations (LGPL-3.0-only).
|
|
38
|
+
|
|
39
|
+
## Reference
|
|
33
40
|
|
|
34
|
-
|
|
41
|
+
### packages
|
|
35
42
|
|
|
36
|
-
|
|
37
|
-
| ------ | ------ |
|
|
38
|
-
| [Enum](#functions/Enum) | Transforms a given record object into a readonly "enum-like" structure while preserving the literal types of its values. This allows you to use the returned object both at runtime (for lookups) and at compile time (for strongly typed values). |
|
|
43
|
+
### enum
|
|
39
44
|
|
|
40
|
-
###
|
|
45
|
+
### .temp-typedoc
|
|
41
46
|
|
|
42
|
-
|
|
47
|
+
### functions
|
|
48
|
+
|
|
49
|
+
### <a id="Enum"></a>Enum
|
|
43
50
|
|
|
44
51
|
[**@xylabs/enum**](#../README)
|
|
45
52
|
|
|
46
53
|
***
|
|
47
54
|
|
|
48
55
|
```ts
|
|
49
|
-
function Enum<T>(obj
|
|
56
|
+
function Enum<T>(obj): Enum<T>;
|
|
50
57
|
```
|
|
51
58
|
|
|
52
59
|
Transforms a given record object into a readonly "enum-like" structure while preserving
|
|
@@ -58,15 +65,19 @@ ensure you annotate your object with `as const` before passing it to `Enum`.
|
|
|
58
65
|
|
|
59
66
|
## Type Parameters
|
|
60
67
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
68
|
+
### T
|
|
69
|
+
|
|
70
|
+
`T` *extends* `Record`\<`string` \| `number` \| `symbol`, `unknown`\>
|
|
71
|
+
|
|
72
|
+
A record type with string keys and any kind of values.
|
|
64
73
|
|
|
65
74
|
## Parameters
|
|
66
75
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
76
|
+
### obj
|
|
77
|
+
|
|
78
|
+
`Readonly`\<`T`\>
|
|
79
|
+
|
|
80
|
+
A readonly record object annotated with `as const`.
|
|
70
81
|
|
|
71
82
|
## Returns
|
|
72
83
|
|
|
@@ -110,9 +121,9 @@ const DnsRecordType = Enum({
|
|
|
110
121
|
// }
|
|
111
122
|
```
|
|
112
123
|
|
|
113
|
-
### type-aliases
|
|
124
|
+
### type-aliases
|
|
114
125
|
|
|
115
|
-
|
|
126
|
+
### <a id="Enum"></a>Enum
|
|
116
127
|
|
|
117
128
|
[**@xylabs/enum**](#../README)
|
|
118
129
|
|
|
@@ -127,9 +138,11 @@ of that record. This results in a type where all properties of `T` are readonly.
|
|
|
127
138
|
|
|
128
139
|
## Type Parameters
|
|
129
140
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
141
|
+
### T
|
|
142
|
+
|
|
143
|
+
`T` *extends* `Readonly`\<`Record`\<`string` \| `number` \| `symbol`, `unknown`\>\>
|
|
144
|
+
|
|
145
|
+
The record type to make readonly.
|
|
133
146
|
|
|
134
147
|
## Example
|
|
135
148
|
|
|
@@ -154,7 +167,7 @@ export const DnsRecordType = Enum({
|
|
|
154
167
|
export type DnsRecordType = Enum<typeof DnsRecordType>
|
|
155
168
|
```
|
|
156
169
|
|
|
157
|
-
|
|
170
|
+
### <a id="EnumKey"></a>EnumKey
|
|
158
171
|
|
|
159
172
|
[**@xylabs/enum**](#../README)
|
|
160
173
|
|
|
@@ -168,12 +181,15 @@ A utility type that, given an `Enum` object, returns the union of its keys.
|
|
|
168
181
|
|
|
169
182
|
## Type Parameters
|
|
170
183
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
| `K` | [`Enum`](#Enum)\<`T`\> |
|
|
184
|
+
### T
|
|
185
|
+
|
|
186
|
+
`T` *extends* `Record`\<`string` \| `number` \| `symbol`, `unknown`\>
|
|
175
187
|
|
|
176
|
-
|
|
188
|
+
### K
|
|
189
|
+
|
|
190
|
+
`K` = [`Enum`](#Enum)\<`T`\>
|
|
191
|
+
|
|
192
|
+
### <a id="EnumValue"></a>EnumValue
|
|
177
193
|
|
|
178
194
|
[**@xylabs/enum**](#../README)
|
|
179
195
|
|
|
@@ -187,47 +203,16 @@ A utility type that, given an `Enum` object, returns the union of its values.
|
|
|
187
203
|
|
|
188
204
|
## Type Parameters
|
|
189
205
|
|
|
190
|
-
|
|
191
|
-
| ------ | ------ |
|
|
192
|
-
| `T` *extends* `Record`\<`string` \| `number` \| `symbol`, `unknown`\> | - |
|
|
193
|
-
| `K` | [`Enum`](#Enum)\<`T`\> |
|
|
206
|
+
### T
|
|
194
207
|
|
|
208
|
+
`T` *extends* `Record`\<`string` \| `number` \| `symbol`, `unknown`\>
|
|
195
209
|
|
|
196
|
-
|
|
210
|
+
### K
|
|
197
211
|
|
|
198
|
-
|
|
212
|
+
`K` = [`Enum`](#Enum)\<`T`\>
|
|
199
213
|
|
|
200
|
-
- [Arie Trouw](https://github.com/arietrouw) ([arietrouw.com](https://arietrouw.com))
|
|
201
|
-
- [Matt Jones](https://github.com/jonesmac)
|
|
202
|
-
- [Joel Carter](https://github.com/JoelBCarter)
|
|
203
|
-
- [Jordan Trouw](https://github.com/jordantrouw)
|
|
204
|
-
|
|
205
|
-
## License
|
|
206
214
|
|
|
207
|
-
> See the [LICENSE](LICENSE) file for license details
|
|
208
|
-
|
|
209
|
-
## Credits
|
|
210
|
-
|
|
211
|
-
[Made with 🔥 and ❄️ by XYLabs](https://xylabs.com)
|
|
212
|
-
|
|
213
|
-
[logo]: https://cdn.xy.company/img/brand/XYPersistentCompany_Logo_Icon_Colored.svg
|
|
214
|
-
|
|
215
|
-
[main-build]: https://github.com/xylabs/sdk-js/actions/workflows/build.yml/badge.svg
|
|
216
|
-
[main-build-link]: https://github.com/xylabs/sdk-js/actions/workflows/build.yml
|
|
217
215
|
[npm-badge]: https://img.shields.io/npm/v/@xylabs/enum.svg
|
|
218
216
|
[npm-link]: https://www.npmjs.com/package/@xylabs/enum
|
|
219
|
-
[
|
|
220
|
-
[
|
|
221
|
-
[codeclimate-badge]: https://api.codeclimate.com/v1/badges/c5eb068f806f0b047ea7/maintainability
|
|
222
|
-
[codeclimate-link]: https://codeclimate.com/github/xylabs/sdk-js/maintainability
|
|
223
|
-
[snyk-badge]: https://snyk.io/test/github/xylabs/sdk-js/badge.svg?targetFile=package.json
|
|
224
|
-
[snyk-link]: https://snyk.io/test/github/xylabs/sdk-js?targetFile=package.json
|
|
225
|
-
|
|
226
|
-
[npm-downloads-badge]: https://img.shields.io/npm/dw/@xylabs/enum
|
|
227
|
-
[npm-license-badge]: https://img.shields.io/npm/l/@xylabs/enum
|
|
228
|
-
|
|
229
|
-
[jsdelivr-badge]: https://data.jsdelivr.com/v1/package/npm/@xylabs/enum/badge
|
|
230
|
-
[jsdelivr-link]: https://www.jsdelivr.com/package/npm/@xylabs/enum
|
|
231
|
-
|
|
232
|
-
[socket-badge]: https://socket.dev/api/badge/npm/package/@xylabs/enum
|
|
233
|
-
[socket-link]: https://socket.dev/npm/package/@xylabs/enum
|
|
217
|
+
[license-badge]: https://img.shields.io/npm/l/@xylabs/enum.svg
|
|
218
|
+
[license-link]: https://github.com/xylabs/sdk-js/blob/main/LICENSE
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xylabs/enum",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.96",
|
|
4
4
|
"description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
|
|
5
5
|
"homepage": "https://xyo.network",
|
|
6
6
|
"bugs": {
|
|
@@ -22,12 +22,10 @@
|
|
|
22
22
|
"exports": {
|
|
23
23
|
".": {
|
|
24
24
|
"types": "./dist/neutral/index.d.ts",
|
|
25
|
-
"import": "./dist/neutral/index.mjs",
|
|
26
25
|
"default": "./dist/neutral/index.mjs"
|
|
27
26
|
},
|
|
28
27
|
"./package.json": "./package.json"
|
|
29
28
|
},
|
|
30
|
-
"types": "./dist/neutral/index.d.ts",
|
|
31
29
|
"files": [
|
|
32
30
|
"dist",
|
|
33
31
|
"!**/*.bench.*",
|
|
@@ -36,15 +34,16 @@
|
|
|
36
34
|
"README.md"
|
|
37
35
|
],
|
|
38
36
|
"devDependencies": {
|
|
39
|
-
"@types/node": "^25.
|
|
40
|
-
"@xylabs/
|
|
41
|
-
"@xylabs/
|
|
42
|
-
"@xylabs/tsconfig": "~7.7.3",
|
|
43
|
-
"acorn": "^6.0.0 || ^7.0.0 || ^8.0.0",
|
|
37
|
+
"@types/node": "^25.6.0",
|
|
38
|
+
"@xylabs/toolchain": "~7.10.4",
|
|
39
|
+
"@xylabs/tsconfig": "~7.10.4",
|
|
44
40
|
"esbuild": "^0.28.0",
|
|
45
41
|
"typescript": "^5",
|
|
46
|
-
"vite": "^
|
|
47
|
-
"vitest": "^4.1.
|
|
42
|
+
"vite": "^8.0.8",
|
|
43
|
+
"vitest": "^4.1.4"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=18"
|
|
48
47
|
},
|
|
49
48
|
"publishConfig": {
|
|
50
49
|
"access": "public"
|