shinkansen-transmission 2.2.235 → 2.3.1

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 (38) hide show
  1. package/babel.config.cjs +1 -0
  2. package/eslint.config.mjs +28 -30
  3. package/index.d.mts +321 -16
  4. package/package.json +6 -6
  5. package/src/index.cjs +2 -0
  6. package/src/index.d.mts +10 -9
  7. package/src/transmission/common/index.d.mts +153 -87
  8. package/src/transmission/common/index.mjs +670 -175
  9. package/src/transmission/from-document-to-hash/array/index.mjs +20 -4
  10. package/src/transmission/from-document-to-hash/boolean/index.mjs +25 -9
  11. package/src/transmission/from-document-to-hash/index.d.mts +8 -19
  12. package/src/transmission/from-document-to-hash/index.mjs +102 -16
  13. package/src/transmission/from-document-to-hash/null/index.mjs +25 -9
  14. package/src/transmission/from-document-to-hash/number/index.mjs +25 -9
  15. package/src/transmission/from-document-to-hash/object/index.mjs +22 -6
  16. package/src/transmission/from-document-to-hash/string/index.mjs +25 -9
  17. package/src/transmission/from-hash-to-document/array/index.mjs +22 -5
  18. package/src/transmission/from-hash-to-document/boolean/index.mjs +21 -4
  19. package/src/transmission/from-hash-to-document/index.d.mts +24 -26
  20. package/src/transmission/from-hash-to-document/index.mjs +264 -142
  21. package/src/transmission/from-hash-to-document/null/index.mjs +21 -4
  22. package/src/transmission/from-hash-to-document/number/index.mjs +21 -4
  23. package/src/transmission/from-hash-to-document/object/index.mjs +22 -5
  24. package/src/transmission/from-hash-to-document/string/index.mjs +26 -4
  25. package/src/transmission/index.d.mts +4 -10
  26. package/src/transmission/to-zashiki/index.d.mts +5 -13
  27. package/src/transmission/to-zashiki/params/index.mjs +430 -0
  28. package/src/transmission/to-zashiki/render/array/index.mjs +737 -0
  29. package/src/transmission/to-zashiki/render/boolean/index.mjs +794 -0
  30. package/src/transmission/to-zashiki/render/index.mjs +157 -0
  31. package/src/transmission/to-zashiki/render/null/index.mjs +796 -0
  32. package/src/transmission/to-zashiki/render/number/index.mjs +940 -0
  33. package/src/transmission/to-zashiki/render/object/index.mjs +653 -0
  34. package/src/transmission/to-zashiki/render/string/index.mjs +910 -0
  35. package/src/transmission/to-zashiki/render-params/root-schema/index.mjs +212 -0
  36. package/src/transmission/to-zashiki/render-params/schema/index.mjs +731 -0
  37. package/src/transmission/to-zashiki/transform-root-schema.mjs +485 -421
  38. package/src/transmission/to-zashiki/transform-schema.mjs +1988 -4663
@@ -1,3 +1,41 @@
1
+ /**
2
+ * @typedef {TransmissionTypes.ObjectLiteralType} ObjectLiteralType
3
+ * @typedef {TransmissionTypes.ObjectType} ObjectType
4
+ *
5
+ * @typedef {TransmissionTypes.ItemsType} ItemsType
6
+ *
7
+ * @typedef {TransmissionTypes.Transmission.StringMetaType} TransmissionStringMetaType
8
+ * @typedef {TransmissionTypes.Transmission.NumberMetaType} TransmissionNumberMetaType
9
+ * @typedef {TransmissionTypes.Transmission.ArrayMetaType} TransmissionArrayMetaType
10
+ * @typedef {TransmissionTypes.Transmission.ObjectMetaType} TransmissionObjectMetaType
11
+ * @typedef {TransmissionTypes.Transmission.BooleanMetaType} TransmissionBooleanMetaType
12
+ * @typedef {TransmissionTypes.Transmission.NullMetaType} TransmissionNullMetaType
13
+ *
14
+ * @typedef {TransmissionTypes.Transmission.StringElementsType} TransmissionStringElementsType
15
+ * @typedef {TransmissionTypes.Transmission.NumberElementsType} TransmissionNumberElementsType
16
+ * @typedef {TransmissionTypes.Transmission.ArrayElementsType} TransmissionArrayElementsType
17
+ * @typedef {TransmissionTypes.Transmission.ObjectElementsType} TransmissionObjectElementsType
18
+ * @typedef {TransmissionTypes.Transmission.BooleanElementsType} TransmissionBooleanElementsType
19
+ * @typedef {TransmissionTypes.Transmission.NullElementsType} TransmissionNullElementsType
20
+ *
21
+ * @typedef {TransmissionTypes.EnumType} EnumType
22
+ * @typedef {TransmissionTypes.AnyOfType} AnyOfType
23
+ * @typedef {TransmissionTypes.OneOfType} OneOfType
24
+ * @typedef {TransmissionTypes.FieldType} FieldType
25
+ *
26
+ * @typedef {TransmissionTypes.SchemaType} SchemaType
27
+ *
28
+ * @typedef {TransmissionTypes.StringSchemaType} StringSchemaType
29
+ * @typedef {TransmissionTypes.NumberSchemaType} NumberSchemaType
30
+ * @typedef {TransmissionTypes.ArraySchemaType} ArraySchemaType
31
+ * @typedef {TransmissionTypes.ObjectSchemaType} ObjectSchemaType
32
+ * @typedef {TransmissionTypes.BooleanSchemaType} BooleanSchemaType
33
+ * @typedef {TransmissionTypes.NullSchemaType} NullSchemaType
34
+ *
35
+ * @typedef {TransmissionTypes.ValuesType} ValuesType
36
+ * @typedef {TransmissionTypes.ParamsType} ParamsType
37
+ */
38
+
1
39
  import debug from 'debug'
2
40
 
3
41
  import equal from 'fast-deep-equal'
@@ -6,41 +44,111 @@ const log = debug('shinkansen-transmission/transmission/common')
6
44
 
7
45
  log('`shinkansen` is awake')
8
46
 
47
+ /**
48
+ * @param {unknown} [v]
49
+ * @returns {v is (Record<PropertyKey, string | number | object | boolean | null | string[] | number[] | object[] | boolean[] | null[]> | Record<PropertyKey, never>)}
50
+ */
9
51
  export const isObject = (v) => (v || false) instanceof Object && !isArray(v)
10
52
 
53
+ /**
54
+ * @param {unknown} [v]
55
+ * @returns {v is (string[] | number[] | object[] | boolean[] | null[])} // | SchemaType)[]}
56
+ */
11
57
  export const isArray = (v) => Array.isArray(v)
