Skip to content

Commit 761150e

Browse files
committed
Add es6 import/export for utils
1 parent 5c8ef3a commit 761150e

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
* SOFTWARE.
2525
*/
2626

27+
import { objType, createElement, cloneNode, unitConvert } from './utils.js';
28+
2729
/**
2830
* Generate a PDF from an HTML element or string using html2canvas and jsPDF.
2931
*

src/utils.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Determine the type of a variable/object.
2-
var objType = function(obj) {
2+
export const objType = function(obj) {
33
if (typeof obj === 'undefined') return 'undefined';
44
else if (typeof obj === 'string' || obj instanceof String) return 'string';
55
else if (typeof obj === 'number' || obj instanceof Number) return 'number';
@@ -10,7 +10,7 @@ var objType = function(obj) {
1010
};
1111

1212
// Create an HTML element with optional className, innerHTML, and style.
13-
var createElement = function(tagName, opt) {
13+
export const createElement = function(tagName, opt) {
1414
var el = document.createElement(tagName);
1515
if (opt.className) el.className = opt.className;
1616
if (opt.innerHTML) {
@@ -27,7 +27,7 @@ var createElement = function(tagName, opt) {
2727
};
2828

2929
// Deep-clone a node and preserve contents/properties.
30-
var cloneNode = function(node, javascriptEnabled) {
30+
export const cloneNode = function(node, javascriptEnabled) {
3131
// Recursively clone the node.
3232
var clone = node.nodeType === 3 ? document.createTextNode(node.nodeValue) : node.cloneNode(false);
3333
for (var child = node.firstChild; child; child = child.nextSibling) {
@@ -58,7 +58,7 @@ var cloneNode = function(node, javascriptEnabled) {
5858
}
5959

6060
// Convert units using the conversion value 'k' from jsPDF.
61-
var unitConvert = function(obj, k) {
61+
export const unitConvert = function(obj, k) {
6262
var newObj = {};
6363
for (var key in obj) {
6464
newObj[key] = obj[key] * 72 / 96 / k;

0 commit comments

Comments
 (0)