Created
November 3, 2016 18:42
-
-
Save sufianrhazi/89ae263bbfb2c7da52a5955d6d804a3d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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