Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import * as ltx from 'ltx';
ltx.parse('');
const p = new ltx.Parser();
p.on('tree', (ignored: any) => {});
p.on('error', (ignored: any) => {});
const el = new ltx.Element('root').c('children');
el.c('child', {age: 5}).t('Hello').up()
.c('child', {age: 7}).t('Hello').up()
.c('child', {age: 99}).t('Hello').up();
el.root().toString();
import * as ltx from 'ltx';
ltx.parse('');
const getChildTextElement = ltx.parse('body text') as ltx.Element;
if (getChildTextElement.getChildText('child') !== 'body text') {
throw new Error("body does not match");
}
const p = new ltx.Parser();
p.on('tree', (ignored: any) => {});
p.on('error', (ignored: any) => {});
const el = new ltx.Element('root').c('children');
el.c('child', {age: 5}).t('Hello').up()
.c('child', {age: 7}).t('Hello').up()
.c('child', {age: 99}).t('Hello').up();
el.root().toString();
function parseBody(stream, cb) {
var parser = new ltx.Parser()
stream.on('data', function(data) {
parser.write(data)
})
stream.on('end', function() {
parser.end()
})
stream.on('error', function(e) {
cb(e)
})
parser.on('tree', function(bodyEl) {
cb(null, bodyEl)
})
parser.on('error', function(e) {
cb(e)
})
}
function parseBody(stream, cb) {
var parser = new ltx.Parser()
stream.on('data', function(data) {
parser.write(data)
})
stream.on('end', function() {
parser.end()
})
stream.on('error', function(e) {
cb(e)
})
parser.on('tree', function(bodyEl) {
cb(null, bodyEl)
})
parser.on('error', function(e) {
cb(e)
})
}
function parseBody(stream, cb) {
var parser = new ltx.Parser()
stream.on('data', function(data) {
parser.write(data)
})
stream.on('end', function() {
parser.end()
})
stream.on('error', function(e) {
cb(e)
})
parser.on('tree', function(bodyEl) {
cb(null, bodyEl)
})
parser.on('error', function(e) {
cb(e)
})
}