open-index/open-npm huggingface dataset:
npm package: @ochoalopes/csvparse
Description: Parse CSV into JSON, Typescript or Text files
Author: leovene
Latest version: 1.0.3

# CSVParse

A utility for parsing CSV files and converting them to JSON format in Node.js. The `CSVParse` class is easy to use and can handle large CSV files, allowing you to start and stop at specific line numbers and use custom delimiters.

## Features

- Parse large CSV files with configurable start and stop line numbers
- Supports custom delimiters and file encodings
- Optional header row support
- Can specify errorCallback to handle errors

## Installation

```bash
npm install @ochoalopes/csvparse
```

## Usage

Import the `CSVParse` class and create a new instance:

```
import { CSVParse } from '@ochoalopes/csvparse';

const csvParse = new CSVParse();
```

Then, call the parseToJson method:

```
csvParse.parseToJson(filePathToRead, filePathToWrite, fileHasHeader, encoding, delimiter, startFrom, stopAt, errorCallback);
```

### Parameters

- `filePathToRead` (string) - The path of the CSV file to read.
- `filePathToWrite` (string) - The path of the JSON file to write.
- `fileHasHeader` (boolean, optional, default: `false`) - Set to `true` if the CSV file has a header row.
- `encoding` (BufferEncoding, optional, default: `'utf-8'`) - The encoding of the CSV file.
- `delimiter` (string, optional, default: `'|'`) - The delimiter used in the CSV file.
- `startFrom` (number, optional, default: `0`) - The line number to start parsing from (inclusive).
- `stopAt` (number, optional, default: `0`) - The line number to stop parsing at (inclusive).
- `errorCallback` (function, optional) - A callback function that receives an `Error` object if an error occurs during parsing.

Example:

```
csvParse.parseToJson('./data/input.csv', './data/output.json', true, 'utf-8', ',', 1, 100, (error) => {
  console.error('Error occurred:', error.message);
});
```

### Tests

```run
npm test
```
 ## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.
npm package: @ochuzor/todo.txt-indexer
Description: a javascript library for indexing and searching todo.txt texts
Author: ochuzor
Latest version: 4.1.0

A javascript indexer library for [todo.txt](https://github.com/todotxt/todo.txt). It provides classes for easily holding a list of todo items in memory and searching through them.

```
npm i @ochuzor/todo.txt-indexer
```
It provides ITodoIndexer interface and (currently) two implementations.
```typescript
export interface ITodoIndexer {
    addDoc(doc: ITodoDoc): void;
    getDoc(id: IdType): ITodoDoc;
    deleteDoc(id: IdType): void;
    getAll(): ITodoDoc[];
    search(query: string): ITodoDoc[];
}
```

The addDoc method adds a new document to the index. If the item already exists in the index, it will be replaced. 

The first implementation, AbstractArrayTodoIndexer is an abstract class that implements all the methods except the search method. The main idea is to provide a base class for the other functionalities and then you can go about implementing the search functionality as you wish. A class that extends AbstractArrayTodoIndexer has access to the enter data array via _data field, which is a protected field.

The other class, FuseJsTodoIndexer implements all the methods, including the search functionality. The search is implemented using the beautiful [Fuse.js library](https://fusejs.io/). Basic usage the class:
```typescript
import { FuseJsTodoIndexer } from '@ochuzor/todo.txt-indexer';

const indexer = new FuseJsTodoIndexer();

// to add a document
indexer.addDoc({id: 100, text: 'x call Jerry'});

// to delete a document
indexer.deleteDoc(id);

// to get a document
const todo = indexer.getDoc(id);

// to get a list of all the documents
const lsTodos = indexer.getAll();

// to search 
const searchResults = indexer.search('search string');
```
If an item is not found, getDoc returns A [null object](https://en.wikipedia.org/wiki/Null_object_pattern). The object has the supplied id, but an empty text field.

The search methods accepts a string as query. Treat the search query as a todo item. The search functionality is not that good though. It might be improved in the future. So, to search for all completed items that have "call Tom in it", with "phone" as a context, use
```
x call Tom @phone
```

Take a look at the code and tests.
npm package: @ochuzor/todo.txt-parser
Description: a parser for todo.txt
Author: ochuzor
Latest version: 3.2.2

A javascript parser for [todo.txt](https://github.com/todotxt/todo.txt)

Is it over-engineered? Yes! It is! But in my defence, the real reason for creating this package is to learn. I mean, there are a lot of good todo.txt parsers out there. This one is just for my learning purpose.

```
npm i @ochuzor/todo.txt-parser
```
The library provides a few functions for working with todo.txt formatted strings. To convert a todo.txt text into a javascript object, use:

```typescript
import {textToDto} from '@ochuzor/todo.txt-parser';
const todo = textToDto('x work on the new +projectMakeOver @home');
```

The returned object has the following properties:

```typescript
interface IDoc {
    id?: string | number;
}

interface TagDto {
    name: string;
    value: string;
}

interface TodoDto extends IDoc {
    description: string;
    isCompleted: boolean;
    priority: string;
    dateOfCreation: string;
    dateOfCompletion: string;
    projects: string[];
    contexts: string[];
    tags: TagDto[];
}
```
Another function provided is todoDtoToText. It converts an object from the above function into a todo.txt string. Here's how to use it:
```typescript
import {todoDtoToText} from '@ochuzor/todo.txt-parser';

const todo = {
    description: 'write a new documentation',
    isCompleted: true,
    priority: '(A)',
    ...
};

const todoTxt = todoDtoToText(todo);
// returns "x (A) write a new documentation"
```
The priority ranges from (A) to (E). The implementation follows the format on [todo.txt](https://github.com/todotxt/todo.txt). The third function is textToIndexDto. It is similar to textToDto above except that every field is a string, including the "isCompleted", which is then either "true" or "false". The projects list is now a space separated list of projects. Same applies to the contexts field as well. The tags field is a space separated list of tagName:tagValue strings. I made this function, for cases where you want to index documents but make all the fields searchable strings.

Finally, I made this library for learning purposes. Check out the code and tests.