work.suroh.tk/node_modules/rxjs/operators/pluck.js.map

1 line
2.8 KiB
Plaintext

{"version":3,"file":"pluck.js","sourceRoot":"","sources":["../../src/operators/pluck.ts"],"names":[],"mappings":";AACA,oBAAoB,OAAO,CAAC,CAAA;AAG5B;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH;IAA4B,oBAAuB;SAAvB,WAAuB,CAAvB,sBAAuB,CAAvB,IAAuB;QAAvB,mCAAuB;;IACjD,IAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IACjC,EAAE,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;IACzD,CAAC;IACD,MAAM,CAAC,UAAC,MAAqB,IAAK,OAAA,SAAG,CAAC,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,MAAa,CAAC,EAA/C,CAA+C,CAAC;AACpF,CAAC;AANe,aAAK,QAMpB,CAAA;AAED,iBAAiB,KAAe,EAAE,MAAc;IAC9C,IAAM,MAAM,GAAG,UAAC,CAAS;QACvB,IAAI,WAAW,GAAG,CAAC,CAAC;QACpB,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAChC,IAAM,CAAC,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;YAChC,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,WAAW,CAAC,CAAC,CAAC;gBAC7B,WAAW,GAAG,CAAC,CAAC;YAClB,CAAC;YAAC,IAAI,CAAC,CAAC;gBACN,MAAM,CAAC,SAAS,CAAC;YACnB,CAAC;QACH,CAAC;QACD,MAAM,CAAC,WAAW,CAAC;IACrB,CAAC,CAAC;IAEF,MAAM,CAAC,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { Observable } from '../Observable';\nimport { map } from './map';\nimport { OperatorFunction } from '../interfaces';\n\n/**\n * Maps each source value (an object) to its specified nested property.\n *\n * <span class=\"informal\">Like {@link map}, but meant only for picking one of\n * the nested properties of every emitted object.</span>\n *\n * <img src=\"./img/pluck.png\" width=\"100%\">\n *\n * Given a list of strings describing a path to an object property, retrieves\n * the value of a specified nested property from all values in the source\n * Observable. If a property can't be resolved, it will return `undefined` for\n * that value.\n *\n * @example <caption>Map every click to the tagName of the clicked target element</caption>\n * var clicks = Rx.Observable.fromEvent(document, 'click');\n * var tagNames = clicks.pluck('target', 'tagName');\n * tagNames.subscribe(x => console.log(x));\n *\n * @see {@link map}\n *\n * @param {...string} properties The nested properties to pluck from each source\n * value (an object).\n * @return {Observable} A new Observable of property values from the source values.\n * @method pluck\n * @owner Observable\n */\nexport function pluck<T, R>(...properties: string[]): OperatorFunction<T, R> {\n const length = properties.length;\n if (length === 0) {\n throw new Error('list of properties cannot be empty.');\n }\n return (source: Observable<T>) => map(plucker(properties, length))(source as any);\n}\n\nfunction plucker(props: string[], length: number): (x: string) => any {\n const mapper = (x: string) => {\n let currentProp = x;\n for (let i = 0; i < length; i++) {\n const p = currentProp[props[i]];\n if (typeof p !== 'undefined') {\n currentProp = p;\n } else {\n return undefined;\n }\n }\n return currentProp;\n };\n\n return mapper;\n}\n"]}