Skip to content

Commit b7738ad

Browse files
committed
docs: Add LICENSE and README
1 parent 91f0e7d commit b7738ad

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

LICENSE

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright Eemeli Aro <eemeli@gmail.com>
2+
3+
Permission to use, copy, modify, and/or distribute this software for any purpose
4+
with or without fee is hereby granted, provided that the above copyright notice
5+
and this permission notice appear in all copies.
6+
7+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
8+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
9+
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
10+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
11+
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
12+
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
13+
THIS SOFTWARE.

README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# yaml-types
2+
3+
Additional useful types for [`yaml`](https://github.com/eemeli/yaml).
4+
5+
## Installation and Usage
6+
7+
```
8+
npm install yaml yaml-types
9+
```
10+
11+
Each type (a.k.a. "tag") is available as a named export of `'yaml-types'`.
12+
These may then be used as [custom tags](https://eemeli.org/yaml/#writing-custom-tags):
13+
14+
```js
15+
import { parse } from 'yaml'
16+
import { regexp } from 'yaml-types'
17+
18+
const re = parse('!re /fo./g', { customTags: [regexp] })
19+
'foxbarfoo'.match(re) // [ 'fox', 'foo' ]
20+
```
21+
22+
## Available Types
23+
24+
- `regexp` (`!re`) - [RegExp] values,
25+
using their default `/foo/flags` string representation.
26+
27+
[RegExp]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_expressions
28+
29+
## Customising Tag Names
30+
31+
To use one of the types with a different tag identifier, set its `tag` value accordingly.
32+
For example, to extend the default namespace with `!!js/regexp` instead of using a locale `!re` tag for RegExp values:
33+
34+
```js
35+
import { stringify } from 'yaml'
36+
import { regexp } from 'yaml-types'
37+
38+
const myregexp = { ...regexp, tag: 'tag:yaml.org,2002:js/regexp' }
39+
const str = stringify(/fo./m, { customTags: [myregexp] })
40+
// '!!js/regexp /fo./m\n'
41+
```
42+
43+
## Contributing
44+
45+
Additions to this library are very welcome!
46+
Many data types are useful beyond any single project,
47+
and while the core `yaml` library is mostly limited to the YAML spec,
48+
no such restriction applies here.
49+
50+
The source code is written in [TypeScript], and the tests use [Node-Tap].
51+
When submitting a PR for a new type, tests and documentation are required,
52+
as well as satisfying [Prettier].
53+
54+
[TypeScript]: https://www.typescriptlang.org/
55+
[Node-Tap]: https://node-tap.org/
56+
[Prettier]: https://prettier.io/

0 commit comments

Comments
 (0)