Skip to content

Instantly share code, notes, and snippets.

@lac5
Created October 16, 2019 13:00
Show Gist options
  • Save lac5/739c922cefb1efc17cdb64a5aafbfa9a to your computer and use it in GitHub Desktop.
Save lac5/739c922cefb1efc17cdb64a5aafbfa9a to your computer and use it in GitHub Desktop.
export default class StyleMap extends Map {
toString(space, newline) {
let style = '';
for (let [key, value] of this) {
style += key;
style += ':';
if (typeof space === 'number') {
for (let i = 0; i < space; i++) {
style += ' ';
}
} else if (typeof space === 'string') {
style += space;
}
style += value;
style += ';';
if (typeof newline === 'string') {
style += newline;
} else if (typeof space === 'number') {
for (let i = 0; i < space; i++) {
style += ' ';
}
} else if (typeof space === 'string') {
style += space;
}
}
return style;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment