Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
format-data
Advanced tools
Readme
Windows | Mac/Linux |
---|---|
Module for formatting tabular data from object streams in different standard ways.
Supporting csv
, ndjson
, json
and sse
. Install with npm install format-data
.
formatData(format, [opts])
The opts
object will be passed to the underlying serializing module (see below).
or just pass an options object with format
as a key.
formatData(opts)
You can pass a custom prefix, separator, or suffix to the stream builder for csv and json cases.
Examples:
## default separator for csv is ','
> formatData('csv')
'a,b\n1,2\nhello,world\n'
## change separator to a tab
> formatData({format: 'csv', separator: '\t'})
'a\tb\n1\t2\nhello\tworld\n'
## default object style finishes with }]
> formatData({
format: 'json',
style: 'object'
})
{"rows":[{"a":1,"b":2},{"a":"hello","b":"world"}]}
## custom suffix
> formatData({
format: 'json',
style: 'object',
suffix: ', "next": "/api/rows?page=2"}'
})
{"rows":[{"a":1,"b":2},{"a":"hello","b":"world"}], "next": "/api/rows?page=2"}
## suffix still added in cases of error
> formatData({
format: 'json',
style: 'object',
suffix: ', "next": "/api/rows?page=2"}'
})
{"rows":[], "error":"Oh no!", "next": "/api/rows?page=2"}
Formats and the used modules:
'csv'
- require('csv-write-stream')(opts)
'ndjson'
- require('ndjson').stringify(opts)
json
- new require('./json.js')(opts)
sse
- require('ssejson').serialize(opts)
FAQs
Format tabular data from object streams to different (standard) formats
The npm package format-data receives a total of 102 weekly downloads. As such, format-data popularity was classified as not popular.
We found that format-data demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.