Skip to content

Commit

Permalink
Updating README with correct argument order
Browse files Browse the repository at this point in the history
  • Loading branch information
wheeyls committed Feb 21, 2019
1 parent 84c8c95 commit 5af26ab
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ This will create a new hash, seperating out keys based on a common prefix:
import { extractOptions } from '@g2crowd/extract-options';
const startingHash = { prefixOne: 1, prefixTwo: 2, otherKey: 3 };

extractOptions('prefix', startingHash); //=> { one: 1, two: 2 }
extractOptions(startingHash, 'prefix'); //=> { one: 1, two: 2 }
```

It will treat keys with an `Options` suffix as special. It will expect a hash of raw options to follow:

```javascript
const startingHash = { prefixOne: 1, prefixTwo: 2, otherKey: 3, prefixOptions: { three: 3 } };

extractOptions('prefix', startingHash); //=> { one: 1, two: 2, three: 3 }
extractOptions(startingHash, 'prefix'); //=> { one: 1, two: 2, three: 3 }
```

Pairs nicely with `jQuery.data`:
Expand All @@ -36,5 +36,5 @@ Pairs nicely with `jQuery.data`:

```javascript
let data = $('#element').data();
const options = extractOptions('prefix', data); //=> { one: 1, two: 2 }
const options = extractOptions(data, 'prefix'); //=> { one: 1, two: 2 }
```

0 comments on commit 5af26ab

Please sign in to comment.