~900 byte minified CSV parser and builder. Smaller when compressed. Built in ESM only.

Related tags

Database but-csv
Overview

but-csv

~900 byte minified CSV parser and builder. Smaller when compressed. Built in ESM only.

Doesn't care about headers, keyed rows, anything but strings. Just supports the CSV spec including multi-line and quoted strings.

Parse

import { parse } from 'but-csv';

const out = parse('foo,bar,zing\n1,2,3');
// out will be [['foo', 'bar', 'zing'], ['1', '2', '3']]

Supports passing a string or Uint8Array. Is internally converted to a byte array first, so pass that if preferred. In Node, do this:

const f = fs.readFileSync('source.csv');
const out = parse(f);

Iterator

Like parse, but you get each row at a time and can return early.

import { iter } from 'but-csv';

for (const row of iter('foo,bar,zing\n1,2,3') {
  // will be an array of ['foo', 'bar', 'zing'],
  // then an array of ['1', '2', '3']
}

Build

import { build } from 'but-csv';

const out = build([
  ['hello', 'there"\n'],
  ['1', '2'],
]);

// out will be:
// hello,"there""
// "
// 1,2
You might also like...

A MongoDB-like database built on top of Hyperbee with support for indexing

hyperbeedeebee A MongoDB-like database built on top of Hyperbee with support for indexing WIP: There may be breaking changes in the indexing before th

Dec 12, 2022

A Crypto App built to pracitse GraphQL Federation

Getting Started To start this project please first create a .env file in the root of your project with the following: REACT_APP_ASTRA_TOKEN={your_astr

Dec 28, 2022

Scaffolding for a dapp built on Solana

🏗 Solana App Scaffold Scaffolding for a dapp built on Solana Quickstart git clone https://github.com/solana-labs/dapp-scaffold.git cd dapp-scaffold

Dec 30, 2022

A simple easy-to-use database, built for beginners.

A simple easy-to-use database, built for beginners.

ByteDatabase: Built for Beginners Table of Content Features Installation Changelog Quick Examples Contributors Features Persistent Storage: Data store

Nov 20, 2022

AlaSQL.js - JavaScript SQL database for browser and Node.js. Handles both traditional relational tables and nested JSON data (NoSQL). Export, store, and import data from localStorage, IndexedDB, or Excel.

AlaSQL.js - JavaScript SQL database for browser and Node.js. Handles both traditional relational tables and nested JSON data (NoSQL). Export, store, and import data from localStorage, IndexedDB, or Excel.

Please use version 1.x as prior versions has a security flaw if you use user generated data to concat your SQL strings instead of providing them as a

Jan 9, 2023

ORM for TypeScript and JavaScript (ES7, ES6, ES5). Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, SAP Hana, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms.

ORM for TypeScript and JavaScript (ES7, ES6, ES5). Supports MySQL, PostgreSQL, MariaDB, SQLite, MS SQL Server, Oracle, SAP Hana, WebSQL databases. Works in NodeJS, Browser, Ionic, Cordova and Electron platforms.

TypeORM is an ORM that can run in NodeJS, Browser, Cordova, PhoneGap, Ionic, React Native, NativeScript, Expo, and Electron platforms and can be used

Jan 3, 2023

TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, MariaDB, PostgreSQL and SQLite databases.

TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, MariaDB, PostgreSQL and SQLite datab

Dec 31, 2022

Azure Data Studio is a data management tool that enables you to work with SQL Server, Azure SQL DB and SQL DW from Windows, macOS and Linux.

Azure Data Studio is a data management tool that enables you to work with SQL Server, Azure SQL DB and SQL DW from Windows, macOS and Linux.

Azure Data Studio is a data management tool that enables working with SQL Server, Azure SQL DB and SQL DW from Windows, macOS and Linux.

Dec 31, 2022
Comments
  • feat: types

    feat: types

    1. auto generate types (thx for jsdoc)
    2. use files section for reduce package size for now https://packagephobia.com/[email protected] and need check after publish new version

    for future need migrate to https://tsup.egoist.sh/ for better experience for build lib

    closes #7

    opened by reslear 1
  • Factor out use of indexOf (528)

    Factor out use of indexOf (528)

    a770bbe08f0ecf0507d2d3deb0ddd3362c7a5ee1 "factored out" charCodeAt and substring, saving some bytes. However, it also slightly slowed down parsing, too.

    These two commits do the same for indexOf and the length assignment. This saves 27 bytes... and also slightly slows down parsing, like the aforementioned commit.

    opened by mcpower 0
  • Change const variables to let

    Change const variables to let

    This allows a minifier to combine the let declarations into a single statement.

    I'm typing this on my phone so I have no idea how much this will affect size, but I think it's at least ~~8~~ 6 bytes worth of savings.

    opened by mcpower 0
  • Reduce to 592 bytes

    Reduce to 592 bytes

    Some unrelated commits:

    • Inline convertToLength, with a special case for commas. Normally, it'd look like

      let to = source.indexOf(',', i);
      if (to < 0) {
        to = source.length;
      }
      if (newline < to) {
        to = newline;
      }
      

      but as we know that newline <= source.length, if to === source.length then the result of the second if statement is always to === newline - so we can merge them to

      let to = source.indexOf(',', i);
      if (to < 0 || newline < to) {
        to = newline;
      }
      

      This commit reduces the size down to 637 (-8) bytes, and seems to slightly improve performance too.

    • Change all variable definitions in iters to be at the top-level as a let declaration. This saves repeatedly having lets and consts in the declaration. This also renames some variables so they can be shared to further reduce size. Note that char and index could be combined to one variable to save 2 bytes, but would make the code even more hard to understand than it currently is.

      This commit, with the above commit, reduces the size down to 599 (-38) bytes and doesn't seem to affect performance.

    • Change === to ==, saving 6 bytes (down to 593) without negatively affecting performance.

    • Change r to use a template string... saving 1 byte.

    Feel free to cherry-pick certain parts of this PR if needed.

    opened by mcpower 0
Owner
Sam Thorogood
Sam Thorogood
A query builder for PostgreSQL, MySQL and SQLite3, designed to be flexible, portable, and fun to use.

knex.js A SQL query builder that is flexible, portable, and fun to use! A batteries-included, multi-dialect (MSSQL, MySQL, PostgreSQL, SQLite3, Oracle

knex 16.9k Jan 4, 2023
Burger builder project using React, Hooks and Context API.

Burger Builder In this project, I made a context-api project by creating hamburgers with 3 different materials. Project setup npm install Project star

Efecan Pınar 4 Jun 17, 2021
A fast, synchronized and dynamic query builder package.

@ssibrahimbas/query A fast, synchronized and dynamic query builder package. What is? In short, the query builder. You can write complex and parameteri

Sami Salih İbrahimbaş 7 Jun 13, 2022
XML/HTML parser and processing library for JavaScript and TypeScript

[VIEW DOCUMENTATION] Robin is an XML parser and processing library that supports a sane version of HTML. It features a set of DOM utilities, including

null 15 Oct 5, 2022
A postgraphile plugin that allows you to expose only a single direction of connections exposed by foreign key constraints

A postgraphile plugin that allows you to expose only a single direction of connections exposed by foreign key constraints

Chandler Gonzales 4 Mar 13, 2022
✏️ Extended Writer supercharges Kirby's built-in Writer field with useful marks, nodes and features you wish were built-in

Extended Writer Extended Writer supercharges Kirby's built-in Writer field and block with useful marks, nodes and features you wish were built-in. Fea

coralic 21 Nov 10, 2022
A Gmail Clone which built with ReactJS and Redux. You can sign in with your Google Account, compose a new e-mail and send realtime emails to the project.

Gmail Clone with ReactJS A Gmail Clone that you can sign in with your Google Account, compose a new e-mail and send realtime emails to the project. Cl

Özge Coşkun Gürsucu 49 Nov 14, 2022
A simple Node.js ORM for PostgreSQL, MySQL and SQLite3 built on top of Knex.js

bookshelf.js Bookshelf is a JavaScript ORM for Node.js, built on the Knex SQL query builder. It features both Promise-based and traditional callback i

Bookshelf.js 6.3k Jan 2, 2023
Modular Redis connection and PUBSUB subscription manager for node. Easily extendable. Built for performance, powered by ioredis.

RediBox Redis connection and PUBSUB subscription manager for node. Built for performance, powered by ioredis (for now). Maintained by TeamFA. What is

RediBox 83 Dec 15, 2022
A simple url shorter API built with nodejs running on Kubernetes in Google Cloud, using PostgreSQL for storage and cloud sql proxy.

Simple URL Shorter - Google Cloud - Kubernetes A simple url shorter API built with nodejs running on Kubernetes in Google Cloud, using PostgreSQL for

null 3 Nov 25, 2021