UNPKG

@ngrx/core

Version:

Core operators and utiliies for the ngrx platform

24 lines (23 loc) 855 B
"use strict"; var pluck_1 = require('rxjs/operator/pluck'); var map_1 = require('rxjs/operator/map'); var distinctUntilChanged_1 = require('rxjs/operator/distinctUntilChanged'); function select(pathOrMapFn) { var paths = []; for (var _i = 1; _i < arguments.length; _i++) { paths[_i - 1] = arguments[_i]; } var mapped$; if (typeof pathOrMapFn === 'string') { mapped$ = pluck_1.pluck.call.apply(pluck_1.pluck, [this, pathOrMapFn].concat(paths)); } else if (typeof pathOrMapFn === 'function') { mapped$ = map_1.map.call(this, pathOrMapFn); } else { throw new TypeError(("Unexpected type " + typeof pathOrMapFn + " in select operator,") + " expected 'string' or 'function'"); } return distinctUntilChanged_1.distinctUntilChanged.call(mapped$); } exports.select = select;