Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bun-plugin-csv

Package Overview
Dependencies
Maintainers
0
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bun-plugin-csv

A Bun plugin which converts .csv and .tsv files into JavaScript modules.

  • 0.1.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created
Source

bun-plugin-csv

A Bun plugin which converts .csv and .tsv files into JavaScript modules.

Install

bun add bun-plugin-csv -d

Bundler Usage

import csv from 'bun-plugin-csv'

await Bun.build({
  entrypoints: ['./src/index.ts'],
  // other config

  plugins: [csv()]
})

Suppose that you have a CSV which contains some info:

type,count
apples,7
pears,4
bananas,5

The import will provide an Array of Objects representing rows from the CSV file:

import fruit from './fruit.csv';

console.log(fruit);
// [
//   { type: 'apples', count: '7' },
//   { type: 'pears', count: '4' },
//   { type: 'bananas', count: '5' }
// ]

Runtime usage

To use as a runtime plugin, create a file that registers the plugin:

import csv from 'bun-plugin-csv'

Bun.plugin(csv())

Then preload it in your bunfig.toml:

preload = ['./csv.ts']

TypeScript Intellisense

Add the following to your .d.ts file:

/// <reference types="bun-plugin-csv/env" />

License

MIT

Keywords

FAQs

Package last updated on 12 Nov 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc