-
Notifications
You must be signed in to change notification settings - Fork 357
Promisified return value #205
base: gh-pages
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -19,6 +19,7 @@ | |||||||||||||||||
const isElement = obj => obj instanceof HTMLElement || obj instanceof SVGElement; | ||||||||||||||||||
const requireDomNode = el => { | ||||||||||||||||||
if (!isElement(el)) throw new Error(`an HTMLElement or SVGElement is required; got ${el}`); | ||||||||||||||||||
return; | ||||||||||||||||||
}; | ||||||||||||||||||
const isExternal = url => url && url.lastIndexOf('http',0) === 0 && url.lastIndexOf(window.location.host) === -1; | ||||||||||||||||||
|
||||||||||||||||||
|
@@ -339,6 +340,7 @@ | |||||||||||||||||
image.src = uri; | ||||||||||||||||||
}) | ||||||||||||||||||
}); | ||||||||||||||||||
return; | ||||||||||||||||||
}; | ||||||||||||||||||
|
||||||||||||||||||
out$.download = (name, uri) => { | ||||||||||||||||||
|
@@ -365,15 +367,26 @@ | |||||||||||||||||
window.open(uri, '_temp', 'menubar=no,toolbar=no,status=no'); | ||||||||||||||||||
} | ||||||||||||||||||
} | ||||||||||||||||||
return; | ||||||||||||||||||
}; | ||||||||||||||||||
|
||||||||||||||||||
out$.saveSvg = (el, name, options) => { | ||||||||||||||||||
requireDomNode(el); | ||||||||||||||||||
out$.svgAsDataUri(el, options || {}, uri => out$.download(name, uri)); | ||||||||||||||||||
return new Promise((resolve, reject) => { | ||||||||||||||||||
requireDomNode(el); | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably, but I think that would be a step in the wrong direction. It looks like
Suggested change
|
||||||||||||||||||
out$.svgAsDataUri(el, options || {}, uri => { | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but |
||||||||||||||||||
out$.download(name, uri) | ||||||||||||||||||
resolve(); | ||||||||||||||||||
}); | ||||||||||||||||||
}); | ||||||||||||||||||
}; | ||||||||||||||||||
|
||||||||||||||||||
out$.saveSvgAsPng = (el, name, options) => { | ||||||||||||||||||
requireDomNode(el); | ||||||||||||||||||
out$.svgAsPngUri(el, options || {}, uri => out$.download(name, uri)); | ||||||||||||||||||
return new Promise((resolve, reject) => { | ||||||||||||||||||
requireDomNode(el); | ||||||||||||||||||
out$.svgAsPngUri(el, options || {}, uri => { | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, but |
||||||||||||||||||
out$.download(name, uri); | ||||||||||||||||||
resolve(); | ||||||||||||||||||
}); | ||||||||||||||||||
}); | ||||||||||||||||||
}; | ||||||||||||||||||
})(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these
return
statements necessary?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They aren't, just experiment cruft. Sorry about that!