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.12 to 1.0.13

2

cjs/request.js

@@ -50,2 +50,4 @@ "use strict";

if (typeof fetchApi !== 'function') fetchApi = undefined;
var addQueryString = function addQueryString(url, params) {

@@ -52,0 +54,0 @@ if (params && _typeof(params) === 'object') {

26

i18nextHttpBackend.js

@@ -273,2 +273,4 @@ (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){

if (typeof fetchApi !== 'function') fetchApi = undefined;
var addQueryString = function addQueryString(url, params) {

@@ -422,28 +424,4 @@ if (params && _typeof(params) === 'object') {

},{}],5:[function(require,module,exports){
(function (global){
"use strict";
// ref: https://github.com/tc39/proposal-global
var getGlobal = function () {
// the only reliable means to get the global object is
// `Function('return this')()`
// However, this causes CSP violations in Chrome apps.
if (typeof self !== 'undefined') { return self; }
if (typeof window !== 'undefined') { return window; }
if (typeof global !== 'undefined') { return global; }
throw new Error('unable to locate global object');
}
var global = getGlobal();
module.exports = exports = global.fetch;
// Needed for TypeScript and Webpack.
exports.default = global.fetch.bind(global);
exports.Headers = global.Headers;
exports.Request = global.Request;
exports.Response = global.Response;
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{}]},{},[2])(2)
});

@@ -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(l)return l(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 l="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&&((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:!1,customHeaders:{},queryStringParams:{},crossDomain:!1,withCredentials:!1,overrideMimeType:!1,requestOptions:{mode:"cors",credentials:"same-origin",cache:"default"}}}var u=function(){function o(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,o),this.services=e,this.options=t,this.allOptions=n,this.type="backend",this.init(e,t,n)}var e,t,n;return e=o,(t=[{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)return r("failed loading "+i,!0);if(t&&400<=t.status&&t.status<500)return r("failed loading "+i,!1);if(e)return r(e,!1);var n,o;try{n=u.options.parse(t.data,a,s)}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(e.prototype,t),n&&r(e,n),o}();u.type="backend",n.default=u,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"!==l(e)&&"function"!=typeof e)return{default:e};var t=f();if(t&&t.has(e))return t.get(e);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e){var r;Object.prototype.hasOwnProperty.call(e,i)&&((r=o?Object.getOwnPropertyDescriptor(e,i):null)&&(r.get||r.set)?Object.defineProperty(n,i,r):n[i]=e[i])}n.default=e,t&&t.set(e,n);return n}(o("./getFetch.js"));function f(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return f=function(){return e},e}function l(e){return(l="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&&(r=t.default||t);function d(e,t){if(t&&"object"===l(t)){var n="";for(var o in t)n+="&"+encodeURIComponent(o)+"="+encodeURIComponent(t[o]);if(!n)return e;e=e+(-1!==e.indexOf("?")?"&":"?")+n.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=d(t,e.queryStringParams));var i=(0,a.defaults)({},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){if(!t.ok)return o(t.statusText||"Error",{status:t.status});t.text().then(function(e){o(null,{status:t.status,data:e})}).catch(o)}).catch(o)}(e,t,n,o):"function"==typeof XMLHttpRequest||"function"==typeof ActiveXObject?function(e,t,n,o){n&&"object"===l(n)&&(n=d("",n).slice(1)),e.queryStringParams&&(t=d(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(i.statusText,{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){(function(e){"use strict";e=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==e)return e;throw new Error("unable to locate global object")}();t.exports=n=e.fetch,n.default=e.fetch.bind(e),n.Headers=e.Headers,n.Request=e.Request,n.Response=e.Response}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[2])(2)});
!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(l)return l(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 l="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&&((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:!1,customHeaders:{},queryStringParams:{},crossDomain:!1,withCredentials:!1,overrideMimeType:!1,requestOptions:{mode:"cors",credentials:"same-origin",cache:"default"}}}var u=function(){function o(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,o),this.services=e,this.options=t,this.allOptions=n,this.type="backend",this.init(e,t,n)}var e,t,n;return e=o,(t=[{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)return r("failed loading "+i,!0);if(t&&400<=t.status&&t.status<500)return r("failed loading "+i,!1);if(e)return r(e,!1);var n,o;try{n=u.options.parse(t.data,a,s)}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(e.prototype,t),n&&r(e,n),o}();u.type="backend",n.default=u,t.exports=n.default},{"./request.js":3,"./utils.js":4}],3:[function(o,i,d){(function(e){"use strict";Object.defineProperty(d,"__esModule",{value:!0}),d.default=void 0;var r,s,u,a=o("./utils.js"),t=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==l(e)&&"function"!=typeof e)return{default:e};var t=f();if(t&&t.has(e))return t.get(e);var n={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var i in e){var r;Object.prototype.hasOwnProperty.call(e,i)&&((r=o?Object.getOwnPropertyDescriptor(e,i):null)&&(r.get||r.set)?Object.defineProperty(n,i,r):n[i]=e[i])}n.default=e,t&&t.set(e,n);return n}(o("./getFetch.js"));function f(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return f=function(){return e},e}function l(e){return(l="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&&(r=t.default||t),"function"!=typeof r&&(r=void 0);function c(e,t){if(t&&"object"===l(t)){var n="";for(var o in t)n+="&"+encodeURIComponent(o)+"="+encodeURIComponent(t[o]);if(!n)return e;e=e+(-1!==e.indexOf("?")?"&":"?")+n.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=c(t,e.queryStringParams));var i=(0,a.defaults)({},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){if(!t.ok)return o(t.statusText||"Error",{status:t.status});t.text().then(function(e){o(null,{status:t.status,data:e})}).catch(o)}).catch(o)}(e,t,n,o):"function"==typeof XMLHttpRequest||"function"==typeof ActiveXObject?function(e,t,n,o){n&&"object"===l(n)&&(n=c("",n).slice(1)),e.queryStringParams&&(t=c(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(i.statusText,{status:i.status,data:i.responseText})},i.send(n)}catch(e){console&&console.log(e)}}(e,t,n,o):void 0}d.default=n,i.exports=d.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)});

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

if (!fetchApi && fetchNode) fetchApi = fetchNode.default || fetchNode // because of strange export
if (typeof fetchApi !== 'function') fetchApi = undefined

@@ -31,0 +32,0 @@ const addQueryString = (url, params) => {

{
"name": "i18next-http-backend",
"version": "1.0.12",
"version": "1.0.13",
"private": false,

@@ -66,3 +66,3 @@ "type": "module",

"compile": "rm -rf cjs && mkdir cjs && babel lib -d cjs --presets=@babel/preset-env --plugins=add-module-exports && echo '{\"type\":\"commonjs\"}' > cjs/package.json && cp lib/getFetch.cjs cjs/getFetch.js && node -e \"fs.writeFileSync('cjs/request.js', fs.readFileSync('cjs/request.js').toString().replace('getFetch.cjs', 'getFetch.js'))\"",
"browser": "browserify --standalone i18nextHttpBackend cjs/index.js -o i18nextHttpBackend.js && uglifyjs i18nextHttpBackend.js --compress --mangle -o i18nextHttpBackend.min.js",
"browser": "browserify --ignore node-fetch --standalone i18nextHttpBackend cjs/index.js -o i18nextHttpBackend.js && uglifyjs i18nextHttpBackend.js --compress --mangle -o i18nextHttpBackend.min.js",
"build": "npm run compile && npm run browser",

@@ -69,0 +69,0 @@ "test:xmlhttpreq": "mocha test -R spec --require test/fixtures/xmlHttpRequest.cjs --exit --experimental-modules",

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