BREAKING CHANGE(core): update
This commit is contained in:
		
							
								
								
									
										34
									
								
								ts/index.ts
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								ts/index.ts
									
									
									
									
									
								
							| @@ -1,20 +1,22 @@ | |||||||
| import * as plugins from './smartjson.plugins'; | import * as plugins from './smartjson.plugins'; | ||||||
|  |  | ||||||
| export class Smartjson { | /** | ||||||
|   // ====== |  | ||||||
|   // STATIC |  | ||||||
|   // ====== |  | ||||||
|   /** |  | ||||||
|  * allows you to parse a json |  * allows you to parse a json | ||||||
|  */ |  */ | ||||||
|   public static parse = plugins.bufferJson.parse; | export const parse = plugins.bufferJson.parse; | ||||||
|  |  | ||||||
|   public static stringify = (objArg: any, optionsArg: plugins.IStableJsonTypes['Options']) => { | /** | ||||||
|  |  *  | ||||||
|  |  * @param objArg | ||||||
|  |  * @param optionsArg | ||||||
|  |  */ | ||||||
|  | export const stringify = (objArg: any, optionsArg: plugins.IStableJsonTypes['Options'] = {}) => { | ||||||
|   const bufferedJson = plugins.bufferJson.stringify(objArg); |   const bufferedJson = plugins.bufferJson.stringify(objArg); | ||||||
|   objArg = JSON.parse(bufferedJson); |   objArg = JSON.parse(bufferedJson); | ||||||
|   return plugins.stableJson(objArg, optionsArg); |   return plugins.stableJson(objArg, optionsArg); | ||||||
|   } | }; | ||||||
|  |  | ||||||
|  | export class Smartjson { | ||||||
|   /** |   /** | ||||||
|    * enfolds data from an object |    * enfolds data from an object | ||||||
|    */ |    */ | ||||||
| @@ -28,6 +30,14 @@ export class Smartjson { | |||||||
|     return newInstance; |     return newInstance; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    * enfold from json | ||||||
|  |    */ | ||||||
|  |   public static enfoldFromJson(jsonArg: string) { | ||||||
|  |     const objectFromJson = parse(jsonArg); | ||||||
|  |     return this.enfoldFromObject(objectFromJson); | ||||||
|  |   } | ||||||
|  |  | ||||||
|   // ======== |   // ======== | ||||||
|   // INSTANCE |   // INSTANCE | ||||||
|   // ======== |   // ======== | ||||||
| @@ -44,6 +54,14 @@ export class Smartjson { | |||||||
|     } |     } | ||||||
|     return newFoldedObject; |     return newFoldedObject; | ||||||
|   } |   } | ||||||
|  |  | ||||||
|  |   /** | ||||||
|  |    * folds a class into an object | ||||||
|  |    */ | ||||||
|  |   public foldToJson() { | ||||||
|  |     const foldedObject = this.foldToObject(); | ||||||
|  |     return stringify(foldedObject, {}); | ||||||
|  |   } | ||||||
| } | } | ||||||
|  |  | ||||||
| /** | /** | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user