Skip to content

Commit

Permalink
add types and fix incorrect info
Browse files Browse the repository at this point in the history
  • Loading branch information
cmawhorter authored Jan 13, 2021
1 parent d3066e6 commit fe14a68
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ if (Array.isArray(valid)) {

Takes an already-parsed urn and returns the stringified version. Note that whether or not you've enabled options.allowEmpty, empty values will be included in the result (PR welcome).

Note: If parsed.protocol exists it is **ignored** and the protocol supplied with create() options is used instead.

Example:
```js
const componentNames = [ 'something', 'else', 'not_included' ];
Expand All @@ -178,6 +180,8 @@ Takes an urn string and parses it into component parts or returns null if `value

Allows you to construct arbitrary parsed urns to use with `validate()` or `format()`.

Note: If you provide a protocol to build it is used, but that won't work with format(). See #8.

Note: Build returns null values and there is currently a bug/feature #7 with validate() that will cause validation to fail if ParsedUrn has any null values. (PR welcome)

Example:
Expand All @@ -190,16 +194,6 @@ const parsed = myUrn.build({
});
```

You can also use build to change protocols:

```js
const arn = URN.create(...);
const parsedArn = arn.parse('arn:aws:...');
console.log(arn.build(Object.assign(parsedArn, {
protocol: 'somethingelse'
))); // somethingelse:aws:...
```
### Type: `ParsedUrn = { [key: string]: null | string }`

The key will be the component name and the corresponding urn value.
Expand Down

0 comments on commit fe14a68

Please sign in to comment.