1.2.0 • Published 3 years ago
kabutils v1.2.0
kabutils
My personal library with some helper stuff in it.
How to use
npm i kabutilsThis library is ES6 only.
import * as kabutils from 'kabutils'
// or if you want only particular helpers
import { parseFromJsonL } from 'kabutils'Helpers
Waiting for some better docs, here is a list of the available helpers
Big Query and JSONL files
parseFromJsonL(jsonl)
- This function parses a string (for instance from a .jsonl file) you'd want as an array of JS objects.
@param {string} jsonlthe json (new line delimited) string you want to parse@returns {any[]}An array of javascript objects
parseToJsonL(jsonl)
- Parses an array of objects and returns a JSONL string as used in Big Query.
- You can have nested objects in it but no arrays. See limitations.
@param {Object[]} objectan array of object you want to parse to a jsonl string@returns {string}returns a JSON (new line delimited) string.
readFromJsonL
- This function reads from an input
.jsonlfile and returns an array of JS objects from it @param {string} pathpath of the jsonl file you want to read and parse.@returns {any[]}an array of JS objects parsed from the input file.
writeToJsonL
- Writes a file as per JSONL specs, useful for Big Query
@param {string} paththe output path and filename you want for the data. JSONL files' extension should (but don't have to) be.jsonl.@param {any[]}data An array of JS objects you want to store in a .jsonl file.