fix(core): update

This commit is contained in:
2024-04-17 20:10:59 +02:00
parent 777d7ae1b3
commit e44d014733
4 changed files with 427 additions and 1184 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartjson',
version: '5.0.16',
description: 'typed json handlers'
version: '5.0.17',
description: 'A library for handling typed JSON data, providing functionalities for parsing, stringifying, and working with JSON objects, including support for encoding and decoding buffers.'
}

View File

@ -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