Skip to content

Commit 6b0ddb2

Browse files
committed
refactor($state): use map function in get()
1 parent 80766cd commit 6b0ddb2

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

src/state.js

+3-7
Original file line numberDiff line numberDiff line change
@@ -1129,16 +1129,12 @@ function $StateProvider( $urlRouterProvider, $urlMatcherFactory) {
11291129
* @description
11301130
* Returns the state configuration object for any specific state or all states.
11311131
*
1132-
* @param {string|object=} stateOrName (absolute or relative) If provided, will only get the config for
1132+
* @param {string|Sbject=} stateOrName (absolute or relative) If provided, will only get the config for
11331133
* the requested state. If not provided, returns an array of ALL state configs.
1134-
* @returns {object|array} State configuration object or array of all objects.
1134+
* @returns {Object|Array} State configuration object or array of all objects.
11351135
*/
11361136
$state.get = function (stateOrName, context) {
1137-
if (arguments.length === 0) {
1138-
var list = [];
1139-
forEach(states, function(state) { list.push(state.self); });
1140-
return list;
1141-
}
1137+
if (arguments.length === 0) return objectKeys(states).map(function(name) { return states[name].self; });
11421138
var state = findState(stateOrName, context);
11431139
return (state && state.self) ? state.self : null;
11441140
};

0 commit comments

Comments
 (0)