12
58
 
59
+ /**
60
+ * @param {unknown} [v]
61
+ * @returns {v is (string | number | boolean | null)}
62
+ */
13
63
  export const isPrimitive = (v) => !isObject(v) && !isArray(v)
14
64
 
15
- export const isSchema = (v = {}) => Reflect.has(v, 'type')
65
+ /**
66
+ * @param {SchemaType | object} [v]
67
+ * @returns {v is SchemaType}
68
+ */
69
+ export const isSchema = (v = {}) => 'type' in v // Reflect.has(v, 'type')
16
70
 
71
+ /**
72
+ * @param {SchemaType} schema
73
+ * @returns {schema is StringSchemaType}
74
+ */
17
75
  export const isStringSchema = ({ type } = {}) => type === 'string'
18
76
 
77
+ /**
78
+ * @param {SchemaType} schema
79
+ * @returns {schema is NumberSchemaType}
80
+ */
19
81
  export const isNumberSchema = ({ type } = {}) => type === 'number'
20
82
 
83
+ /**
84
+ * @param {SchemaType} schema
85
+ * @returns {schema is ArraySchemaType}
86
+ */
21
87
  export const isArraySchema = ({ type } = {}) => type === 'array'
22
88
 
89
+ /**
90
+ * @param {SchemaType} schema
91
+ * @returns {schema is ObjectSchemaType}
92
+ */
23
93
  export const isObjectSchema = ({ type } = {}) => type === 'object'
24
94
 
95
+ /**
96
+ * @param {SchemaType} schema
97
+ * @returns {schema is BooleanSchemaType}
98
+ */
25
99
  export const isBooleanSchema = ({ type } = {}) => type === 'boolean'
26
100
 
101
+ /**
102
+ * @param {SchemaType} schema
103
+ * @returns {schema is NullSchemaType}
104
+ */
27
105
  export const isNullSchema = ({ type } = {}) => type === 'null'
28
106
 
107
+ /**
108
+ * @param {SchemaType} schema
109
+ * @returns {{ title: string} | {}}
110
+ */
29
111
  export const getTitle = ({ title } = {}) => (title ? { title } : {})
30
112
 
113
+ /**
114
+ * @param {SchemaType} schema
115
+ * @returns {{ description: string} | {}}
116
+ */
31
117
  export const getDescription = ({ description } = {}) => (description ? { description } : {})
32
118
 
119
+ /**
120
+ * @param {SchemaType} schema
121
+ * @returns {{ readOnly: boolean } | {}}
122
+ */
33
123
  export const getIsReadOnly = ({ readOnly = false } = {}) => (readOnly ? { readOnly } : {})
34
124
 
125
+ /**
126
+ * @param {SchemaType} schema
127
+ * @returns {{ writeOnly: boolean } | {}}
128
+ */
35
129
  export const getIsWriteOnly = ({ writeOnly = false } = {}) => (writeOnly ? { writeOnly } : {})
36
130
 
37
- const getUriForRegExp = (uri) => uri.endsWith('/') ? uri : uri.concat('/')
38
-
131
+ /**
132
+ * @param {string} uri
133
+ * @returns {string}
134
+ */
135
+ const getUriForRegExp = (uri) => uri.endsWith('/') ? uri : uri + '/'
136
+
137
+ /**
138
+ * @param {Record<string, string | number | boolean | null | string[] | number[] | boolean[] | null[]>} [values]
139
+ * @param {string} [uri]
140
+ * @returns {(
141
+ * string |
142
+ * number |
143
+ * boolean |
144
+ * null
145
+ * )[]}
146
+ */
39
147
  export function getSelectedItems (values = {}, uri = '#') {
40
148
  const u = normaliseUri(uri)
41
149
 
42
- if (Reflect.has(values, u)) {
43
- const v = Reflect.get(values, u)
150
+ if (u in values) { // if (Reflect.has(values, u)) {
151
+ const v = values[u] // Reflect.get(values, u)
44
152
 
45
153
  // transformByKeyForEnum
46
154
  // transformByKeyForAnyOf
@@ -83,12 +191,18 @@ export function getSelectedItems (values = {}, uri = '#') {
83
191
  const v = isArray(value) ? value[i] : value
84
192
  const n = Number(v)
85
193
 
86
- if (!isNaN(n)) return n
87
- return v
194
+ return isNaN(n)
195
+ ? v
196
+ : n
88
197
  })
89
198
  )
90
199
  }
91
200
 
