New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

i18njs

Package Overview
Dependencies
Maintainers
1
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i18njs - npm Package Compare versions

Comparing version 2.0.3 to 2.0.4

.editorconfig

2

bower.json
{
"name": "i18njs",
"main": "i18njs.js",
"version": "2.0.3",
"version": "2.0.4",
"homepage": "https://github.com/yoannmoinet/i18njs",

@@ -6,0 +6,0 @@ "authors": [

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

<a name="2.0.3"></a>
## 2.0.3 (2015-08-03)
<a name="2.0.4"></a>
## 2.0.4 (2015-08-08)

@@ -7,2 +7,17 @@

<a name="2.0.4"></a>
## 2.0.4 (2015-08-08)
### Bug Fixes
* check for `template` before using it ([b9292a2](https://github.com/yoannmoinet/i18njs/commit/b9292a2))
* jscs ([562ec71](https://github.com/yoannmoinet/i18njs/commit/562ec71))
### Features
* add pre-compiled template support ([83c8925](https://github.com/yoannmoinet/i18njs/commit/83c8925))
<a name="2.0.3"></a>

@@ -54,6 +69,6 @@ ## 2.0.3 (2015-08-03)

* add Travis CI ([988fc16](https://github.com/yoannmoinet/i18njs/commit/988fc16))
* add changelog ([45a3ccd](https://github.com/yoannmoinet/i18njs/commit/45a3ccd))
* add defaults template values ([3601034](https://github.com/yoannmoinet/i18njs/commit/3601034))
* add linting ([b9de51a](https://github.com/yoannmoinet/i18njs/commit/b9de51a))
* add Travis CI ([988fc16](https://github.com/yoannmoinet/i18njs/commit/988fc16))
* **npm:** add scripts ([4b6b378](https://github.com/yoannmoinet/i18njs/commit/4b6b378))

@@ -60,0 +75,0 @@

(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.i18njs = f()}})(function(){var define,module,exports;
/*eslint no-new-func:0*/
'use strict';
/*-------------------------------------------*\
| TEMPLATE SYSTEM
| Based on Underscore's
| template system.
| https://github.com/jashkenas/underscore/blob/master/underscore.js#L1388
\*-------------------------------------------*/
var noMatch = /(.)^/;

@@ -29,3 +21,4 @@ var escaperRegEx = /\\|'|\r|\n|\u2028|\u2029/g;

var createEscaper = function(map) {
var createEscaper = function (map) {
'use strict';
var escaper = function(match) {

@@ -47,3 +40,4 @@ return map[match];

var escapeChar = function(match) {
var escapeChar = function (match) {
'use strict';
return '\\' + escapes[match];

@@ -53,2 +47,3 @@ };

var template = function (text, settings) {
'use strict';
var index = 0;

@@ -107,5 +102,5 @@ var source = "__p+='";

};
/*---- END TEMPLATE ----*/
/*globals template*/
var parse = function (key, obj) {
'use strict';
var ar = key.split('.');

@@ -121,2 +116,3 @@

var I18n = function () {
'use strict';
// PRIVATES

@@ -209,3 +205,3 @@ var localLang = 'en';

if (typeof obj === 'string') {
if (typeof obj === 'string' || typeof obj === 'function') {
var i;

@@ -232,5 +228,7 @@ var settings = {

obj = template(obj, settings)(newDatas);
if (typeof obj !== 'function' && typeof template === 'function') {
obj = template(obj, settings);
}
return obj;
return obj(newDatas);
} else if (typeof obj === 'object') {

@@ -237,0 +235,0 @@ return obj;

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

!function(n){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.i18njs=n()}}(function(){var n=/(.)^/,e=/\\|'|\r|\n|\u2028|\u2029/g,t={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},r={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},o=function(n){var e=function(e){return n[e]},t="(?:"+Object.keys(n).join("|")+")",r=RegExp(t),o=RegExp(t,"g");return function(n){return n=null==n?"":""+n,r.test(n)?n.replace(o,e):n}},i=function(n){return"\\"+r[n]},u=function(r,u){var a=0,f="__p+='",s=RegExp([(u.escape||n).source,(u.interpolate||n).source,(u.evaluate||n).source].join("|")+"|$","g");r.replace(s,function(n,t,o,u,s){return f+=r.slice(a,s).replace(e,i),a=s+n.length,t?f+="'+\n((__t=("+t+"))==null?'':_.escape(__t))+\n'":o?f+="'+\n((__t=("+o+"))==null?'':__t)+\n'":u&&(f+="';\n"+u+"\n__p+='"),n}),f+="';\n",f="with(obj||{}){\n"+f+"}\n",f="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+f+"return __p;\n";try{var c=new Function("obj","_",f)}catch(p){throw p.source=f,p}var l=function(n){return c.call(this,n,{escape:o(t)})};return l.source="function(obj){\n"+f+"}",l},a=function(n,e){for(var t=n.split(".");e&&t.length;)e=e[t.shift()];return e},f=function(){var n="en",e={},t={},r=/\{\{([\s\S]+?)\}\}/g,o=/\{\{=([\s\S]+?)\}\}/g,i=/\{\{-([\s\S]+?)\}\}/g;this.add=function(n,t,r){var o,i;e[n]=e[n]||{},void 0===r?(r=t,t=void 0,i=e[n]):(e[n][t]=e[n][t]||{},i=e[n][t]);for(o in r)r.hasOwnProperty(o)&&(i[o]=r[o])},this.has=function(t,r){r=r||n;var o=r+"."+t;return e[t]?!0:a(o,e)?!0:!1},this.listLangs=function(){var n=[];for(var t in e)n.push(t);return n},this.getCurrentLang=function(){return n},this.getDico=function(){return e},this.setLang=function(e){return n=e},this.setDefaults=function(n){t=n||{}},this.get=function(f,s,c,p){var l=p||n;void 0===p&&("string"==typeof s?(l=s,s=void 0):"string"==typeof c&&(l=c));var _=a(l+"."+f,e);if(c=c||{},"string"==typeof _){var g,v={evaluate:c.evaluate||r,interpolate:c.interpolate||o,escape:c.escape||i},d={},h=t[n]||t;for(g in h)h.hasOwnProperty(g)&&(d[g]=h[g]);for(g in s)s.hasOwnProperty(g)&&(d[g]=s[g]);return _=u(_,v)(d)}return"object"==typeof _?_:f}};return new f});
!function(n){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.i18njs=n()}}(function(){var n=/(.)^/,t=/\\|'|\r|\n|\u2028|\u2029/g,e={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},r={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},o=function(n){"use strict";var t=function(t){return n[t]},e="(?:"+Object.keys(n).join("|")+")",r=RegExp(e),o=RegExp(e,"g");return function(n){return n=null==n?"":""+n,r.test(n)?n.replace(o,t):n}},i=function(n){"use strict";return"\\"+r[n]},u=function(r,u){"use strict";var s=0,f="__p+='",c=RegExp([(u.escape||n).source,(u.interpolate||n).source,(u.evaluate||n).source].join("|")+"|$","g");r.replace(c,function(n,e,o,u,c){return f+=r.slice(s,c).replace(t,i),s=c+n.length,e?f+="'+\n((__t=("+e+"))==null?'':_.escape(__t))+\n'":o?f+="'+\n((__t=("+o+"))==null?'':__t)+\n'":u&&(f+="';\n"+u+"\n__p+='"),n}),f+="';\n",f="with(obj||{}){\n"+f+"}\n",f="var __t,__p='',__j=Array.prototype.join,print=function(){__p+=__j.call(arguments,'');};\n"+f+"return __p;\n";try{var a=new Function("obj","_",f)}catch(p){throw p.source=f,p}var l=function(n){return a.call(this,n,{escape:o(e)})};return l.source="function(obj){\n"+f+"}",l},s=function(n,t){"use strict";for(var e=n.split(".");t&&e.length;)t=t[e.shift()];return t},f=function(){"use strict";var n="en",t={},e={},r=/\{\{([\s\S]+?)\}\}/g,o=/\{\{=([\s\S]+?)\}\}/g,i=/\{\{-([\s\S]+?)\}\}/g;this.add=function(n,e,r){var o,i;t[n]=t[n]||{},void 0===r?(r=e,e=void 0,i=t[n]):(t[n][e]=t[n][e]||{},i=t[n][e]);for(o in r)r.hasOwnProperty(o)&&(i[o]=r[o])},this.has=function(e,r){r=r||n;var o=r+"."+e;return t[e]?!0:s(o,t)?!0:!1},this.listLangs=function(){var n=[];for(var e in t)n.push(e);return n},this.getCurrentLang=function(){return n},this.getDico=function(){return t},this.setLang=function(t){return n=t},this.setDefaults=function(n){e=n||{}},this.get=function(f,c,a,p){var l=p||n;void 0===p&&("string"==typeof c?(l=c,c=void 0):"string"==typeof a&&(l=a));var _=s(l+"."+f,t);if(a=a||{},"string"==typeof _||"function"==typeof _){var g,v={evaluate:a.evaluate||r,interpolate:a.interpolate||o,escape:a.escape||i},d={},h=e[n]||e;for(g in h)h.hasOwnProperty(g)&&(d[g]=h[g]);for(g in c)c.hasOwnProperty(g)&&(d[g]=c[g]);return"function"!=typeof _&&"function"==typeof u&&(_=u(_,v)),_(d)}return"object"==typeof _?_:f}};return new f});
{
"name": "i18njs",
"version": "2.0.3",
"version": "2.0.4",
"description": "A simple i18n for Javascript with a templating feature.",

@@ -10,10 +10,13 @@ "main": "i18njs.js",

"build": "npm test",
"pretest": "npm run-script umd && npm run-script uglify",
"pretest": "npm run-script addTemp && npm run-script concat && npm run-script umd && npm run-script uglify",
"test": "mocha",
"posttest": "npm run-script format && npm run-script lint",
"posttest": "npm run-script format && npm run-script lint && npm run-script cleanTemp",
"format": "jscs ./src/i18n.js ./test/i18njs.spec.js",
"lint": "eslint ./src/i18n.js ./test/i18njs.spec.js",
"umd": "umd i18njs ./src/i18n.js i18njs.js",
"changelog": "node ./src/changelog.js",
"bowerSync": "node ./src/bowerSync.js",
"concat": "concat-cli -f ./src/template.js ./src/i18n.js -o ./temp/i18njs.js",
"umd": "umd i18njs ./temp/i18njs.js ./i18njs.js",
"changelog": "node ./bin/changelog.js",
"bowerSync": "node ./bin/bowerSync.js",
"cleanTemp": "node ./bin/cleanTemp.js",
"addTemp": "node ./bin/addTemp.js",
"uglify": "uglifyjs i18njs.js -o i18njs.min.js -c -m"

@@ -37,2 +40,3 @@ },

"devDependencies": {
"concat-cli": "^1.0.1",
"conventional-changelog": "0.2.1",

@@ -39,0 +43,0 @@ "eslint": "^0.24.1",

@@ -1,106 +0,4 @@

/*eslint no-new-func:0*/
'use strict';
/*-------------------------------------------*\
| TEMPLATE SYSTEM
| Based on Underscore's
| template system.
| https://github.com/jashkenas/underscore/blob/master/underscore.js#L1388
\*-------------------------------------------*/
var noMatch = /(.)^/;
var escaperRegEx = /\\|'|\r|\n|\u2028|\u2029/g;
var escapeMap = {
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#x27;',
'`': '&#x60;'
};
var escapes = {
"'": "'",
'\\': '\\',
'\r': 'r',
'\n': 'n',
'\u2028': 'u2028',
'\u2029': 'u2029'
};
var createEscaper = function(map) {
var escaper = function(match) {
return map[match];
};
var source = '(?:' + Object.keys(map).join('|') + ')';
var testRegexp = RegExp(source);
var replaceRegexp = RegExp(source, 'g');
return function(string) {
string = string == null ? '' : '' + string;
return testRegexp.test(string) ?
string.replace(replaceRegexp, escaper) : string;
};
};
var escapeChar = function(match) {
return '\\' + escapes[match];
};
var template = function (text, settings) {
var index = 0;
var source = "__p+='";
var matcher = RegExp([
(settings.escape || noMatch).source,
(settings.interpolate || noMatch).source,
(settings.evaluate || noMatch).source
].join('|') + '|$', 'g');
text.replace(matcher,
function (match, escape, interpolate, evaluate, offset) {
source += text.slice(index, offset)
.replace(escaperRegEx, escapeChar);
index = offset + match.length;
if (escape) {
source += "'+\n((__t=(" +
escape + "))==null?'':_.escape(__t))+\n'";
} else if (interpolate) {
source += "'+\n((__t=(" +
interpolate + "))==null?'':__t)+\n'";
} else if (evaluate) {
source += "';\n" + evaluate + "\n__p+='";
}
return match;
}
);
source += "';\n";
source = 'with(obj||{}){\n' + source + '}\n';
source = "var __t,__p='',__j=Array.prototype.join," +
"print=function(){__p+=__j.call(arguments,'');};\n" +
source + 'return __p;\n';
try {
var render = new Function('obj', '_', source);
} catch (e) {
e.source = source;
throw e;
}
var tmpl = function (data) {
return render.call(this, data, {
escape: createEscaper(escapeMap)
});
};
tmpl.source = 'function(obj){\n' + source + '}';
return tmpl;
};
/*---- END TEMPLATE ----*/
/*globals template*/
var parse = function (key, obj) {
'use strict';
var ar = key.split('.');

@@ -116,2 +14,3 @@

var I18n = function () {
'use strict';
// PRIVATES

@@ -204,3 +103,3 @@ var localLang = 'en';

if (typeof obj === 'string') {
if (typeof obj === 'string' || typeof obj === 'function') {
var i;

@@ -227,5 +126,7 @@ var settings = {

obj = template(obj, settings)(newDatas);
if (typeof obj !== 'function' && typeof template === 'function') {
obj = template(obj, settings);
}
return obj;
return obj(newDatas);
} else if (typeof obj === 'object') {

@@ -232,0 +133,0 @@ return obj;

Sorry, the diff of this file is not supported yet

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