Skip to content

Instantly share code, notes, and snippets.

@sufianrhazi
Created November 3, 2016 18:42
Show Gist options
  • Save sufianrhazi/89ae263bbfb2c7da52a5955d6d804a3d to your computer and use it in GitHub Desktop.
Save sufianrhazi/89ae263bbfb2c7da52a5955d6d804a3d to your computer and use it in GitHub Desktop.
// Original
i18n = Array.from(allDeps).reduce(function(p,c){
if (c.slice(0, 'template!'.length) === 'template!') {
return true;
}
return p;
}, false)
// Array#reduce and String#startsWith
i18n = Array.from(allDeps).reduce(function(p,c){
if (c.startsWith('template!')) {
return true;
}
return p;
}, false)
// Array#every
i18n = !Array.from(allDeps).every(function (dep) {
return !dep.startsWith('template!');
}); // double negative, which is awkward
// Array#some
i18n = Array.from(allDeps).some(function (dep) {
return dep.startsWith('template!');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment