pedantry
pedantry
is a Node.js package that implements a readable stream which puts together of all files in the directory in the sorted order. It also supports reading index.md
and footer.md
as first and last files respectively if found.
yarn add -E pedantry
Table Of Contents
API
The main export of the program is the Pedantry
duplex stream which should only be used as a Readable.
import Pedantry from 'pedantry'
constructor(
source: string,
): Pedantry
Upon creation, Pedantry
will start reading files in the source
directory recursively in the following order:
- the content of the
index.md
file will go first if it exists, - then of all files and directories in the folder recursively in a sorted order,
- and the content of the
footer.md
file will go last if found.
Given the directory structure:
example/test
├── 1-words.md
├── 2-believe.md
├── 3-brick.md
├── footer.md
└── index.md
The usage of Pedantry
is as below:
import Catchment from 'catchment'
import Pedantry from 'pedantry'
(async () => {
try {
const pedantry = new Pedantry('example/test')
const catchment = new Catchment()
pedantry.pipe(catchment)
const res = await catchment.promise
console.log(res)
} catch ({ stack }) {
console.log('stack')
}
})()
(c) Art Deco Code 2018