Skip to content
This repository was archived by the owner on Jul 8, 2023. It is now read-only.

Commit bcae7db

Browse files
committed
Some work on the README.
1 parent 428cef4 commit bcae7db

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed

README.md

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,104 @@ couchdbBuilder.build(sourcePath).then(
6060

6161
[promise]: https://promisesaplus.com/
6262

63+
## Supported file types
64+
65+
*CouchDB builder* supports various file types. The type is determined solely
66+
from the extension, and files with unsupported extensions are ignored:
67+
68+
Extension | Type
69+
----------|-------------------------------
70+
.js | CommonJS module (JavaScript)
71+
.coffee | CommonJS module (CoffeeScript)
72+
.json | JSON document
73+
.txt | text document
74+
*<none>* | text document
75+
76+
## Example document
77+
78+
Given the following directory structure and file contents:
79+
80+
**Directory**:
81+
82+
.
83+
├── a/
84+
│ ├── b
85+
│ ├── c.txt
86+
│ ├── d.json
87+
│ └── e.other
88+
└── views/
89+
├── view-a/
90+
│ └── map.js
91+
└── view-b/
92+
└── map.coffee
93+
94+
*a/b*:
95+
96+
```
97+
String content A.
98+
```
99+
100+
*a/c.txt*:
101+
102+
```
103+
String content B.
104+
```
105+
106+
*a/d.json*:
107+
108+
```json
109+
{
110+
"f": true,
111+
"g": 1.1
112+
}
113+
```
114+
115+
*a/e.other*:
116+
117+
```
118+
Ignored
119+
```
120+
121+
*views/view-a/map.js*:
122+
123+
```js
124+
module.exports = function (doc) {
125+
emit(doc._id);
126+
};
127+
```
128+
129+
*views/view-b/map.coffee*:
130+
131+
```coffee
132+
module.exports = (doc) ->
133+
emit doc._id
134+
135+
return
136+
```
137+
138+
*CouchDB builder* will produce a document like the following:
139+
140+
```json
141+
{
142+
"a": {
143+
"b": "String content A.",
144+
"c": "String content B.",
145+
"d": {
146+
"f": true,
147+
"g": 1.1
148+
}
149+
},
150+
"views": {
151+
"view-a": {
152+
"map": "<source of map.js with wrapper>"
153+
},
154+
"view-a": {
155+
"map": "<compiled source of map.coffee with wrapper>"
156+
}
157+
}
158+
}
159+
```
160+
63161
## Differences to [couchdb-compile]
64162

65163
### Better support for CommonJS modules

0 commit comments

Comments
 (0)