From 8f89e4d637364f4322758f96481fe61b4deb0660 Mon Sep 17 00:00:00 2001 From: Adrian Etter Date: Fri, 1 Feb 2019 15:17:06 +0100 Subject: [PATCH] allow es6 import of unibabel.hex --- package.json | 2 +- unibabel.hex.js | 29 +++++++++++++++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 3c27db8..dbfc8df 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "unibabel", - "version": "2.1.7", + "version": "2.1.8", "description": "Base64, TypedArrays, and UTF-8 / Unicode conversions in Browser (and Node) JavaScript", "main": "node.js", "browser": { diff --git a/unibabel.hex.js b/unibabel.hex.js index e1bf50d..ef87378 100644 --- a/unibabel.hex.js +++ b/unibabel.hex.js @@ -1,6 +1,25 @@ -(function () { +(function (exports) { 'use strict'; +var _index = require('./index.js'); + +var Unibabel = _interopRequireWildcard(_index).Unibabel; + +function _interopRequireWildcard(obj) { + if (obj && obj.__esModule) { + return obj; + } else { + var newObj = {}; + if (obj != null) { + for (var key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; + } + } + newObj.default = obj; + return newObj; + } +} + function bufferToHex(arr) { var i; var len; @@ -40,7 +59,9 @@ function hexToBuffer(hex) { } // Hex Convenience Functions -window.Unibabel.hexToBuffer = hexToBuffer; -window.Unibabel.bufferToHex = bufferToHex; +Unibabel.hexToBuffer = hexToBuffer; +Unibabel.bufferToHex = bufferToHex; -}()); +exports.Unibabel = Unibabel; + +}('undefined' !== typeof exports && exports || 'undefined' !== typeof window && window || global));