forked from sindresorhus/srcset
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
66 lines (56 loc) · 1.15 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
declare namespace srcset {
interface SrcSetDefinition {
url: string;
width?: number;
density?: number;
}
}
declare const srcset: {
/**
Parse the HTML `<img>` [srcset](http://mobile.smashingmagazine.com/2013/08/21/webkit-implements-srcset-and-why-its-a-good-thing/) attribute.
@param srcset - A srcset string.
@example
```
import srcset = require('srcset');
console.log(srcset.parse('banner-HD.jpg 2x, banner-phone.jpg 100w'));
// [
// {
// url: 'banner-HD.jpg',
// density: 2
// },
// {
// url: 'banner-phone.jpg',
// width: 100
// }
// ]
```
*/
parse: (srcset: string) => srcset.SrcSetDefinition[];
/**
Stringify `SrcSetDefinition`s.
@returns A srcset string.
@example
```
import srcset = require('srcset');
const stringified = srcset.stringify([
{
url: 'banner-HD.jpg',
density: 2
},
{
url: 'banner-phone.jpg',
width: 100
},
{
url: 'banner-phone-HD.jpg',
width: 100,
density: 2
}
]);
console.log(stringified);
// banner-HD.jpg 2x, banner-phone.jpg 100w, banner-phone-HD.jpg 100w 2x
```
*/
stringify: (srcSetDefinitions: srcset.SrcSetDefinition[]) => string;
};
export = srcset;