Package Exports
- line-observer
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (line-observer) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
line-observer
Step by step...
API
byline
import byLine from 'line-observer'
const file = 'path/to/file'
/**
file === `
a line
another one!
`
*/
const lines$ = byLine(file) // Observable of lines
lines$.subscribe(console.log) // a line, another one!This is the main export of this package and returns an Observable of each line read. It shouldn't be read all into memory but instead read character by character.
createCharObservable
import { createCharObservable } from 'line-observer'
const bySpace = createCharObservable((char, strBuffer) => char === '\s')
/**
file === `
a line
another one!
`
*/
const words$ = bySpace(file) // Observable of words
words$.subscribe(console.log) // a, line, another, one!Returns a function that expects a file path and returns an observable, emitting at each character that passes the function given.
parseBy
import byLine from 'line-observer'
const { parseBy } = byLine
const groupByTab = parseBy('\t')
const parsedLines$ = groupByTab(byLine(file))
/**
file === `
header1 header2
tim1 tim2
tim3 tim4
`
*/
parsedLines$
.subscribe(console.log) // { header1: tim1, header2: tim2 }, { header1: tim3, header2: tim4 }Creates a function that expects an observable that emits parsed lines, attaching the headers to each line following.