fix(core): update
This commit is contained in:
15
ts/index.ts
15
ts/index.ts
@@ -2,11 +2,26 @@ import * as plugins from './smartjson.plugins.js';
|
||||
import * as bufferhandling from './bufferhandling.js';
|
||||
import { json } from 'stream/consumers';
|
||||
|
||||
interface JsonObject {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* allows you to parse a json
|
||||
*/
|
||||
export const parse = bufferhandling.parse;
|
||||
|
||||
export const parseJsonL = (jsonlData: string): JsonObject[] => {
|
||||
const lines = jsonlData.trim().split('\n');
|
||||
const parsedData: JsonObject[] = lines.reduce((acc, line) => {
|
||||
if (line.trim().length > 0) {
|
||||
acc.push(JSON.parse(line));
|
||||
}
|
||||
return acc;
|
||||
}, [] as JsonObject[]);
|
||||
return parsedData;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param objArg
|
||||
|
Reference in New Issue
Block a user