
Security News
How Enterprise Security Is Adapting to AI-Accelerated Threats
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.
LTSV parser and formatter
$ npm install ltsv
$ bower install ltsv
var ltsv = require('ltsv');
<script src="ltsv.min.js"></script>
ltsv.parse(
'label1:value1\tlabel2:value2\n' +
'label1:value1\tlabel2:value2\n' +
'label1:value1\tlabel2:value2'
);
// [ { label1: 'value1', label2: 'value2' },
// { label1: 'value1', label2: 'value2' },
// { label1: 'value1', label2: 'value2' } ]
ltsv.parseLine('label1:value1\tlabel2:value2');
// { label1: 'value1', label2: 'value2' }
ltsv.parseLine('label1:value1\tlabel2:value2\n');
// { label1: 'value1', label2: 'value2' }
ltsv.parseLine('label1:value1\tlabel2:value2\r\n');
// { label1: 'value1', label2: 'value2' }
ltsv.format([
{ label1: 'value1', label2: 'value2' },
{ label1: 'value1', label2: 'value2' },
{ label1: 'value1', label2: 'value2' }
]);
// 'label1:value1\tlabel2:value2\nlabel1:value1\tlabel2:value2\nlabel1:value1\tlabel2:value2'
ltsv.format({ label1: 'value1', label2: 'value2' });
// 'label1:value1\tlabel2:value2'
var fs = require('fs'),
ltsv = require('ltsv'),
ltjs = ltsv.createLtsvToJsonStream({
toObject: false,
strict: false
});
// access.log:
// l1:v1\tl2:v2\n
// l1:v1\tl2:v2\n
// l1:v1\tl2:v2\n
fs.createReadStream('./access.log').pipe(ltjs).pipe(process.stdout);
// {"l1":"v1","l2":"v2"}{"l1":"v1","l2":"v2"}{"l1":"v1","l2":"v2"}
text string - LTSV textreturn Object[] - parsed objectssplit to LTSV records.
throw SyntaxError if text has no separator.
line string - LTSV linereturn Object - parsed objectsplit to LTSV record.
throw SyntaxError if line has no separator.
text string - LTSV textreturn Object[] - parsed objectssplit to LTSV records and validate label and value of fields.
throw SyntaxError if text has no separator.
also throw SyntaxError if text has unexpected character.
line string - LTSV linereturn Object - parsed objectsplit to LTSV record.
throw SyntaxError if line has no separator.
also throw SyntaxError if line has unexpected character.
mixed Object|Object[] - object or object arrayreturn string - LTSV textconvert to LTSV text.
throw TypeError if mixed is not an object or array.
mixed Object|Object[] - object or object arrayreturn string - LTSV textconvert to LTSV text.
throw TypeError if mixed is not an object or array.
also throw SyntaxError if mixed has unexpected character.
options object - option objectreturn LtsvToJsonStream - LTSV to JSON streamreturn LtsvToJsonStream instance. cannot use by browser.
encoding string - StringDecoder encodingtoObject boolean - flag of send to objectstrict boolean - flag of strict parseStringDecoder's encoding.
if not set, use "utf8".
send object if toObject is true.
otherwise send JSON string.
if not set, toObject is false.
strict parse if strict is true.
otherwise not strict parse.
if not set, strict is false.
$ npm install
$ npm test
$ npm install
$ npm run-script bower
$ npm run-script testem
The MIT License. Please see LICENSE file.
FAQs
LTSV parser, formatter, validator and TransformStream
The npm package ltsv receives a total of 279 weekly downloads. As such, ltsv popularity was classified as not popular.
We found that ltsv demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.

Security News
Experts push back on new claims about AI-driven ransomware, warning that hype and sponsored research are distorting how the threat is understood.