fix(core): update
This commit is contained in:
@ -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.'
|
||||
}
|
||||
|
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