File tree Expand file tree Collapse file tree 2 files changed +16
-11
lines changed
Expand file tree Collapse file tree 2 files changed +16
-11
lines changed Original file line number Diff line number Diff line change 1- export namespace URI {
2- function expand ( template : string , data : { [ key : string ] : unknown } ) : string ;
1+ declare class Template {
2+ constructor ( template : string ) ;
3+ expand ( data : { [ key : string ] : unknown } ) : string ;
4+ match ( uri : string ) : { [ key : string ] : string } ;
5+ }
6+
7+ declare function expand ( template : string , data : { [ key : string ] : unknown } ) : string ;
38
4- class Template {
5- constructor ( template : string ) ;
6- expand : ( data : { [ key : string ] : unknown } ) => string ;
7- match : ( template : string ) => { [ key : string ] : string } ;
8- }
9+ declare namespace Template {
10+ export { expand } ;
911}
12+
13+ export = Template ;
Original file line number Diff line number Diff line change 1- import { URI } from "uri-template-lite" ;
1+ import Template from "uri-template-lite" ;
22
3- // Call `expand` directly
3+ // Call `expand` directly via the static method
44const dataSet = { domain : "example.com" , user : "fred" , query : "mycelium" } ;
5- URI . expand ( "http://{domain}/~{user}/foo{?query,number}" , dataSet ) ;
5+ Template . expand ( "http://{domain}/~{user}/foo{?query,number}" , dataSet ) ;
66
7- const template = new URI . Template ( "http://{domain}/~{user}/foo{?query,number}" ) ;
7+ // Create a template instance
8+ const template = new Template ( "http://{domain}/~{user}/foo{?query,number}" ) ;
89template . expand ( dataSet ) ;
910template . match ( "http://example.com/~fred/foo?query=mycelium&number=3" ) ;
1011template . match ( "http://other.com/?query=mycelium" ) ;
You can’t perform that action at this time.
0 commit comments