According to the documentation
A function that returns its first argument. This function is useful when writing code in the functional style.
I
Correct me if I'm wrong, but my understanding is that this
function transformer(transformationFn, value) {
return (transformationFn || angular.identity)(value);
};
could be "un-refactored" to this
function transformer(transformationFn, value) {
if (transformationFn) {
return transformationFn(value);
} else {
return angular.identity(value);
}
};
which would be functionally equivalent to this identity
-less version:
function transformer(transformationFn, value) {
if (transformationFn) {
return transformationFn(value);
} else {
return value;
}
};
So I guess the use case would be when you want to apply a certain transformation to a value when you're supplied with something that may or may not actually exist.
I wanted to better explain the identity
function (as I understand it), although as I review my answer I don't think I really answered your question. Leaving my answer here anyway in case it's helpful.