{"record":{"id":"d606074f86e8488a","repo":"bettercap/bettercap","slug":"argument-is-not-a-function-are-you-looking-for-m","errorCode":null,"errorMessage":"argument is not a function. Are you looking for `mapTo()`?","messagePattern":"argument is not a function\\. Are you looking for `mapTo\\(\\)`\\?","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/ui/ui/vendor.js","lineNumber":101948,"sourceCode":"/*!***********************************************************!*\\\n  !*** ./node_modules/rxjs/_esm5/internal/operators/map.js ***!\n  \\***********************************************************/\n/*! exports provided: map, MapOperator */\n/***/ (function(module, __webpack_exports__, __webpack_require__) {\n\n\"use strict\";\n__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"map\", function() { return map; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"MapOperator\", function() { return MapOperator; });\n/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ \"./node_modules/tslib/tslib.es6.js\");\n/* harmony import */ var _Subscriber__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Subscriber */ \"./node_modules/rxjs/_esm5/internal/Subscriber.js\");\n/** PURE_IMPORTS_START tslib,_Subscriber PURE_IMPORTS_END */\n\n\nfunction map(project, thisArg) {\n    return function mapOperation(source) {\n        if (typeof project !== 'function') {\n            throw new TypeError('argument is not a function. Are you looking for `mapTo()`?');\n        }\n        return source.lift(new MapOperator(project, thisArg));\n    };\n}\nvar MapOperator = /*@__PURE__*/ (function () {\n    function MapOperator(project, thisArg) {\n        this.project = project;\n        this.thisArg = thisArg;\n    }\n    MapOperator.prototype.call = function (subscriber, source) {\n        return source.subscribe(new MapSubscriber(subscriber, this.project, this.thisArg));\n    };\n    return MapOperator;\n}());\n\nvar MapSubscriber = /*@__PURE__*/ (function (_super) {\n    tslib__WEBPACK_IMPORTED_MODULE_0__[\"__extends\"](MapSubscriber, _super);\n    function MapSubscriber(destination, project, thisArg) {","sourceCodeStart":101930,"sourceCodeEnd":101966,"githubUrl":"https://github.com/bettercap/bettercap/blob/8eca2820f3c41d2004434ed5a291d87462caeeb7/modules/ui/ui/vendor.js#L101930-L101966","documentation":"The map() operator validates that its projector is a function, throwing this TypeError with a hint pointing at mapTo(). It exists because a common mistake is passing a constant value to map() expecting a transformation to that constant.","triggerScenarios":"source$.pipe(map(42)), map(someValue) where someValue is data instead of a function, or map(obj.prop) evaluating to a non-function at pipe time.","commonSituations":"Confusing map with mapTo when projecting to constants; passing an already-computed value from an expression; refactors where a projector function was replaced by its result; mixing Array.prototype.map semantics with RxJS.","solutions":["Wrap constants with mapTo: source$.pipe(mapTo(42)) or map(() => 42)","Provide a real projector function: map(x => x.name)","Check the value passed to map with typeof before piping","If you meant to transform each value, keep the arrow function inside map()"],"exampleFix":"// before\n clicks$.pipe(map('clicked'));\n// after\n clicks$.pipe(mapTo('clicked')); // or map(() => 'clicked')","handlingStrategy":"validation","validationCode":"if (typeof project !== 'function') throw new TypeError('map() requires a projector function; use mapTo() for constants');","typeGuard":"function isProjector<T, R>(f: unknown): f is (value: T, index: number) => R { return typeof f === 'function'; }","tryCatchPattern":"try { src$.pipe(map(p)).subscribe(h); } catch (e) { if (e.message.includes('mapTo()')) { console.error('map() got a non-function; use mapTo for constants'); } else throw e; }","preventionTips":["Use mapTo(value) when emitting a constant","Keep projector logic inside arrow functions, never precomputed results","Enable TypeScript so non-function arguments are flagged"],"tags":["rxjs","map","mapto","type-error"],"backgroundTag":"map-projector-not-a-function","analyzedSha":"8eca2820f3c41d2004434ed5a291d87462caeeb7","analyzedAt":"2026-09-02T12:49:00.712Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T16:17:10.729Z"}