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

jslt

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jslt - npm Package Compare versions

Comparing version 0.2.4 to 0.2.5

25

jslt.js

@@ -20,2 +20,13 @@

state = { catchCount : 0, props };
if (props.locales) {
state.locales = [];
let locales = props.locales instanceof Array ? props.locales : [ props.locales ];
locales.forEach(locale => {
let parts = locale.split("-");
for (var i = parts.length; i > 0; --i)
state.locales.push(parts.slice(0, i).join("-"));
});
}
var res = compileTemplate(data, template);

@@ -241,2 +252,10 @@ var lastState = state;

$localize(input, args, global) {
if (!args) return error("[args]", "Missing arguments");
var locales = state.locales || [ "en-US", "en" ];
for (var i = 0; i < locales.length; ++i)
if (args.hasOwnProperty(locales[i]))
return compileTemplate(global, args[locales[i]]);
},
$join(input, args, global) {

@@ -251,7 +270,7 @@ return args.map(item => compileTemplate(global, item)).join("");

$formatDate(input, args, global) {
return (new Date(input)).toLocaleString(compileTemplate(global, args && args.locales), compileTemplate(global, args && args.options));
return (new Date(input)).toLocaleString(compileTemplate(global, (args && args.locales) || state.locales), compileTemplate(global, args && args.options));
},
$formatNumber(input, args, global) {
return Number(input).toLocaleString(compileTemplate(global, args && args.locales), compileTemplate(global, args && args.options));
return Number(input).toLocaleString(compileTemplate(global, (args && args.locales) || state.locales), compileTemplate(global, args && args.options));
},

@@ -308,3 +327,3 @@

if (!keywordFunc) return error(`[${keyword}]`, "Unknown keyword");
if (!keywordFunc(input, args[keyword])) return error("[input]", keyword);
if (!keywordFunc(input, args[keyword])) return error("[input]", keyword);
}

@@ -311,0 +330,0 @@ return input;

2

package.json
{
"name": "jslt",
"version": "0.2.4",
"version": "0.2.5",
"description": "JSON transformer",

@@ -5,0 +5,0 @@ "main": "jslt.js",

@@ -211,2 +211,15 @@

transformProps = { locales : "ko-KR" };
test("$localize - exact", { label : { $localize : { "ko-KR" : "Korean KR" } } }, { label : "Korean KR" });
test("$localize - lang", { label : { $localize : { "ko" : "Korean" } } }, { label : "Korean" });
test("$localize - none", { label : { $localize : { "en" : "English" } } }, {});
//test("$formatDate - locales", Date.UTC(2017, 4, 20, 5, 0, 0), { $formatDate: {} }, "2017-5-20 08:00:00");
transformProps = { locales : [ "ko-KR", "en-US" ] };
test("$localize - multi - exact", { label : { $localize : { "en-US" : "English US", "ko-KR" : "Korean KR" } } }, { label : "Korean KR" });
test("$localize - multi - lang", { label : { $localize : { "en-US" : "English US", "ko" : "Korean" } } }, { label : "Korean" });
test("$localize - multi - fallback - exact", { label : { $localize : { "en-US" : "English US" } } }, { label : "English US" });
test("$localize - multi - fallback - lang", { label : { $localize : { "en" : "English" } } }, { label : "English" });
//test("$formatDate - multi - locales", Date.UTC(2017, 4, 20, 5, 0, 0), { $formatDate: {} }, "2017-5-20 08:00:00");
console.log(`\nPassed: ${passed}, Failed: ${failed}`);
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