201
+ /**
202
+ * @param {string} [parentUri]
203
+ * @param {string} [uri]
204
+ * @returns {boolean}
205
+ */
92
206
  export function isParentUri (parentUri = '#', uri = '#') {
93
207
  return (
94
208
  parentUri !== '#' &&
@@ -96,20 +210,44 @@ export function isParentUri (parentUri = '#', uri = '#') {
96
210
  )
97
211
  }
98
212
 
213
+ /**
214
+ * @param {ParamsType} [params]
215
+ * @param {string} [uri]
216
+ * @returns {TransmissionStringMetaType | TransmissionNumberMetaType | TransmissionArrayMetaType | TransmissionObjectMetaType | TransmissionBooleanMetaType | TransmissionNullMetaType | Record<string, never>}
217
+ */
99
218
  export function getMetaProps (params = {}, uri = '#') {
100
- let meta
101
- if (Reflect.has(params, uri)) {
102
- ({
103
- meta
104
- } = Reflect.get(params, uri))
219
+ if (uri in params) { // if (Reflect.has(params, uri)) {
220
+ const {
221
+ meta = {}
222
+ } = params[uri] // Reflect.get(params, uri))
223
+
224
+ return meta
225
+ }
226
+
227
+ return {}
228
+ }
229
+
230
+ /**
231
+ * @param {SchemaType} [schema]
232
+ * @returns {boolean}
233
+ */
234
+ export function hasMetaDefaultValue (schema = {}) {
235
+ if ('default' in schema) { // if (Reflect.has(schema, 'default') {
236
+ const defaultValue = schema.default // Reflect.get(schema, 'default')
237
+
238
+ return isPrimitive(defaultValue)
105
239
  }
106
240
 
107
- return meta || {}
241
+ return false
108
242
  }
109
243
 
244
+ /**
245
+ * @param {SchemaType} [schema]
246
+ * @returns {{ defaultValue: string } | {}}
247
+ */
110
248
  export function getMetaDefaultValue (schema = {}) {
111
- if (Reflect.has(schema, 'default')) {
112
- const defaultValue = Reflect.get(schema, 'default')
249
+ if ('default' in schema) { // if (Reflect.has(schema, 'default') {
250
+ const defaultValue = schema.default // Reflect.get(schema, 'default')
113
251
 
114
252
  return { defaultValue: String(defaultValue) }
115
253
  }
@@ -117,15 +255,21 @@ export function getMetaDefaultValue (schema = {}) {
117
255
  return {}
118
256
  }
119
257
 
258
+ /**
259
+ * @param {ValuesType} [values]
260
+ * @param {string} [uri]
261
+ * @param {SchemaType} [schema]
262
+ * @returns {boolean}
263
+ */
120
264
  export function hasMetaValue (values = {}, uri = '#', schema = {}) {
121
- if (Reflect.has(values, uri)) {
122
- const value = Reflect.get(values, uri)
265
+ if (uri in values) { // Reflect.has(values, uri)) {
266
+ const value = values[uri] // Reflect.get(values, uri)
123
267
 
124
268
  return isPrimitive(value)
125
269
  }
126
270
 
127
- if (Reflect.has(schema, 'const')) {
128
- const constValue = Reflect.get(schema, 'const')
271
+ if ('const' in schema) { // Reflect.has(schema, 'const')) {
272
+ const constValue = schema.const // Reflect.get(schema, 'const')
129
273
 
130
274
  return isPrimitive(constValue)
131
275
  }
@@ -133,17 +277,23 @@ export function hasMetaValue (values = {}, uri = '#', schema = {}) {
133
277
  return false
134
278
  }
135
279
 
280
+ /**
281
+ * @param {ValuesType} [values]
282
+ * @param {string} [uri]
283
+ * @param {SchemaType} [schema]
284
+ * @returns {{ value: string } | {}}
285
+ */
136
286
  export function getMetaValue (values = {}, uri = '#', schema = {}) {
137
- if (Reflect.has(values, uri)) {
138
- const value = Reflect.get(values, uri)
287
+ if (uri in values) { // if (Reflect.has(values, uri)) {
288
+ const value = values[uri] // Reflect.get(values, uri)
139
289
 
140
290
  if (isPrimitive(value)) {
141
291
  return { value: String(value) }
142
292
  }
143
293
  }
144
294
 
145
- if (Reflect.has(schema, 'const')) {
146
- const constValue = Reflect.get(schema, 'const')
295
+ if ('const' in schema) { // if (Reflect.has(schema, 'const')) {
296
+ const constValue = schema.const // Reflect.get(schema, 'const')
147
297
 
148
298
  if (isPrimitive(constValue)) {
149
299
  return { value: String(constValue) }
@@ -153,18 +303,31 @@ export function getMetaValue (values = {}, uri = '#', schema = {}) {
153
303
  return {}
154
304
  }
155
305
 
156
- export function transformValue (schema) {
157
- return (
158
- isObject(schema)
159
- ? hasConst(schema)
160
- ? getConst(schema)
161
- : hasDefault(schema)
162
- ? getDefault(schema)
163
- : schema
164
- : schema
165
- )
306
+ /**
307
+ * @param {string | number | object | boolean | null} [item]
308
+ * @returns {string | number | object | boolean | null | undefined}
309
+ */
310
+ export function transformToValue (item) {
311
+ if (isPrimitive(item)) return item
312
+
313
+ if (isObject(item)) {
314
+ if (hasConst(item)) {
315
+ return getConst(item)
316
+ } else {
317
+ if (hasDefault(item)) {
318
+ return getDefault(item)
319
+ }
320
+ }
321
+ }
322
+
323
+ return item
166
324
  }
167
325
 
326
+ /**
327
+ * @param {string} parentUri
328
+ * @param {string} uri
329
+ * @returns {(key: string | number) => boolean}
330
+ */
168
331
  export function findByKey (parentUri, uri) {
169
332
  /*
170
333
  * log('findByKey')
@@ -173,62 +336,106 @@ export function findByKey (parentUri, uri) {
173
336
  /*
174
337
  * log('find')
175
338
  */
176
- return getUri(parentUri, key) === uri
339
+
340
+ return (
341
+ getUri(parentUri, key) === uri
342
+ )
177
343
  }
178
344
  }
179
345
 
346
+ /**
347
+ * @param {string} parentUri
348
+ * @param {string} uri
349
+ * @returns {(item: SchemaType, index: number) => boolean}
350
+ */
180
351
  export function findByIndex (parentUri, uri) {
181
352
  /*
182
353
  * log('findByIndex')
183
354
  */
184
- return function find (schema, index) {
355
+ return function find (item, index) {
185
356
  /*
186
357
  * log('find')
187
358
  */
188
- if (hasEnum(schema)) {
189
- return getUri(parentUri, index) === uri
190
- }
191
359
 
192
- if (hasAnyOf(schema)) {
193
- const array = getAnyOf(schema)
360
+ /**
361
+ * It's a schema not a value
362
+ */
194
363
 
195
- return array.find(findByIndex(parentUri, uri))
364
+ if (hasEnum(item)) {
365
+ /**
366
+ * Do the `parentUri` and `uri` match?
367
+ */
368
+
369
+ return (
370
+ getUri(parentUri, index) === uri
371
+ )
372
+ } else {
373
+ if (hasAnyOf(item)) {
374
+ const array = getAnyOf(item)
375
+
376
+ return (
377
+ array.filter(isObject).some(findByIndex(parentUri, uri))
378
+ )
379
+ } else {
380
+ if (hasOneOf(item)) {
381
+ const array = getOneOf(item)
382
+
383
+ return (
384
+ array.filter(isObject).some(findByIndex(parentUri, uri))
385
+ )
386
+ }
387
+ }
196
388
  }
197
389
 
198
- if (hasOneOf(schema)) {
199
- const array = getOneOf(schema)
200
-
201
- return array.find(findByIndex(parentUri, uri))
202
- }
390
+ /**
391
+ * It's any other kind of schema/sub-schema
392
+ */
203
393
 
204
- return getUri(parentUri, index) === uri
394
+ return (
395
+ getUri(parentUri, index) === uri
396
+ )
205
397
  }
206
398
  }
207
399
 
400
+ /**
401
+ * @param {string | number | object | boolean | null} [value]
402
+ * @returns {(item?: string | number | object | boolean | null | string[] | number[] | object[] | boolean[] | null[]) => boolean}
403
+ */
208
404
  export function findByValue (value) {
209
405
  /*
210
406
  * log('findByValue')
211
407
  */
212
- return function find (schema) {
408
+ return function find (item) {
213
409
  /*
214
410
  * log('find')
215
411
  */
216
- return value === transformValue(schema)
412
+
413
+ return (
414
+ value === transformToValue(item)
415
+ )
217
416
  }
218
417
  }
219
418
 
419
+ /**
420
+ * @param {string | number | object | boolean | null} [value]
421
+ * @returns {(item?: string | number | object | boolean | null | string[] | number[] | object[] | boolean[] | null[]) => boolean}
422
+ */
220
423
  export function findByEqual (value) {
221
424
  /*
222
425
  * log('findByEqual')
223
426
  */
224
- return function find (schema) {
427
+ return function find (item) {
225
428
  /*
226
429
  * log('find')
227
430
  */
228
- return equal(value, transformValue(schema))
431
+ return equal(value, transformToValue(item))
229
432
  }
230
433
  }
231
434
 
435
+ /**
436
+ * @param {string | number | object | boolean | null} [value]
437
+ * @returns {string}
438
+ */
232
439
  export function toString (value) {
233
440
  /*
234
441
  * log('toString')
@@ -236,57 +443,114 @@ export function toString (value) {
236
443
  return (value !== undefined) ? String(value) : ''
237
444
  }
238
445
 
239
- export function getObject ({ properties = {} /* object */ } = {}, parentUri = '', uri = '') {
446
+ /**
447
+ * @param {{ items?: SchemaType | SchemaType[] }} [schema]
448
+ * @param {string} parentUri
449
+ * @param {string} uri
450
+ * @returns {SchemaType | undefined}
451
+ */
452
+ export function getArray ({ items /* array or object */ } = {}, parentUri = '', uri = '') {
240
453
  /*
241
- * log('getObject')
454
+ * log('getArray')
242
455
  */
243
- return (
244
- Reflect.get(properties, (
245
- Object.keys(properties)
246
- .find(findByKey(parentUri, uri))
247
- ))
248
- )
456
+
457
+ if (isArray(items)) {
458
+ const find = findByIndex(parentUri, uri)
459
+
460
+ return (
461
+ items.find(find)
462
+ )
463
+ }
464
+
465
+ if (isObject(items)) return items
466
+
467
+ return undefined
249
468
  }
250
469
 
251
- export function getArray ({ items = {} /* array or object */ } = {}, parentUri = '', uri = '') {
470
+ /**
471
+ * @param {{ properties?: Record<string, SchemaType> }} [schema]
472
+ * @param {string} [parentUri]
473
+ * @param {string} [uri]
474
+ * @returns {SchemaType | undefined}
475
+ */
476
+ export function getObject ({ properties /* object */ } = {}, parentUri = '', uri = '') {
252
477
  /*
253
- * log('getArray')
478
+ * log('getObject')
254
479
  */
255
- return (isArray(items))
256
- ? items.find(findByIndex(parentUri, uri))
257
- : items
480
+
481
+ if (isObject(properties)) {
482
+ const find = findByKey(parentUri, uri)
483
+ const key = Object.keys(properties).find(find)
484
+
485
+ if (key) {
486
+ return (
487
+ properties[key]
488
+ )
489
+ }
490
+ }
491
+
492
+ return undefined
258
493
  }
259
494
 
495
+ /**
496
+ * @overload
497
+ * @param {(
498
+ * StringSchemaType |
499
+ * NumberSchemaType |
500
+ * ArraySchemaType |
501
+ * ObjectSchemaType |
502
+ * BooleanSchemaType |
503
+ * NullSchemaType
504
+ * )} schema
505
+ * @param {string} [parentUri]
506
+ * @param {string} [uri]
507
+ * @returns {SchemaType | undefined}
508
+ *
509
+ *
510
+ * @param {*} [schema]
511
+ * @param {string} [parentUri]
512
+ * @param {string} [uri]
513
+ * @returns {* | undefined}
514
+ */
260
515
  export function getSchema (schema = {}, parentUri = '', uri = '') {
261
516
  /*
262
517
  * log('getSchema')
263
518
  */
264
- const { type } = schema
265
519
 
266
- switch (type) {
267
- case 'object':
268
- return getObject(schema, parentUri, uri)
520
+ const {
521
+ type
522
+ } = schema
269
523
 
524
+ switch (type) {
270
525
  case 'array':
271
526
  return getArray(schema, parentUri, uri)
272
527
 
528
+ case 'object':
529
+ return getObject(schema, parentUri, uri)
530
+
273
531
  default:
274
532
  return schema
275
533
  }
276
534
  }
277
535
 
536
+ /**
537
+ * @param {string[] | number[] | object[] | boolean[] | null[]} array
538
+ * @param {string | number | object | boolean | null} [value]
539
+ * @returns {string}
540
+ */
278
541
  export function transformValueIndexFor (array, value) {
279
542
  /*
280
- * log('transformValueIndexFor')
543
+ * log('transformEqualIndexFor')
281
544
  */
545
+
282
546
  const find = findByValue(value)
283
547
 
284
548
  if (array.some(find)) {
285
549
  const index = array.findIndex(find)
286
550
 
287
551
  /*
288
- * Transform a number to a string
289
- */
552
+ * Transform a number to a string
553
+ */
290
554
  return String(index)
291
555
  }
292
556
 
@@ -296,10 +560,16 @@ export function transformValueIndexFor (array, value) {
296
560
  return toString(value)
297
561
  }
298
562
 
563
+ /**
564
+ * @param {string[] | number[] | object[] | boolean[] | null[]} array
565
+ * @param {string | number | object | boolean | null} [value]
566
+ * @returns {string}
567
+ */
299
568
  export function transformEqualIndexFor (array, value) {
300
569
  /*
301
570
  * log('transformEqualIndexFor')
302
571
  */
572
+
303
573
  const find = findByEqual(value)
304
574
 
305
575
  if (array.some(find)) {
@@ -317,15 +587,21 @@ export function transformEqualIndexFor (array, value) {
317
587
  return toString(value)
318
588
  }
319
589
 
590
+ /**
591
+ * @param {ValuesType} [values]
592
+ * @param {string} [uri]
593
+ * @param {SchemaType} [schema]
594
+ * @returns {boolean}
595
+ */
320
596
  export function hasValue (values = {}, uri = '#', schema = {}) {
321
- if (Reflect.has(values, uri)) {
322
- const value = Reflect.get(values, uri)
597
+ if (uri in values) { // if (Reflect.has(values, uri)) {
598
+ const value = values[uri] // Reflect.get(values, uri)
323
599
 
324
600
  return isPrimitive(value)
325
601
  }
326
602
 
327
- if (Reflect.has(schema, 'const')) {
328
- const constValue = Reflect.get(schema, 'const')
603
+ if ('const' in schema) { // if (Reflect.has(schema, 'const')) {
604
+ const constValue = schema.const // Reflect.get(schema, 'const')
329
605
 
330
606
  return isPrimitive(constValue)
331
607
  }
@@ -333,34 +609,53 @@ export function hasValue (values = {}, uri = '#', schema = {}) {
333
609
  return false
334
610
  }
335
611
 
612
+ /**
613
+ * @param {ValuesType} [values]
614
+ * @param {string} [uri]
615
+ * @param {SchemaType} [schema]
616
+ * @returns {string}
617
+ */
336
618
  export function getValue (values = {}, uri = '#', schema = {}) {
337
- if (Reflect.has(values, uri)) {
338
- const value = Reflect.get(values, uri)
619
+ if (uri in values) { // if (Reflect.has(values, uri)) {
620
+ const value = values[uri] // Reflect.get(values, uri)
339
621
 
340
622
  if (isPrimitive(value)) {
341
623
  return String(value)
342
624
  }
343
625
  }
344
626
 
345
- if (Reflect.has(schema, 'const')) {
346
- const constValue = Reflect.get(schema, 'const')
627
+ if ('const' in schema) { // if (Reflect.has(schema, 'const')) {
628
+ const constValue = schema.const // Reflect.get(schema, 'const')
347
629
 
348
630
  if (isPrimitive(constValue)) {
349
631
  return String(constValue)
350
632
  }
351
633
  }
634
+
635
+ return ''
352
636
  }
353
637
 
638
+ /**
639
+ * @deprecated
640
+ *
641
+ * @param {string | number} v
642
+ * @param {{ enum?: ItemsType }} [schema]
643
+ * @returns {string}
644
+ */
354
645
  export function getValueForEnum (v, { enum: items = [] } = {}) {
355
- if (Reflect.has(items, v)) {
356
- const enumValue = Reflect.get(items, v)
646
+ if (v in items) { // @ts-ignore // if (Reflect.has(items, v)) {
647
+ const enumValue = items[v] // Reflect.get(items, v)
357
648
 
358
649
  return String(enumValue)
359
650
  }
651
+
652
+ return ''
360
653
  }
361
654
 
362
- /*
655
+ /**
363
656
  * Use `index` `item` `arrayIndex`
657
+ *
658
+ * @deprecated
364
659
  */
365
660
  export function getIndexForEnum (values = {}, parentUri = '#', uri = '#', schema = {}) {
366
661
  if (/\/\d+$/.test(uri)) {
@@ -373,20 +668,31 @@ export function getIndexForEnum (values = {}, parentUri = '#', uri = '#', schema
373
668
  return NaN
374
669
  }
375
670
 
671
+ /**
672
+ * @deprecated
673
+ *
674
+ * @param {string | number} v
675
+ * @param {{ anyOf?: ItemsType }} [schema]
676
+ * @returns {string}
677
+ */
376
678
  export function getValueForAnyOf (v, { anyOf: items = [] } = {}) {
377
- if (Reflect.has(items, v)) {
378
- const anyOf = Reflect.get(items, v)
679
+ if (v in items) { // @ts-ignore // if (Reflect.has(items, v)) {
680
+ const anyOf = items[v] // Reflect.get(items, v)
379
681
 
380
- const anyOfValue = transformValue(anyOf)
682
+ const anyOfValue = transformToValue(anyOf)
381
683
 
382
684
  if (isPrimitive(anyOfValue)) {
383
685
  return String(anyOfValue)
384
686
  }
385
687
  }
688
+
689
+ return ''
386
690
  }
387
691
 
388
- /*
692
+ /**
389
693
  * Use `index` `item` `arrayIndex`
694
+ *
695
+ * @deprecated
390
696
  */
391
697
  export function getIndexForAnyOf (values = {}, parentUri = '#', uri = '#', schema = {}) {
392
698
  if (/\/\d+$/.test(uri)) {
@@ -399,20 +705,31 @@ export function getIndexForAnyOf (values = {}, parentUri = '#', uri = '#', schem
399
705
  return NaN
400
706
  }
401
707
 
708
+ /**
709
+ * @deprecated
710
+ *
711
+ * @param {string | number} v
712
+ * @param {{ oneOf?: ItemsType }} [schema]
713
+ * @returns {string}
714
+ */
402
715
  export function getValueForOneOf (v, { oneOf: items = [] } = {}) {
403
- if (Reflect.has(items, v)) {
404
- const oneOf = Reflect.get(items, v)
716
+ if (v in items) { // @ts-ignore // if (Reflect.has(items, v)) {
717
+ const oneOf = items[v] // Reflect.get(items, v)
405
718
 
406
- const oneOfValue = transformValue(oneOf)
719
+ const oneOfValue = transformToValue(oneOf)
407
720
 
408
721
  if (isPrimitive(oneOfValue)) {
409
722
  return String(oneOfValue)
410
723
  }
411
724
  }
725
+
726
+ return ''
412
727
  }
413
728
 
414
- /*
729
+ /**
415
730
  * Use `index` `item` `arrayIndex`
731
+ *
732
+ * @deprecated
416
733
  */
417
734
  export function getIndexForOneOf (values = {}, parentUri = '#', uri = '#', schema = {}) {
418
735
  if (/\/\d+$/.test(uri)) {
@@ -425,127 +742,158 @@ export function getIndexForOneOf (values = {}, parentUri = '#', uri = '#', schem
425
742
  return NaN
426
743
  }
427
744
 
745
+ /**
746
+ * @param {ParamsType} [params]
747
+ * @param {string} [uri]
748
+ * @returns {TransmissionStringElementsType | TransmissionNumberElementsType | TransmissionArrayElementsType | TransmissionObjectElementsType | TransmissionBooleanElementsType | TransmissionNullElementsType | Record<string, never>}
749
+ */
428
750
  export function getElementsProps (params = {}, uri = '#') {
429
- let elements
430
- if (Reflect.has(params, uri)) {
431
- ({
751
+ if (uri in params) { // if (Reflect.has(values, uri)) {
752
+ const {
432
753
  elements = {}
433
- } = Reflect.get(params, uri))
434
- }
754
+ } = params[uri] // Reflect.get(values, uri)
435
755
 
436
- return elements || {}
437
- }
438
-
439
- export function getElementsTitleProps (params = {}, uri = '#') {
440
- let title
441
- if (Reflect.has(params, uri)) {
442
- ({
443
- elements: {
444
- title
445
- } = {}
446
- } = Reflect.get(params, uri))
447
- }
448
-
449
- return title || {}
450
- }
451
-
452
- export function getElementsDescriptionProps (params = {}, uri = '#') {
453
- let description
454
- if (Reflect.has(params, uri)) {
455
- ({
456
- elements: {
457
- description
458
- } = {}
459
- } = Reflect.get(params, uri))
756
+ return elements
460
757
  }
461
758
 
462
- return description || {}
759
+ return {}
463
760
  }
464
761
 
762
+ /**
763
+ * @param {ParamsType} [params]
764
+ * @param {string} [uri]
765
+ * @returns {EnumType | ObjectLiteralType}
766
+ */
465
767
  export function getElementsFieldPropsForEnum (params = {}, uri = '#') {
466
- let field
467
- if (Reflect.has(params, uri)) {
468
- ({
768
+ if (uri in params) { // if (Reflect.has(values, uri)) {
769
+ /**
770
+ * @type {{ elements?: { enum?: EnumType | ObjectLiteralType } }}
771
+ */
772
+ const {
469
773
  elements: {
470
- enum: field
774
+ enum: value = {}
471
775
  } = {}
472
- } = Reflect.get(params, uri))
776
+ } = params[uri] // Reflect.get(values, uri)
777
+
778
+ return value
473
779
  }
474
780
 
475
- return field || {}
781
+ return {}
476
782
  }
477
783
 
784
+ /**
785
+ * @param {ParamsType} [params]
786
+ * @param {string} [uri]
787
+ * @returns {OneOfType | ObjectLiteralType}
788
+ */
478
789
  export function getElementsFieldPropsForOneOf (params = {}, uri = '#') {
479
- let field
480
- if (Reflect.has(params, uri)) {
481
- ({
790
+ if (uri in params) { // if (Reflect.has(values, uri)) {
791
+ /**
792
+ * @type {{ elements?: { oneOf?: OneOfType | ObjectLiteralType } }}
793
+ */
794
+ const {
482
795
  elements: {
483
- oneOf: field
796
+ oneOf: value = {}
484
797
  } = {}
485
- } = Reflect.get(params, uri))
798
+ } = params[uri] // Reflect.get(values, uri)
799
+
800
+ return value
486
801
  }
487
802
 
488
- return field || {}
803
+ return {}
489
804
  }
490
805
 
806
+ /**
807
+ * @param {ParamsType} [params]
808
+ * @param {string} [uri]
809
+ * @returns {AnyOfType | ObjectLiteralType}
810
+ */
491
811
  export function getElementsFieldPropsForAnyOf (params = {}, uri = '#') {
492
- let field
493
- if (Reflect.has(params, uri)) {
494
- ({
812
+ if (uri in params) { // if (Reflect.has(values, uri)) {
813
+ /**
814
+ * @type {{ elements?: { anyOf?: AnyOfType | ObjectLiteralType } }}
815
+ */
816
+ const {
495
817
  elements: {
496
- anyOf: field
818
+ anyOf: value = {}
497
819
  } = {}
498
- } = Reflect.get(params, uri))
820
+ } = params[uri] // Reflect.get(values, uri)
821
+
822
+ return value
499
823
  }
500
824
 
501
- return field || {}
825
+ return {}
502
826
  }
503
827
 
828
+ /**
829
+ * @param {ParamsType} [params]
830
+ * @param {string} [uri]
831
+ * @returns {FieldType | ObjectLiteralType}
832
+ */
504
833
  export function getElementsFieldPropsForAllOf (params = {}, uri = '#') {
505
- let field
506
- if (Reflect.has(params, uri)) {
507
- ({
834
+ if (uri in params) { // if (Reflect.has(values, uri)) {
835
+ /**
836
+ * @type {{ elements?: { field?: FieldType | ObjectLiteralType } }}
837
+ */
838
+ const {
508
839
  elements: {
509
- field
840
+ field: value = {}
510
841
  } = {}
511
- } = Reflect.get(params, uri))
842
+ } = params[uri] // Reflect.get(values, uri)
843
+
844
+ return value
512
845
  }
513
846
 
514
- return field || {}
847
+ return {}
515
848
  }
516
849
 
850
+ /**
851
+ * @param {ParamsType} [params]
852
+ * @param {string} [uri]
853
+ * @returns {FieldType | ObjectLiteralType}
854
+ */
517
855
  export function getElementsFieldProps (params = {}, uri = '#') {
518
- let field
519
- if (Reflect.has(params, uri)) {
520
- ({
856
+ if (uri in params) { // if (Reflect.has(values, uri)) {
857
+ /**
858
+ * @type {{ elements?: { field?: FieldType | ObjectLiteralType } }}
859
+ */
860
+ const {
521
861
  elements: {
522
- field
862
+ field: value = {}
523
863
  } = {}
524
- } = Reflect.get(params, uri))
864
+ } = params[uri] // Reflect.get(values, uri)
865
+
866
+ return value
525
867
  }
526
868
 
527
- return field || {}
869
+ return {}
528
870
  }
529
871
 
872
+ /**
873
+ * @param {ValuesType} [values]
874
+ * @param {string} [uri]
875
+ * @param {SchemaType} [schema]
876
+ * @returns {{ value: string } | {}}
877
+ */
530
878
  export function getElementsFieldValue (values = {}, uri = '#', schema = {}) {
531
- if (Reflect.has(values, uri)) {
532
- const value = Reflect.get(values, uri)
879
+ if (uri in values) { // (Reflect.has(values, uri)) {
880
+ const value = values[uri] // Reflect.get(values, uri)
533
881
 
534
882
  if (isPrimitive(value)) {
535
883
  return { value: String(value) }
536
884
  }
537
885
  }
538
886
 
539
- if (Reflect.has(schema, 'const')) {
540
- const constValue = Reflect.get(schema, 'const')
887
+ if ('const' in schema) { // Reflect.has(schema, 'const')) {
888
+ const constValue = schema.const // Reflect.get(schema, 'const')
541
889
 
542
890
  if (isPrimitive(constValue)) {
543
891
  return { value: String(constValue) }
544
892
  }
545
893
  }
546
894
 
547
- if (Reflect.has(schema, 'default')) {
548
- const defaultValue = Reflect.get(schema, 'default')
895
+ if ('default' in schema) { // Reflect.has(schema, 'default')) {
896
+ const defaultValue = schema.default // Reflect.get(schema, 'default')
549
897
 
550
898
  if (isPrimitive(defaultValue)) {
551
899
  return { value: String(defaultValue) }
@@ -555,67 +903,182 @@ export function getElementsFieldValue (values = {}, uri = '#', schema = {}) {
555
903
  return {}
556
904
  }
557
905
 
558
- export const hasEnum = (schema = {}) => Reflect.has(schema, 'enum')
559
- export const getEnum = (schema = {}) => Reflect.get(schema, 'enum')
906
+ /**
907
+ * @param {{ 'enum'?: ItemsType }} [schema]
908
+ * @returns {schema is { 'enum': ItemsType }}
909
+ */
910
+ export const hasEnum = (schema = {}) => 'enum' in schema // Reflect.has(schema, 'enum')
911
+
912
+ /**
913
+ * @overload
914
+ * @param {{ 'enum': ItemsType }} schema
915
+ * @returns {ItemsType}
916
+ *
917
+ * @param {{ 'enum'?: ItemsType }} [schema]
918
+ * @returns {ItemsType | undefined}
919
+ */
920
+ export const getEnum = (schema = {}) => schema.enum // Reflect.get(schema, 'enum')
560
921
 
561
- export const hasConst = (schema = {}) => Reflect.has(schema, 'const')
562
- export const getConst = (schema = {}) => Reflect.get(schema, 'const')
922
+ /**
923
+ * @param {{ 'const'?: string | number | object | boolean | null }} [schema]
924
+ * @returns {schema is { 'const': string | number | object | boolean | null }}
925
+ */
926
+ export const hasConst = (schema = {}) => 'const' in schema // Reflect.has(schema, 'const')
927
+
928
+ /**
929
+ * @overload
930
+ * @param {{ 'const': string | number | object | boolean | null }} schema
931
+ * @returns {string | number | object | boolean | null}
932
+ *
933
+ * @param {{ 'const'?: string | number | object | boolean | null }} [schema]
934
+ * @returns {string | number | object | boolean | null | undefined}
935
+ */
936
+ export const getConst = (schema = {}) => schema.const // Reflect.get(schema, 'const')
563
937
 
564
- export const hasDefault = (schema = {}) => Reflect.has(schema, 'default')
565
- export const getDefault = (schema = {}) => Reflect.get(schema, 'default')
938
+ /**
939
+ * @param {{ 'default'?: string | number | object | boolean | null }} [schema]
940
+ * @returns {schema is { 'default': string | number | object | boolean | null }}
941
+ */
942
+ export const hasDefault = (schema = {}) => 'default' in schema // Reflect.has(schema, 'default')
943
+
944
+ /**
945
+ * @overload
946
+ * @param {{ 'default': string | number | object | boolean | null }} schema
947
+ * @returns {string | number | object | boolean | null}
948
+ *
949
+ * @param {{ 'default'?: string | number | object | boolean | null }} [schema]
950
+ * @returns {string | number | object | boolean | null | undefined}
951
+ */
952
+ export const getDefault = (schema = {}) => schema.default // Reflect.get(schema, 'default')
566
953
 
567
- export const hasAnyOf = (schema = {}) => Reflect.has(schema, 'anyOf')
568
- export const getAnyOf = (schema = {}) => Reflect.get(schema, 'anyOf')
954
+ /**
955
+ * @param {{ 'anyOf'?: ItemsType }} [schema]
956
+ * @returns {schema is { 'anyOf': ItemsType }}
957
+ */
958
+ export const hasAnyOf = (schema = {}) => 'anyOf' in schema // Reflect.has(schema, 'anyOf')
959
+
960
+ /**
961
+ * @overload
962
+ * @param {{ 'anyOf': ItemsType }} schema
963
+ * @returns {ItemsType}
964
+ *
965
+ * @param {{ 'anyOf'?: ItemsType }} [schema]
966
+ * @returns {ItemsType | undefined}
967
+ */
968
+ export const getAnyOf = (schema = {}) => schema.anyOf // Reflect.get(schema, 'anyOf')
569
969
 
570
- export const hasOneOf = (schema = {}) => Reflect.has(schema, 'oneOf')
571
- export const getOneOf = (schema = {}) => Reflect.get(schema, 'oneOf')
970
+ /**
971
+ * @param {{ 'oneOf'?: ItemsType }} [schema]
972
+ * @returns {schema is { 'oneOf': ItemsType }}
973
+ */
974
+ export const hasOneOf = (schema = {}) => 'oneOf' in schema // Reflect.has(schema, 'oneOf')
975
+
976
+ /**
977
+ * @overload
978
+ * @param {{ 'oneOf': ItemsType }} schema
979
+ * @returns {ItemsType}
980
+ *
981
+ * @param {{ 'oneOf'?: ItemsType }} schema
982
+ * @returns {ItemsType | undefined}
983
+ */
984
+ export const getOneOf = (schema = {}) => schema.oneOf // Reflect.get(schema, 'oneOf')
572
985
 
573
- export const hasAllOf = (schema = {}) => Reflect.has(schema, 'allOf')
574
- export const getAllOf = (schema = {}) => Reflect.get(schema, 'allOf')
986
+ /**
987
+ * @param {{ 'allOf'?: ItemsType }} [schema]
988
+ * @returns {schema is { 'allOf': ItemsType }}
989
+ */
990
+ export const hasAllOf = (schema = {}) => 'allOf' in schema // Reflect.has(schema, 'allOf')
991
+
992
+ /**
993
+ * @overload
994
+ * @param {{ 'allOf': ItemsType }} schema
995
+ * @returns {ItemsType}
996
+ *
997
+ * @param {{ 'allOf'?: ItemsType }} [schema]
998
+ * @returns {ItemsType | undefined}
999
+ */
1000
+ export const getAllOf = (schema = {}) => schema.allOf // Reflect.get(schema, 'allOf')
575
1001
 
576
- export const getUri = (uri = '#', resource = '') => (uri.endsWith('/') ? uri : uri.concat('/')).concat(resource)
1002
+ /**
1003
+ * @param {string} [uri]
1004
+ * @param {string | number} [resource]
1005
+ * @returns {string}
1006
+ */
1007
+ export const getUri = (uri = '#', resource = '') => (uri.endsWith('/') ? uri : uri + '/') + String(resource)
577
1008
 
1009
+ /**
1010
+ * @param {string} [uri]
1011
+ * @returns {string}
1012
+ */
578
1013
  export const normaliseUri = (uri = '#') => uri === '#' ? '#/' : uri
579
1014
 
1015
+ /**
1016
+ * @param {{ minimum?: number }} schema
1017
+ * @returns {{ min: number } | {}}
1018
+ */
580
1019
  export function getMin ({ minimum } = {}) {
581
1020
  const value = Number(minimum)
582
1021
 
583
1022
  return isNaN(value) ? {} : { min: value }
584
1023
  }
585
1024
 
1025
+ /**
1026
+ * @param {{ maximum?: number }} schema
1027
+ * @returns {{ max: number } | {}}
1028
+ */
586
1029
  export function getMax ({ maximum } = {}) {
587
1030
  const value = Number(maximum)
588
1031
 
589
1032
  return isNaN(value) ? {} : { max: value }
590
1033
  }
591
1034
 
1035
+ /**
1036
+ * @param {{ minLength?: number }} schema
1037
+ * @returns {{ minLength: number } | {}}
1038
+ */
592
1039
  export function getMinLength ({ minLength } = {}) {
593
1040
  const value = Number(minLength)
594
1041
 
595
1042
  return isNaN(value) ? {} : { minLength: value }
596
1043
  }
597
1044
 
1045
+ /**
1046
+ * @param {{ maxLength?: number }} schema
1047
+ * @returns {{ maxLength: number } | {}}
1048
+ */
598
1049
  export function getMaxLength ({ maxLength } = {}) {
599
1050
  const value = Number(maxLength)
600
1051
 
601
1052
  return isNaN(value) ? {} : { maxLength: value }
602
1053
  }
603
1054
 
1055
+ /**
1056
+ * @param {{ minItems?: number }} schema
1057
+ * @returns {{ minItems: number } | {}}
1058
+ */
604
1059
  export function getMinItems ({ minItems } = {}) {
605
1060
  const value = Number(minItems)
606
1061
 
607
1062
  return isNaN(value) ? {} : { minItems: value }
608
1063
  }
609
1064
 
1065
+ /**
1066
+ * @param {{ maxItems?: number }} schema
1067
+ * @returns {{ maxItems: number } | {}}
1068
+ */
610
1069
  export function getMaxItems ({ maxItems } = {}) {
611
1070
  const value = Number(maxItems)
612
1071
 
613
1072
  return isNaN(value) ? {} : { maxItems: value }
614
1073
  }
615
1074
 
1075
+ /**
1076
+ * @param {{ uniqueItems?: boolean }} schema
1077
+ * @returns {{ hasUniqueItems: boolean } | {}}
1078
+ */
616
1079
  export function getHasUniqueItems (schema = {}) {
617
- if (Reflect.has(schema, 'uniqueItems')) {
618
- const value = Reflect.get(schema, 'uniqueItems')
1080
+ if ('uniqueItems' in schema) { // if (Reflect.has(schema, 'uniqueItems') {
1081
+ const value = schema.uniqueItems // Reflect.get(schema, 'uniqueItems')
619
1082
 
620
1083
  return (typeof value === 'boolean') ? { hasUniqueItems: value } : {}
621
1084
  }
@@ -623,33 +1086,53 @@ export function getHasUniqueItems (schema = {}) {
623
1086
  return {}
624
1087
  }
625
1088
 
1089
+ /**
1090
+ * @param {{ minContains?: number }} schema
1091
+ * @returns {{ minContains: number } | {}}
1092
+ */
626
1093
  export function getMinContains ({ minContains } = {}) {
627
1094
  const value = Number(minContains)
628
1095
 
629
1096
  return isNaN(value) ? {} : { minContains: value }
630
1097
  }
631
1098
 
1099
+ /**
1100
+ * @param {{ maxContains?: number }} schema
1101
+ * @returns {{ maxContains: number } | {}}
1102
+ */
632
1103
  export function getMaxContains ({ maxContains } = {}) {
633
1104
  const value = Number(maxContains)
634
1105
 
635
1106
  return isNaN(value) ? {} : { maxContains: value }
636
1107
  }
637
1108
 
1109
+ /**
1110
+ * @param {{ minProperties?: number }} schema
1111
+ * @returns {{ minProperties: number } | {}}
1112
+ */
638
1113
  export function getMinProperties ({ minProperties } = {}) {
639
1114
  const value = Number(minProperties)
640
1115
 
641
1116
  return isNaN(value) ? {} : { minProperties: value }
642
1117
  }
643
1118
 
1119
+ /**
1120
+ * @param {{ maxProperties?: number }} schema
1121
+ * @returns {{ maxProperties: number } | {}}
1122
+ */
644
1123
  export function getMaxProperties ({ maxProperties } = {}) {
645
1124
  const value = Number(maxProperties)
646
1125
 
647
1126
  return isNaN(value) ? {} : { maxProperties: value }
648
1127
  }
649
1128
 
1129
+ /**
1130
+ * @param {{ exclusiveMinimum?: boolean }} schema
1131
+ * @returns {{ isExclusiveMin: boolean } | {}}
1132
+ */
650
1133
  export function getIsExclusiveMin (schema = {}) {
651
- if (Reflect.has(schema, 'exclusiveMinimum')) {
652
- const value = Reflect.get(schema, 'exclusiveMinimum')
1134
+ if ('exclusiveMinimum' in schema) { // if (Reflect.has(schema, 'exclusiveMinimum') {
1135
+ const value = schema.exclusiveMinimum // Reflect.get(schema, 'exclusiveMinimum')
653
1136
 
654
1137
  return (typeof value === 'boolean') ? { isExclusiveMin: value } : {}
655
1138
  }
@@ -657,9 +1140,13 @@ export function getIsExclusiveMin (schema = {}) {
657
1140
  return {}
658
1141
  }
659
1142
 
1143
+ /**
1144
+ * @param {{ exclusiveMaximum?: boolean }} schema
1145
+ * @returns {{ isExclusiveMax: boolean } | {}}
1146
+ */
660
1147
  export function getIsExclusiveMax (schema = {}) {
661
- if (Reflect.has(schema, 'exclusiveMaximum')) {
662
- const value = Reflect.get(schema, 'exclusiveMaximum')
1148
+ if ('exclusiveMaximum' in schema) { // if (Reflect.has(schema, 'exclusiveMaximum') {
1149
+ const value = schema.exclusiveMaximum // Reflect.get(schema, 'exclusiveMaximum')
663
1150
 
664
1151
  return (typeof value === 'boolean') ? { isExclusiveMax: value } : {}
665
1152
  }
@@ -667,8 +1154,16 @@ export function getIsExclusiveMax (schema = {}) {
667
1154
  return {}
668
1155
  }
669
1156
 
1157
+ /**
1158
+ * @param {{ pattern?: RegExp }} schema
1159
+ * @returns {{ pattern: RegExp } | {}}
1160
+ */
670
1161
  export const getPattern = ({ pattern } = {}) => (pattern ? { pattern } : {})
671
1162
 
1163
+ /**
1164
+ * @param {{ multipleOf?: number }} schema
1165
+ * @returns {{ step: number } | {}}
1166
+ */
672
1167
  export function getStep ({ multipleOf } = {}) {
673
1168
  const value = Number(multipleOf)
674
1169