Socket
Socket
Sign inDemoInstall

i18next-http-backend

Package Overview
Dependencies
Maintainers
2
Versions
66
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i18next-http-backend - npm Package Compare versions

Comparing version 1.0.21 to 1.0.22

4

cjs/request.js

@@ -30,3 +30,3 @@ "use strict";

if (typeof XMLHttpRequest === 'function') {
if (_utils.hasXMLHttpRequest) {
if (typeof global !== 'undefined' && global.XMLHttpRequest) {

@@ -159,3 +159,3 @@ XmlHttpRequestApi = global.XMLHttpRequest;

if (typeof XMLHttpRequest === 'function' || typeof ActiveXObject === 'function') {
if (_utils.hasXMLHttpRequest || typeof ActiveXObject === 'function') {
return requestWithXmlHttpRequest(options, url, payload, callback);

@@ -162,0 +162,0 @@ }

@@ -7,2 +7,6 @@ "use strict";

exports.defaults = defaults;
exports.hasXMLHttpRequest = hasXMLHttpRequest;
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
var arr = [];

@@ -21,2 +25,6 @@ var each = arr.forEach;

return obj;
}
function hasXMLHttpRequest() {
return typeof XMLHttpRequest === 'function' || (typeof XMLHttpRequest === "undefined" ? "undefined" : _typeof(XMLHttpRequest)) === 'object';
}
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
import { defaults } from './utils.js';
import { defaults, hasXMLHttpRequest } from './utils.js';
import * as fetchNode from './getFetch.cjs';

@@ -17,3 +17,3 @@ var fetchApi;

if (typeof XMLHttpRequest === 'function') {
if (hasXMLHttpRequest) {
if (typeof global !== 'undefined' && global.XMLHttpRequest) {

@@ -146,3 +146,3 @@ XmlHttpRequestApi = global.XMLHttpRequest;

if (typeof XMLHttpRequest === 'function' || typeof ActiveXObject === 'function') {
if (hasXMLHttpRequest || typeof ActiveXObject === 'function') {
return requestWithXmlHttpRequest(options, url, payload, callback);

@@ -149,0 +149,0 @@ }

@@ -0,1 +1,3 @@

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
var arr = [];

@@ -13,2 +15,5 @@ var each = arr.forEach;

return obj;
}
export function hasXMLHttpRequest() {
return typeof XMLHttpRequest === 'function' || (typeof XMLHttpRequest === "undefined" ? "undefined" : _typeof(XMLHttpRequest)) === 'object';
}
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.i18nextHttpBackend = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
(function (global){
(function (global){(function (){
var fetchApi

@@ -19,3 +19,3 @@ if (typeof fetch === 'function') {

}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"node-fetch":5}],2:[function(require,module,exports){

@@ -218,3 +218,3 @@ "use strict";

},{"./request.js":3,"./utils.js":4}],3:[function(require,module,exports){
(function (global){
(function (global){(function (){
"use strict";

@@ -249,3 +249,3 @@

if (typeof XMLHttpRequest === 'function') {
if (_utils.hasXMLHttpRequest) {
if (typeof global !== 'undefined' && global.XMLHttpRequest) {

@@ -378,3 +378,3 @@ XmlHttpRequestApi = global.XMLHttpRequest;

if (typeof XMLHttpRequest === 'function' || typeof ActiveXObject === 'function') {
if (_utils.hasXMLHttpRequest || typeof ActiveXObject === 'function') {
return requestWithXmlHttpRequest(options, url, payload, callback);

@@ -387,3 +387,3 @@ }

module.exports = exports.default;
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"./getFetch.js":1,"./utils.js":4}],4:[function(require,module,exports){

@@ -396,2 +396,6 @@ "use strict";

exports.defaults = defaults;
exports.hasXMLHttpRequest = hasXMLHttpRequest;
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
var arr = [];

@@ -411,2 +415,6 @@ var each = arr.forEach;

}
function hasXMLHttpRequest() {
return typeof XMLHttpRequest === 'function' || (typeof XMLHttpRequest === "undefined" ? "undefined" : _typeof(XMLHttpRequest)) === 'object';
}
},{}],5:[function(require,module,exports){

@@ -413,0 +421,0 @@

@@ -1,1 +0,1 @@

!function(e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).i18nextHttpBackend=e()}(function(){return function r(a,s,u){function f(t,e){if(!s[t]){if(!a[t]){var n="function"==typeof require&&require;if(!e&&n)return n(t,!0);if(d)return d(t,!0);var o=new Error("Cannot find module '"+t+"'");throw o.code="MODULE_NOT_FOUND",o}var i=s[t]={exports:{}};a[t][0].call(i.exports,function(e){return f(a[t][1][e]||e)},i,i.exports,r,a,s,u)}return s[t].exports}for(var d="function"==typeof require&&require,e=0;e<u.length;e++)f(u[e]);return f}({1:[function(o,i,r){(function(e){var t,n;"function"==typeof fetch&&(void 0!==e&&e.fetch?t=e.fetch:"undefined"!=typeof window&&window.fetch&&(t=window.fetch)),void 0===o||"undefined"!=typeof window&&void 0!==window.document||((n=t||o("node-fetch")).default&&(n=n.default),r.default=n,i.exports=r.default)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"node-fetch":5}],2:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var o,a=e("./utils.js"),i=(o=e("./request.js"))&&o.__esModule?o:{default:o};function r(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function s(){return{loadPath:"/locales/{{lng}}/{{ns}}.json",addPath:"/locales/add/{{lng}}/{{ns}}",allowMultiLoading:!1,parse:function(e){return JSON.parse(e)},stringify:JSON.stringify,parsePayload:function(e,t,n){return r=n||"",(i=t)in(o={})?Object.defineProperty(o,i,{value:r,enumerable:!0,configurable:!0,writable:!0}):o[i]=r,o;var o,i,r},request:i.default,reloadInterval:"undefined"==typeof window&&36e5,customHeaders:{},queryStringParams:{},crossDomain:!1,withCredentials:!1,overrideMimeType:!1,requestOptions:{mode:"cors",credentials:"same-origin",cache:"default"}}}var u,f,d,l=(u=c,(f=[{key:"init",value:function(e,t,n){var o=this,i=1<arguments.length&&void 0!==t?t:{},r=2<arguments.length&&void 0!==n?n:{};this.services=e,this.options=(0,a.defaults)(i,this.options||{},s()),this.allOptions=r,this.options.reloadInterval&&setInterval(function(){return o.reload()},this.options.reloadInterval)}},{key:"readMulti",value:function(e,t,n){var o=this.options.loadPath;"function"==typeof this.options.loadPath&&(o=this.options.loadPath(e,t));var i=this.services.interpolator.interpolate(o,{lng:e.join("+"),ns:t.join("+")});this.loadUrl(i,n,e,t)}},{key:"read",value:function(e,t,n){var o=this.options.loadPath;"function"==typeof this.options.loadPath&&(o=this.options.loadPath([e],[t]));var i=this.services.interpolator.interpolate(o,{lng:e,ns:t});this.loadUrl(i,n,e,t)}},{key:"loadUrl",value:function(i,r,a,s){var u=this;this.options.request(this.options,i,void 0,function(e,t){if(t&&(500<=t.status&&t.status<600||!t.status))return r("failed loading "+i,!0);if(t&&400<=t.status&&t.status<500)return r("failed loading "+i,!1);if(!t&&e&&e.message&&-1<e.message.indexOf("Failed to fetch"))return r("failed loading "+i,!0);if(e)return r(e,!1);var n,o;try{n="string"==typeof t.data?u.options.parse(t.data,a,s):t.data}catch(e){o="failed parsing "+i+" to json"}if(o)return r(o,!1);r(null,n)})}},{key:"create",value:function(e,n,t,o){var i,r=this;this.options.addPath&&("string"==typeof e&&(e=[e]),i=this.options.parsePayload(n,t,o),e.forEach(function(e){var t=r.services.interpolator.interpolate(r.options.addPath,{lng:e,ns:n});r.options.request(r.options,t,i,function(e,t){})}))}},{key:"reload",value:function(){var t,e,n=this,o=this.services,i=o.backendConnector,r=o.languageUtils,a=o.logger,s=i.language;s&&"cimode"===s.toLowerCase()||(t=[],(e=function(e){r.toResolveHierarchy(e).forEach(function(e){t.indexOf(e)<0&&t.push(e)})})(s),this.allOptions.preload&&this.allOptions.preload.forEach(e),t.forEach(function(o){n.allOptions.ns.forEach(function(n){i.read(o,n,"read",null,null,function(e,t){e&&a.warn("loading namespace ".concat(n," for language ").concat(o," failed"),e),!e&&t&&a.log("loaded namespace ".concat(n," for language ").concat(o),t),i.loaded("".concat(o,"|").concat(n),e,t)})})}))}}])&&r(u.prototype,f),d&&r(u,d),c);function c(e){var t=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,c),this.services=e,this.options=t,this.allOptions=n,this.type="backend",this.init(e,t,n)}l.type="backend",n.default=l,t.exports=n.default},{"./request.js":3,"./utils.js":4}],3:[function(o,i,c){(function(e){"use strict";Object.defineProperty(c,"__esModule",{value:!0}),c.default=void 0;var r,s,u,a=o("./utils.js"),t=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==d(e)&&"function"!=typeof e)return{default:e};var t=f();if(t&&t.has(e))return t.get(e);var n,o={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(n in e){var r;Object.prototype.hasOwnProperty.call(e,n)&&((r=i?Object.getOwnPropertyDescriptor(e,n):null)&&(r.get||r.set)?Object.defineProperty(o,n,r):o[n]=e[n])}o.default=e,t&&t.set(e,o);return o}(o("./getFetch.js"));function f(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return f=function(){return e},e}function d(e){return(d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}"function"==typeof fetch&&(void 0!==e&&e.fetch?r=e.fetch:"undefined"!=typeof window&&window.fetch&&(r=window.fetch)),"function"==typeof XMLHttpRequest&&(void 0!==e&&e.XMLHttpRequest?s=e.XMLHttpRequest:"undefined"!=typeof window&&window.XMLHttpRequest&&(s=window.XMLHttpRequest)),"function"==typeof ActiveXObject&&(void 0!==e&&e.ActiveXObject?u=e.ActiveXObject:"undefined"!=typeof window&&window.ActiveXObject&&(u=window.ActiveXObject)),r||!t||s||u||(r=t.default||t),"function"!=typeof r&&(r=void 0);function l(e,t){if(t&&"object"===d(t)){var n,o="";for(n in t)o+="&"+encodeURIComponent(n)+"="+encodeURIComponent(t[n]);if(!o)return e;e=e+(-1!==e.indexOf("?")?"&":"?")+o.slice(1)}return e}function n(e,t,n,o){return"function"==typeof n&&(o=n,n=void 0),o=o||function(){},r?function(e,t,n,o){e.queryStringParams&&(t=l(t,e.queryStringParams));var i=(0,a.defaults)({},"function"==typeof e.customHeaders?e.customHeaders():e.customHeaders);n&&(i["Content-Type"]="application/json"),r(t,(0,a.defaults)({method:n?"POST":"GET",body:n?e.stringify(n):void 0,headers:i},"function"==typeof e.requestOptions?e.requestOptions(n):e.requestOptions)).then(function(t){return t.ok?void t.text().then(function(e){o(null,{status:t.status,data:e})}).catch(o):o(t.statusText||"Error",{status:t.status})}).catch(o)}(e,t,n,o):"function"==typeof XMLHttpRequest||"function"==typeof ActiveXObject?function(e,t,n,o){n&&"object"===d(n)&&(n=l("",n).slice(1)),e.queryStringParams&&(t=l(t,e.queryStringParams));try{var i=s?new s:new u("MSXML2.XMLHTTP.3.0");i.open(n?"POST":"GET",t,1),e.crossDomain||i.setRequestHeader("X-Requested-With","XMLHttpRequest"),i.withCredentials=!!e.withCredentials,n&&i.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),i.overrideMimeType&&i.overrideMimeType("application/json");var r=e.customHeaders;if(r="function"==typeof r?r():r)for(var a in r)i.setRequestHeader(a,r[a]);i.onreadystatechange=function(){3<i.readyState&&o(400<=i.status?i.statusText:null,{status:i.status,data:i.responseText})},i.send(n)}catch(e){console&&console.log(e)}}(e,t,n,o):void 0}c.default=n,i.exports=c.default}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./getFetch.js":1,"./utils.js":4}],4:[function(e,t,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.defaults=function(n){return i.call(r.call(arguments,1),function(e){if(e)for(var t in e)void 0===n[t]&&(n[t]=e[t])}),n};var o=[],i=o.forEach,r=o.slice},{}],5:[function(e,t,n){},{}]},{},[2])(2)});
!function(t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).i18nextHttpBackend=t()}(function(){return function o(i,r,a){function s(e,t){if(!r[e]){if(!i[e]){var n="function"==typeof require&&require;if(!t&&n)return n(e,!0);if(u)return u(e,!0);throw(n=new Error("Cannot find module '"+e+"'")).code="MODULE_NOT_FOUND",n}n=r[e]={exports:{}},i[e][0].call(n.exports,function(t){return s(i[e][1][t]||t)},n,n.exports,o,i,r,a)}return r[e].exports}for(var u="function"==typeof require&&require,t=0;t<a.length;t++)s(a[t]);return s}({1:[function(n,o,i){(function(e){(function(){var t;"function"==typeof fetch&&(void 0!==e&&e.fetch?t=e.fetch:"undefined"!=typeof window&&window.fetch&&(t=window.fetch)),void 0===n||"undefined"!=typeof window&&void 0!==window.document||((t=t||n("node-fetch")).default&&(t=t.default),i.default=t,o.exports=i.default)}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"node-fetch":5}],2:[function(t,e,n){"use strict";Object.defineProperty(n,"__esModule",{value:!0}),n.default=void 0;var o,i=t("./utils.js"),r=(o=t("./request.js"))&&o.__esModule?o:{default:o};function a(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}function s(){return{loadPath:"/locales/{{lng}}/{{ns}}.json",addPath:"/locales/add/{{lng}}/{{ns}}",allowMultiLoading:!1,parse:function(t){return JSON.parse(t)},stringify:JSON.stringify,parsePayload:function(t,e,n){return o=n||"",(n=e)in(e={})?Object.defineProperty(e,n,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[n]=o,e;var o},request:r.default,reloadInterval:"undefined"==typeof window&&36e5,customHeaders:{},queryStringParams:{},crossDomain:!1,withCredentials:!1,overrideMimeType:!1,requestOptions:{mode:"cors",credentials:"same-origin",cache:"default"}}}var u,f,l,c=(u=d,(f=[{key:"init",value:function(t){var e=this,n=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},o=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};this.services=t,this.options=(0,i.defaults)(n,this.options||{},s()),this.allOptions=o,this.options.reloadInterval&&setInterval(function(){return e.reload()},this.options.reloadInterval)}},{key:"readMulti",value:function(t,e,n){var o=this.options.loadPath;"function"==typeof this.options.loadPath&&(o=this.options.loadPath(t,e));o=this.services.interpolator.interpolate(o,{lng:t.join("+"),ns:e.join("+")});this.loadUrl(o,n,t,e)}},{key:"read",value:function(t,e,n){var o=this.options.loadPath;"function"==typeof this.options.loadPath&&(o=this.options.loadPath([t],[e]));o=this.services.interpolator.interpolate(o,{lng:t,ns:e});this.loadUrl(o,n,t,e)}},{key:"loadUrl",value:function(i,r,a,s){var u=this;this.options.request(this.options,i,void 0,function(t,e){if(e&&(500<=e.status&&e.status<600||!e.status))return r("failed loading "+i,!0);if(e&&400<=e.status&&e.status<500)return r("failed loading "+i,!1);if(!e&&t&&t.message&&-1<t.message.indexOf("Failed to fetch"))return r("failed loading "+i,!0);if(t)return r(t,!1);var n,o;try{n="string"==typeof e.data?u.options.parse(e.data,a,s):e.data}catch(t){o="failed parsing "+i+" to json"}if(o)return r(o,!1);r(null,n)})}},{key:"create",value:function(t,e,n,o){var i,r=this;this.options.addPath&&("string"==typeof t&&(t=[t]),i=this.options.parsePayload(e,n,o),t.forEach(function(t){t=r.services.interpolator.interpolate(r.options.addPath,{lng:t,ns:e});r.options.request(r.options,t,i,function(t,e){})}))}},{key:"reload",value:function(){var e,t=this,n=this.services,i=n.backendConnector,o=n.languageUtils,r=n.logger,a=i.language;a&&"cimode"===a.toLowerCase()||(e=[],(n=function(t){o.toResolveHierarchy(t).forEach(function(t){e.indexOf(t)<0&&e.push(t)})})(a),this.allOptions.preload&&this.allOptions.preload.forEach(n),e.forEach(function(o){t.allOptions.ns.forEach(function(n){i.read(o,n,"read",null,null,function(t,e){t&&r.warn("loading namespace ".concat(n," for language ").concat(o," failed"),t),!t&&e&&r.log("loaded namespace ".concat(n," for language ").concat(o),e),i.loaded("".concat(o,"|").concat(n),t,e)})})}))}}])&&a(u.prototype,f),l&&a(u,l),d);function d(t){var e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},n=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};!function(t){if(!(t instanceof d))throw new TypeError("Cannot call a class as a function")}(this),this.services=t,this.options=e,this.allOptions=n,this.type="backend",this.init(t,e,n)}c.type="backend",n.default=c,e.exports=n.default},{"./request.js":3,"./utils.js":4}],3:[function(n,o,i){(function(e){(function(){"use strict";Object.defineProperty(i,"__esModule",{value:!0}),i.default=void 0;var r,s,u,a=n("./utils.js"),t=function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==l(t)&&"function"!=typeof t)return{default:t};var e=f();if(e&&e.has(t))return e.get(t);var n,o={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(n in t){var r;Object.prototype.hasOwnProperty.call(t,n)&&((r=i?Object.getOwnPropertyDescriptor(t,n):null)&&(r.get||r.set)?Object.defineProperty(o,n,r):o[n]=t[n])}o.default=t,e&&e.set(t,o);return o}(n("./getFetch.js"));function f(){if("function"!=typeof WeakMap)return null;var t=new WeakMap;return f=function(){return t},t}function l(t){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}"function"==typeof fetch&&(void 0!==e&&e.fetch?r=e.fetch:"undefined"!=typeof window&&window.fetch&&(r=window.fetch)),a.hasXMLHttpRequest&&(void 0!==e&&e.XMLHttpRequest?s=e.XMLHttpRequest:"undefined"!=typeof window&&window.XMLHttpRequest&&(s=window.XMLHttpRequest)),"function"==typeof ActiveXObject&&(void 0!==e&&e.ActiveXObject?u=e.ActiveXObject:"undefined"!=typeof window&&window.ActiveXObject&&(u=window.ActiveXObject)),r||!t||s||u||(r=t.default||t),"function"!=typeof r&&(r=void 0);function c(t,e){if(e&&"object"===l(e)){var n,o="";for(n in e)o+="&"+encodeURIComponent(n)+"="+encodeURIComponent(e[n]);if(!o)return t;t=t+(-1!==t.indexOf("?")?"&":"?")+o.slice(1)}return t}t=function(t,e,n,o){return"function"==typeof n&&(o=n,n=void 0),o=o||function(){},r?function(t,e,n,o){t.queryStringParams&&(e=c(e,t.queryStringParams));var i=(0,a.defaults)({},"function"==typeof t.customHeaders?t.customHeaders():t.customHeaders);n&&(i["Content-Type"]="application/json"),r(e,(0,a.defaults)({method:n?"POST":"GET",body:n?t.stringify(n):void 0,headers:i},"function"==typeof t.requestOptions?t.requestOptions(n):t.requestOptions)).then(function(e){return e.ok?void e.text().then(function(t){o(null,{status:e.status,data:t})}).catch(o):o(e.statusText||"Error",{status:e.status})}).catch(o)}(t,e,n,o):a.hasXMLHttpRequest||"function"==typeof ActiveXObject?function(t,e,n,o){n&&"object"===l(n)&&(n=c("",n).slice(1)),t.queryStringParams&&(e=c(e,t.queryStringParams));try{var i=s?new s:new u("MSXML2.XMLHTTP.3.0");i.open(n?"POST":"GET",e,1),t.crossDomain||i.setRequestHeader("X-Requested-With","XMLHttpRequest"),i.withCredentials=!!t.withCredentials,n&&i.setRequestHeader("Content-Type","application/x-www-form-urlencoded"),i.overrideMimeType&&i.overrideMimeType("application/json");var r=t.customHeaders;if(r="function"==typeof r?r():r)for(var a in r)i.setRequestHeader(a,r[a]);i.onreadystatechange=function(){3<i.readyState&&o(400<=i.status?i.statusText:null,{status:i.status,data:i.responseText})},i.send(n)}catch(t){console&&console.log(t)}}(t,e,n,o):void 0};i.default=t,o.exports=i.default}).call(this)}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./getFetch.js":1,"./utils.js":4}],4:[function(t,e,n){"use strict";function o(t){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}Object.defineProperty(n,"__esModule",{value:!0}),n.defaults=function(n){return i.call(r.call(arguments,1),function(t){if(t)for(var e in t)void 0===n[e]&&(n[e]=t[e])}),n},n.hasXMLHttpRequest=function(){return"function"==typeof XMLHttpRequest||"object"===("undefined"==typeof XMLHttpRequest?"undefined":o(XMLHttpRequest))};var n=[],i=n.forEach,r=n.slice},{}],5:[function(t,e,n){},{}]},{},[2])(2)});

@@ -46,3 +46,3 @@ import { defaults } from './utils.js'

readMulti (languages, namespaces, callback) {
var loadPath = this.options.loadPath
let loadPath = this.options.loadPath
if (typeof this.options.loadPath === 'function') {

@@ -56,3 +56,3 @@ loadPath = this.options.loadPath(languages, namespaces)

read (language, namespace, callback) {
var loadPath = this.options.loadPath
let loadPath = this.options.loadPath
if (typeof this.options.loadPath === 'function') {

@@ -59,0 +59,0 @@ loadPath = this.options.loadPath([language], [namespace])

@@ -1,2 +0,2 @@

import { defaults } from './utils.js'
import { defaults, hasXMLHttpRequest } from './utils.js'
import * as fetchNode from './getFetch.cjs'

@@ -13,3 +13,3 @@

let XmlHttpRequestApi
if (typeof XMLHttpRequest === 'function') {
if (hasXMLHttpRequest) {
if (typeof global !== 'undefined' && global.XMLHttpRequest) {

@@ -97,3 +97,3 @@ XmlHttpRequestApi = global.XMLHttpRequest

if (h) {
for (var i in h) {
for (const i in h) {
x.setRequestHeader(i, h[i])

@@ -123,3 +123,3 @@ }

if (typeof XMLHttpRequest === 'function' || typeof ActiveXObject === 'function') {
if (hasXMLHttpRequest || typeof ActiveXObject === 'function') {
// use xml http request

@@ -126,0 +126,0 @@ return requestWithXmlHttpRequest(options, url, payload, callback)

@@ -8,3 +8,3 @@ const arr = []

if (source) {
for (var prop in source) {
for (const prop in source) {
if (obj[prop] === undefined) obj[prop] = source[prop]

@@ -16,1 +16,5 @@ }

}
export function hasXMLHttpRequest () {
return (typeof XMLHttpRequest === 'function' || typeof XMLHttpRequest === 'object')
}
{
"name": "i18next-http-backend",
"version": "1.0.21",
"version": "1.0.22",
"private": false,

@@ -26,20 +26,20 @@ "type": "module",

"devDependencies": {
"@babel/cli": "7.11.6",
"@babel/core": "7.11.6",
"@babel/preset-env": "7.11.5",
"@babel/cli": "7.12.10",
"@babel/core": "7.12.10",
"@babel/preset-env": "7.12.11",
"babel-plugin-add-module-exports": "1.0.4",
"browserify": "16.5.2",
"eslint": "7.9.0",
"eslint-config-standard": "14.1.1",
"eslint-plugin-import": "2.22.0",
"browserify": "17.0.0",
"eslint": "7.18.0",
"eslint-config-standard": "16.0.2",
"eslint-plugin-import": "2.22.1",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "4.2.1",
"eslint-plugin-require-path-exists": "1.1.9",
"eslint-plugin-standard": "4.0.1",
"eslint-plugin-standard": "5.0.0",
"expect.js": "0.3.1",
"i18next": "19.7.0",
"json-server": "0.16.1",
"i18next": "19.8.4",
"json-server": "0.16.3",
"json5": "2.1.3",
"mocha": "8.1.3",
"uglify-js": "3.10.4",
"mocha": "8.2.1",
"uglify-js": "3.12.4",
"xmlhttprequest": "1.8.0"

@@ -77,3 +77,3 @@ },

"test": "npm run lint && npm run build && npm run test:fetch && npm run test:xmlhttpreq",
"test:deno": "deno test test/deno/*.js --allow-net --no-check",
"test:deno": "deno test --allow-net test/deno/*.js",
"preversion": "npm run test && npm run build && git push",

@@ -80,0 +80,0 @@ "postversion": "git push && git push --tags"

@@ -52,2 +52,5 @@ # Introduction

// the returned path will interpolate lng, ns if provided like giving a static path
//
// If allowMultiLoading is false, lngs and namespaces will have only one element each,
// If allowMultiLoading is true, lngs and namespaces can have multiple elements
loadPath: '/locales/{{lng}}/{{ns}}.json',

@@ -93,2 +96,7 @@

},
// can also be a function, that returns the headers
customHeaders: () => ({
authorization: 'foo',
// ...
}),

@@ -160,10 +168,10 @@ requestOptions: { // used for fetch, can also be a function (payload) => ({ method: 'GET' })

**localization as a service - locize.com**
**From the creators of i18next: localization as a service - locize.com**
Needing a translation management? Want to edit your translations with an InContext Editor? Use the orginal provided to you by the maintainers of i18next!
A translation management system built around the i18next ecosystem - [locize.com](https://locize.com).
![locize](https://locize.com/img/ads/github_locize.png)
With using [locize](http://locize.com/?utm_source=react_i18next_readme&utm_medium=github) you directly support the future of i18next and react-i18next.
With using [locize](http://locize.com/?utm_source=react_i18next_readme&utm_medium=github) you directly support the future of i18next.
---
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc