NPM publish README fix

This commit is contained in:
dig 2019-05-28 01:00:24 +02:00
parent 3e5c1528a2
commit 056dfca4c8
1 changed files with 10 additions and 5 deletions

View File

@ -114,27 +114,32 @@ esm myLib:showParams param1 param2 param3 -s --t -foo --bar -baz:42 --val=some
> [ "param1", "param2", "param3", s: true, t: true, foo: true, bar: true, baz: 42, val: "some" ]
```
Note: order don't matters...
> Note: order don't matters...
You can then use ES destructuration to filter named paremeters:
```javascript
export function myAwesomeFunction( [ first, second, , forth ] ) // Array destructuration gets simple params
// Array destructuration gets simple params
export function myAwesomeFunction( [ first, second, , forth ] )
{
console.log( first, second, forth )
}
export function myAwesomeFunction2( { foo, val, baz } ) // Object destructuration gets named params
// Object destructuration gets named params
export function myAwesomeFunction2( { foo, val, baz } )
{
console.log( foo, val, baz )
}
export function myAwesomeFunction3( { 0:param1, 3:param4, foo, val, baz } ) // Object destructuration for both, using index name
// Object destructuration for both, using index name
export function myAwesomeFunction3( { 0:param1, 3:param4, foo, val, baz } )
{
console.log( param1, param4, foo, val, baz )
}
```
To call this kind of function in js:
To call this kind of function in js and create an augmented param array:
```javascript
import { myAwesomeFunction3 } from 'myLib'
myAwesomeFunction3({ 0: "first", 3: "forth", foo: true })
```