Skip to content
This repository was archived by the owner on Jun 24, 2024. It is now read-only.

Commit 3f9fa0f

Browse files
committed
docs: Update docs to match changes
1 parent 79cdef6 commit 3f9fa0f

File tree

1 file changed

+15
-108
lines changed

1 file changed

+15
-108
lines changed

README.md

Lines changed: 15 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@
1515
<!-- /BADGES -->
1616

1717

18-
A module that takes any number of css feed streams (provided by asset-pipe sinks) and bundles them into a readable stream of css content.
18+
[![Greenkeeper badge](https://badges.greenkeeper.io/asset-pipe/asset-pipe-css-reader.svg)](https://greenkeeper.io/)
19+
20+
A module that takes any number of css feeds and bundles them into a css bundle.
1921

2022
This is an internal module intended for use by other modules in the [asset-pipe project](https://github.com/asset-pipe).
2123

2224
## Overview
2325

24-
[![Greenkeeper badge](https://badges.greenkeeper.io/asset-pipe/asset-pipe-css-reader.svg)](https://greenkeeper.io/)
25-
26-
Given any number of css feed streams, the reader will:
27-
1. Merge streams into a single stream
26+
Given any number of css feeds, the reader will:
27+
1. Merge feeds into a single feed
2828
2. Dedupe any items with identical id hashes keeping the last occurrence
29-
3. Ensure order of streams given is preserved for the final output CSS
29+
3. Ensure order of feeds given is preserved for the final output CSS
3030

3131
### Input data format
3232

@@ -57,128 +57,35 @@ npm install asset-pipe-css-reader
5757

5858
### Require the reader
5959
```js
60-
const CssReader = require('asset-pipe-css-reader')
60+
const cssReader = require('asset-pipe-css-reader')
6161
```
6262

6363
### Instantiating the reader
6464

65-
Either pass a single stream created by an asset-pipe sink:
66-
```js
67-
const sink = new SinkFs({
68-
path: '/path/to/css/feeds'
69-
});
70-
const feedStream = sink.reader('feed-a.json');
71-
const reader = new CssReader(feedStream)
72-
```
73-
74-
Or pass an array of streams:
65+
Pass feeds created by an asset-pipe sink:
7566
```js
7667
const sink = new SinkFs({
7768
path: '/path/to/css/feeds'
7869
});
79-
const feedStream1 = sink.reader('feed-a.json');
80-
const feedStream2 = sink.reader('feed-b.json');
81-
const reader = new CssReader([feedStream1, feedStream2])
82-
```
83-
84-
### Consuming content from the reader
85-
86-
You should wait for the reader to become ready by listening for the `pipeline ready` event.
87-
88-
The reader is a readable stream so in order to access the data you may register a data handler
89-
and listen for chunks to be passed to the handler:
90-
```js
91-
reader.on('pipeline ready', () => {
92-
reader.on('data', data => {
93-
// ..
94-
})
95-
})
96-
```
97-
98-
You might also pipe the reader into a writeable or transform stream:
99-
```js
100-
const { writeFile } = require('fs')
101-
const consumer = writeFile('/path/to/save/file')
102-
103-
reader.on('pipeline ready', () => {
104-
reader.pipe(consumer)
105-
})
70+
const feed1 = JSON.parse(await sink.get('feed-a.json'));
71+
const feed2 = JSON.parse(await sink.get('feed-b.json'));
72+
const bundle = await cssReader([feed1, feed2])
10673
```
10774

10875
## API
10976

110-
### Methods
111-
112-
#### constructor
113-
114-
Constructor takes a single stream or array of streams. Streams should be produced with an asset-pipe sink such as:
77+
Reader takes an array of feeds. Feeds should be produced with an asset-pipe sink such as:
11578
- [asset-pipe-sink-s3](https://github.com/asset-pipe/asset-pipe-sink-s3`)
11679
- [asset-pipe-sink-fs](https://github.com/asset-pipe/asset-pipe-sink-fs`)
11780
- [asset-pipe-sink-gcs](https://github.com/asset-pipe/asset-pipe-sink-gcs`)
11881
- [asset-pipe-sink-mem](https://github.com/asset-pipe/asset-pipe-sink-mem`)
11982

120-
Examples
121-
```js
122-
new CssReader(stream)
123-
```
124-
```js
125-
new CssReader([stream, ...stream])
126-
```
127-
128-
Returns: `Readable Stream`
129-
130-
### Events
131-
132-
#### file found
133-
134-
Event produced whenever an underlying feed stream successfully reads its feed
135-
file from disk
136-
137-
```js
138-
cssReader.on('file found', file => {})
139-
```
140-
141-
Param: `file`, name of the file given to the feed stream to read from
142-
143-
#### file not found
144-
145-
Event produced whenever an underlying feed stream is unable to read its feed
146-
file from disk
147-
148-
```js
149-
cssReader.on('file not found', file => {})
150-
```
151-
152-
Param: `file`, name of the file given to the feed stream to read from
153-
154-
#### pipeline ready
155-
156-
Event produced once all feed file streams have been successfully merged into
157-
a pipeline
158-
159-
```js
160-
cssReader.on('pipeline ready', () => {})
161-
```
162-
163-
#### data
164-
165-
Event that emits chunks of CSS content to a consumer
166-
167-
```js
168-
cssReader.on('data', chunk => {})
169-
```
170-
171-
Param: `chunk`, a piece of CSS text
172-
173-
#### error
174-
175-
Event produced whenever any of the various stages of the pipeline emit errors
176-
83+
Example
17784
```js
178-
cssReader.on('error', err => {})
85+
cssReader([feed, ...feeds])
17986
```
18087

181-
Param: `err`, Error forwarded from merged streams or otherwise emitted from the pipeline
88+
Returns: `string`
18289

18390
## Contributing
18491

0 commit comments

Comments
 (0)