Last change
on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
902 bytes
|
Line | |
---|
1 | /** PURE_IMPORTS_START _map PURE_IMPORTS_END */
|
---|
2 | import { map } from './map';
|
---|
3 | export function pluck() {
|
---|
4 | var properties = [];
|
---|
5 | for (var _i = 0; _i < arguments.length; _i++) {
|
---|
6 | properties[_i] = arguments[_i];
|
---|
7 | }
|
---|
8 | var length = properties.length;
|
---|
9 | if (length === 0) {
|
---|
10 | throw new Error('list of properties cannot be empty.');
|
---|
11 | }
|
---|
12 | return function (source) { return map(plucker(properties, length))(source); };
|
---|
13 | }
|
---|
14 | function plucker(props, length) {
|
---|
15 | var mapper = function (x) {
|
---|
16 | var currentProp = x;
|
---|
17 | for (var i = 0; i < length; i++) {
|
---|
18 | var p = currentProp != null ? currentProp[props[i]] : undefined;
|
---|
19 | if (p !== void 0) {
|
---|
20 | currentProp = p;
|
---|
21 | }
|
---|
22 | else {
|
---|
23 | return undefined;
|
---|
24 | }
|
---|
25 | }
|
---|
26 | return currentProp;
|
---|
27 | };
|
---|
28 | return mapper;
|
---|
29 | }
|
---|
30 | //# sourceMappingURL=pluck.js.map
|
---|
Note:
See
TracBrowser
for help on using the repository browser.