Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 7640589

Browse files
dotkugkalpak
authored andcommitted
docs(identity): add example
Closes #14528
1 parent bb73070 commit 7640589

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/Angular.js

+15-5
Original file line numberDiff line numberDiff line change
@@ -447,12 +447,22 @@ noop.$inject = [];
447447
* functional style.
448448
*
449449
```js
450-
function transformer(transformationFn, value) {
451-
return (transformationFn || angular.identity)(value);
452-
};
450+
function transformer(transformationFn, value) {
451+
return (transformationFn || angular.identity)(value);
452+
};
453+
454+
// E.g.
455+
function getResult(fn, input) {
456+
return (fn || angular.identity)(input);
457+
};
458+
459+
getResult(function(n) { return n * 2; }, 21); // returns 42
460+
getResult(null, 21); // returns 21
461+
getResult(undefined, 21); // returns 21
453462
```
454-
* @param {*} value to be returned.
455-
* @returns {*} the value passed in.
463+
*
464+
* @param {*} value to be returned.
465+
* @returns {*} the value passed in.
456466
*/
457467
function identity($) {return $;}
458468
identity.$inject = [];

0 commit comments

Comments
 (0)