Skip to content

Commit 57e8f5a

Browse files
committed
release: v1.0.0
Initial release.
1 parent 778bbd4 commit 57e8f5a

1 file changed

Lines changed: 46 additions & 1 deletion

File tree

readme.md

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ someFunction({
4747
```
4848

4949
How you can see, `defineOptions` **overwrite original object**.
50-
If you need clone object, use spread operator.
50+
If you need clone object, use spread operator or set clone option
51+
in config.
5152

5253
# Documentation
5354

@@ -67,6 +68,9 @@ If you need clone object, use spread operator.
6768
1. [Type option checker](#3-type-option-checker)
6869
1. [Type checker](#4-type-checker)
6970
1. [Validator](#5-validator)
71+
1. [Config API](#config-api)
72+
1. [mode](#mode)
73+
1. [clone](#clone)
7074
1. [Using typescript](#using-typescript)
7175

7276
## **Settings as array**
@@ -261,6 +265,47 @@ If the validator returns `true` - the script moves to the
261265
next property or ends work. But if returns `false` - this
262266
will result in an error
263267

268+
## **Config API**
269+
270+
### **mode**
271+
272+
Type: `strict`, `log`, `disabled`\
273+
Default: `strict`
274+
275+
Mode option needs for changes the way errors are output.
276+
277+
- **strict** - error will be throw script
278+
- **log** - error will be output to console
279+
- **disabled** - error will be ignored
280+
281+
Example:
282+
283+
```js
284+
// Error without throw script
285+
defineOptions({}, ['name'], { mode: 'log' })
286+
```
287+
288+
### **clone**
289+
290+
Type: `boolean`\
291+
Default: `false`
292+
293+
Clone option needed if you don't want to change the original
294+
options object.
295+
296+
```js
297+
const originalObject = {}
298+
299+
const newObject = defineOptions(
300+
originalObject,
301+
{ name: { required: false, default: 'Dmitry' } },
302+
{ clone: true }
303+
)
304+
305+
console.log(originalObject) // Returns: {}
306+
console.log(newObject) // Returns: { name: 'Dmitry' }
307+
```
308+
264309
## **Using typescript**
265310

266311
If you using typescript, you can use generic type in plugin:

0 commit comments

Comments
 (0)