hexo-filter-probe-image-size
Version:
Probe and set image sizes in hexo web pages
24 lines (21 loc) • 510 B
JavaScript
class Attrs {
/**
* @param {string} stringAttrs
*/
constructor(stringAttrs) {
[...stringAttrs.matchAll(/(?<=\s*)([^\s=]+)(?:="([^"]*)")?/g)]
.forEach(([, name, value]) => {
this[name.toLowerCase()] = value;
});
return this;
}
toString() {
return Object.getOwnPropertyNames(this)
.map((name) => {
const value = this[name];
return ` ${name}${value === undefined ? '' : `="${value}"`}`;
})
.join('');
}
}
module.exports = Attrs;