Skip to content

Commit

Permalink
Merge pull request #48 from appcoders/mr/addTypes
Browse files Browse the repository at this point in the history
Adding type information for usage from TypeScript
  • Loading branch information
moappi authored Apr 8, 2022
2 parents 8779f4e + 48f7859 commit 40712fc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,10 @@ Usage
let html = json2html.transform([{'male':'Bob','female':'Jane'},{'male':'Rick','female':'Ann'}],{"<>":"div","html":"${male} likes ${female}"});
```
TypeScript:
```javascript
import json2html from 'node-json2html'; //Import module
const { render, component } = json2html; // Import methods from Json2html
```
<a href='http://www.json2html.com'>www.json2html.com</a> for full documentation.
15 changes: 15 additions & 0 deletions node.json2html.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
interface componentMethods {
add: (name:object|string, template:object) => void,
get: (name:string) => object,
}
interface iHTMLInterface {
append: (ihtml:iHTMLInterface) => iHTMLInterface;
appendHTML: (html:string) => iHTMLInterface;
toJSON: () => object;

}
export function render(json: object|string, template: object, options?: object): string;
export function toText(html:string): string;
export const component: componentMethods;
export const version: string;
export const iHTML: iHTMLInterface;

0 comments on commit 40712fc

Please sign in to comment.