@coorpacademy/translate
Advanced tools
Comparing version 3.0.0-beta.3-alpha.eb88ee6c to 3.0.1
import get from 'lodash/fp/get'; | ||
import has from 'lodash/fp/has'; | ||
import trim from 'lodash/fp/trim'; | ||
import replace from 'lodash/fp/replace'; | ||
@@ -9,8 +10,8 @@ var interpolation = /\{\{([\s\S]+?)\}\}/g; | ||
return function (key, data) { | ||
var template = locales[key] || key; | ||
var template = locales[key] || key || ''; | ||
return template.replace(interpolation, function (token, value) { | ||
return replace(interpolation, function (token, value) { | ||
var _value = trim(value); | ||
return has(_value, data) ? get(_value, data) : token; | ||
}); | ||
}, template); | ||
}; | ||
@@ -17,0 +18,0 @@ }; |
@@ -17,2 +17,6 @@ 'use strict'; | ||
var _replace = require('lodash/fp/replace'); | ||
var _replace2 = _interopRequireDefault(_replace); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -24,8 +28,8 @@ | ||
return function (key, data) { | ||
var template = locales[key] || key; | ||
var template = locales[key] || key || ''; | ||
return template.replace(interpolation, function (token, value) { | ||
return (0, _replace2.default)(interpolation, function (token, value) { | ||
var _value = (0, _trim2.default)(value); | ||
return (0, _has2.default)(_value, data) ? (0, _get2.default)(_value, data) : token; | ||
}); | ||
}, template); | ||
}; | ||
@@ -32,0 +36,0 @@ }; |
{ | ||
"name": "@coorpacademy/translate", | ||
"version": "3.0.0-beta.3-alpha.eb88ee6c", | ||
"version": "3.0.1", | ||
"description": "", | ||
"main": "lib/translate.js", | ||
"module": "es/translate.js", | ||
"files": [ | ||
"lib", | ||
"es", | ||
"README.md" | ||
], | ||
"scripts": { | ||
@@ -8,0 +13,0 @@ "build": "npm run build:commonjs && npm run build:es", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
1
5999
5
37