From eeee33969b6d8f77735ddf49eab758b63d53a81f Mon Sep 17 00:00:00 2001 From: "Basile Trujillo [L0gIn]" Date: Wed, 31 Jul 2019 15:55:46 +0200 Subject: [PATCH] Handled browser compatibility Exports objects and functions only if module and exports node objects are available --- index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index df607cb..e9e5483 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,3 @@ -exports.remove = removeDiacritics; - var replacementList = [ { base: ' ', @@ -312,5 +310,9 @@ function removeDiacritics(str) { }); } -exports.replacementList = replacementList; -exports.diacriticsMap = diacriticsMap; +// Uses NodeJS exports only if available (handles browser compatibility) +if('object' === typeof exports && 'undefined' != typeof module) { + exports.remove = removeDiacritics; + exports.replacementList = replacementList; + exports.diacriticsMap = diacriticsMap; +}