You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Aug 19, 2020. It is now read-only.
Just looked at nano.js and you could easily make it several characters. It is interesting that you spend time making should you do not output null or undefined, but don't check that undefined[keys[]] or null[keys[]] is not protected, you could put it in the while(i < l && ...) adds code though.
function nano(template, data) {
return template.replace(/{([\w.]*)}/g, function(str, key) {
var keys = key.split("."), v = data[keys.shift()], i = 0, l = keys.length;
while(i < l) v = v[keys[i++]];
//simple while, hoisted variables up to avoid extra 'var', increment on use
return (typeof v == "undefined" || v == null) ? '' : v;
//change double negative save two chars.
});
}
Just sharing what I happen to see, really not any issue and I can close out either way.
The text was updated successfully, but these errors were encountered:
Just looked at nano.js and you could easily make it several characters. It is interesting that you spend time making should you do not output null or undefined, but don't check that undefined[keys[]] or null[keys[]] is not protected, you could put it in the while(i < l && ...) adds code though.
function nano(template, data) {
return template.replace(/{([\w.]*)}/g, function(str, key) {
var keys = key.split("."), v = data[keys.shift()], i = 0, l = keys.length;
while(i < l) v = v[keys[i++]];
//simple while, hoisted variables up to avoid extra 'var', increment on use
return (typeof v == "undefined" || v == null) ? '' : v;
//change double negative save two chars.
});
}
Just sharing what I happen to see, really not any issue and I can close out either way.
The text was updated successfully, but these errors were encountered: