@@ -18,30 +18,30 @@ npm i @dtavern/options
1818const { defineOptions } = require (' @dtavern/options' )
1919
2020function someFunction (options ) {
21- defineOptions (options, {
22- name: String ,
23- age: [String , Number ],
24- colors: {
25- type: Array ,
26- required: false ,
27- default : () => [' red' , ' blue' ],
28- validator : (value ) => value .length > 0 ,
29- },
30- })
31-
32- console .log (options)
21+ defineOptions (options, {
22+ name: String ,
23+ age: [String , Number ],
24+ colors: {
25+ type: Array ,
26+ required: false ,
27+ default : () => [' red' , ' blue' ],
28+ validator : (value ) => value .length > 0 ,
29+ },
30+ })
31+
32+ console .log (options)
3333}
3434
3535someFunction ({
36- name: ' Rocket' ,
37- age: ' 17' ,
36+ name: ' Rocket' ,
37+ age: ' 17' ,
3838})
3939
4040/* Output:
4141{
42- name: 'Rocket',
43- age: '17',
44- colors: ['red', 'blue']
42+ name: 'Rocket',
43+ age: '17',
44+ colors: ['red', 'blue']
4545}
4646*/
4747```
@@ -57,17 +57,17 @@ in config.
57571 . [ Set plugin settings as array] ( #settings-as-array )
58581 . [ Set plugin settings as object] ( #settings-as-object )
59591 . [ Set options settings as object] ( #options-settings-as-object )
60- 1 . [ Option setting API] ( #option-setting-api )
61- 1 . [ type] ( #type )
62- 1 . [ required] ( #required )
63- 1 . [ default] ( #default )
64- 1 . [ validator] ( #validator )
65- 1 . [ Checkers execution order] ( #checkers-execution-order )
66- 1 . [ Exists checker] ( #1-exists-checker )
67- 1 . [ Default setter] ( #2-default-setter )
68- 1 . [ Type option checker] ( #3-type-option-checker )
69- 1 . [ Type checker] ( #4-type-checker )
70- 1 . [ Validator] ( #5-validator )
60+ 1 . [ Option setting API] ( #option-setting-api )
61+ 1 . [ type] ( #type )
62+ 1 . [ required] ( #required )
63+ 1 . [ default] ( #default )
64+ 1 . [ validator] ( #validator )
65+ 1 . [ Checkers execution order] ( #checkers-execution-order )
66+ 1 . [ Exists checker] ( #1-exists-checker )
67+ 1 . [ Default setter] ( #2-default-setter )
68+ 1 . [ Type option checker] ( #3-type-option-checker )
69+ 1 . [ Type checker] ( #4-type-checker )
70+ 1 . [ Validator] ( #5-validator )
71711 . [ Config API] ( #config-api )
7272 1 . [ mode] ( #mode )
7373 1 . [ clone] ( #clone )
@@ -127,15 +127,15 @@ const { defineOptions } = require('@dtavern/options')
127127
128128// Returns { name: 'hello' }
129129defineOptions (
130- {},
131- {
132- name: {
133- type: String ,
134- required: false ,
135- default: ' hello' ,
136- validator : (value ) => value .length > 0 ,
137- },
138- }
130+ {},
131+ {
132+ name: {
133+ type: String ,
134+ required: false ,
135+ default: ' hello' ,
136+ validator : (value ) => value .length > 0 ,
137+ },
138+ }
139139)
140140```
141141
@@ -177,7 +177,7 @@ throw error will not happen
177177
178178``` js
179179root: {
180- required: false
180+ required: false
181181}
182182```
183183
@@ -297,9 +297,9 @@ options object.
297297const originalObject = {}
298298
299299const newObject = defineOptions (
300- originalObject,
301- { name: { required: false , default: ' Dmitry' } },
302- { clone: true }
300+ originalObject,
301+ { name: { required: false , default: ' Dmitry' } },
302+ { clone: true }
303303)
304304
305305console .log (originalObject) // Returns: {}
@@ -320,21 +320,21 @@ Example:
320320import { defineOptions } from ' @dtavern/options'
321321
322322interface Options {
323- name? : string
323+ name? : string
324324}
325325
326326function someFunction(options : Options = {}) {
327- // Returns { name: 'hello' }
328- const newOptions = defineOptions <Options >(options , {
329- name: {
330- type: String ,
331- required: false ,
332- default: ' Dmitry' ,
333- },
334- })
335-
336- // Valid
337- console .log (newOptions .name )
327+ // Returns { name: 'hello' }
328+ const newOptions = defineOptions <Options >(options , {
329+ name: {
330+ type: String ,
331+ required: false ,
332+ default: ' Dmitry' ,
333+ },
334+ })
335+
336+ // Valid
337+ console .log (newOptions .name )
338338}
339339
340340someFunction ()
0 commit comments