• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript map.map函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中rxjs/operators/map.map函数的典型用法代码示例。如果您正苦于以下问题:TypeScript map函数的具体用法?TypeScript map怎么用?TypeScript map使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了map函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: reloadStyleImages

    function reloadStyleImages(style, styleNames: string[], path, expando): Observable<any> {
        return from(styleNames).pipe(
            filter(styleName => typeof style[styleName] === 'string')
            , map((styleName: string) => {
                let pathName;
                const value = style[styleName];
                const newValue = value.replace(new RegExp(`\\burl\\s*\\(([^)]*)\\)`), (match, src) => {
                    let _src = src;
                    if (src[0] === '"' && src[src.length-1] === '"') {
                        _src = src.slice(1, -1);
                    }
                    pathName = getLocation(_src).pathname;
                    if (pathsMatch(path, pathFromUrl(_src))) {
                        return `url(${generateCacheBustUrl(_src, expando)})`;
                    } else {
                        return match;
                    }
                });

                return [
                    style,
                    styleName,
                    value,
                    newValue,
                    pathName
                ];
            })
            , filter(([style, styleName, value, newValue]) => newValue !== value)
            , map(([style, styleName, value, newValue, pathName]) => styleSet({style, styleName, value, newValue, pathName}))
        )
    }
开发者ID:BrowserSync,项目名称:browser-sync,代码行数:31,代码来源:Reloader.ts


示例2: run

function run() {
  if (!command) {
    console.log('Welcome to frint-cli!');
    console.log('\n');
    console.log('These commands are currently available:\n');

    return app.getApps$()
      .pipe(
        map(registeredApps => (
          registeredApps
            .map(registeredApp => registeredApp.name)
            .sort()
        )),
        take(1),
        map(registeredAppNames => (
          registeredAppNames
            .map(appName => `  - ${appName}`)
            .join('\n')
        )),
        tap(names => console.log(names)),
        tap(() => console.log('\n')),
        tap(() => console.log('Type `frint help <commandName>` to learn more.'))
      )
      .subscribe();
  }

  const commandApp = app.getAppInstance(command);

  if (!commandApp) {
    return console.log('Command not available.');
  }

  return commandApp.get<FrintCliProvider>('execute')();
}
开发者ID:Travix-International,项目名称:frint,代码行数:34,代码来源:frint.ts


示例3: switchMap

        switchMap(scroll => {
            if (!scroll) return empty();
            return fromEvent(document, "scroll", true).pipe(
                map((e: Event) => e.target),
                withLatestFrom(canSync$, elemMap$),
                filter(([, canSync]) => Boolean(canSync)),
                map(([target, canSync, elemMap]: [any, boolean, any[]]) => {
                    if (target === document) {
                        return ScrollEvent.outgoing(
                            getScrollPosition(window, document),
                            "document",
                            0
                        );
                    }

                    const elems = document.getElementsByTagName(target.tagName);
                    const index = Array.prototype.indexOf.call(
                        elems || [],
                        target
                    );

                    return ScrollEvent.outgoing(
                        getScrollPositionForElement(target),
                        target.tagName,
                        index,
                        elemMap.indexOf(target)
                    );
                })
            );
        })
开发者ID:BrowserSync,项目名称:browser-sync,代码行数:30,代码来源:scroll.listener.ts


示例4: of

(() => {
    of(1, 2, 3, 4)
        .pipe(filter(n => n % 2 == 0), map(n => n * n))
        .subscribe(n => console.log(n));

    const removeEven = () => (source: Observable<number>) => source.pipe(filter(n => n % 2 !== 0));

    of(1, 2, 3, 4)
        .pipe(removeEven(), map(n => n * n))
        .subscribe(n => console.log(n));
}); //();
开发者ID:,项目名称:,代码行数:11,代码来源:


示例5: ngOnInit

  ngOnInit() {
    // Capture the session ID if available
    this.sessionId = this.route
      .queryParamMap
      .pipe(
        map(params => params.get('sessionId') || 'None')
      );

    // Capture the fragment if available
    this.token = this.route
      .fragment
      .pipe(
        map(fragment => fragment || 'None')
      );
  }
开发者ID:ivanina-ilya,项目名称:An2-4-Routing,代码行数:15,代码来源:admin-dashboard.component.ts


示例6: login

  login(params: any): Observable<any> {
    var __headers = new HttpHeaders({
      'Content-Type': 'application/json'
    });
    var __body = {
      EmailAddress: params.username,
      Password:(params.password),

    };
    let req = new HttpRequest < any > (
      'POST',
      this.rootUrl + `/account/token`,
      __body, {
        headers: __headers

      });
      
    return this.http.request < any > (req).pipe(
      filter(_r => _r instanceof HttpResponse),
      map(_r => {
        let _resp = _r as HttpResponse < any > ;
        let _body = _resp.body;
   
        if (_resp.ok) {
          localStorage.clear();
          Object.keys(_body).map(key => localStorage.setItem(key, _body[key]));
        } else {
          localStorage.clear();
        }
        return _resp.clone({
          body: _body
        }) as HttpResponse < any > ;
      })
    );
  }
开发者ID:sgbangale,项目名称:AngularApp,代码行数:35,代码来源:account.service.ts


示例7: request

    request(params: any,request_type:string): Observable < any > {
        var __headers = new HttpHeaders({
            'Content-Type': 'application/json'
        });
        var __body = {
            "request_data": params
        };
       
        let req = new HttpRequest < any > (
            'POST',
            this.rootUrl + `/request?request_type=`+request_type,
            __body, {
                headers: __headers
            });

        return this.http.request < any > (req).pipe(
            filter(_r => _r instanceof HttpResponse),
            map(_r => {
                let _resp = _r as HttpResponse < any > ;
                let _body = _resp.body;               
                return _resp.clone({
                    body: _body
                }) as HttpResponse < any > ;
            })
        );
    }
开发者ID:sgbangale,项目名称:AngularApp,代码行数:26,代码来源:request.service.ts


示例8: fleshBibUsers

    // Flesh the creator and editor fields.
    // Handling this separately lets us pull from the cache and
    // avoids the requirement that the main bib query use a staff
    // (VIEW_USER) auth token.
    fleshBibUsers(records: IdlObject[]): Promise<void> {

        const search = [];

        records.forEach(rec => {
            ['creator', 'editor'].forEach(field => {
                const id = rec[field]();
                if (Number.isInteger(id)) {
                    if (this.userCache[id]) {
                        rec[field](this.userCache[id]);
                    } else if (!search.includes(id)) {
                        search.push(id);
                    }
                }
            });
        });

        if (search.length === 0) {
            return Promise.resolve();
        }

        return this.pcrud.search('au', {id: search})
        .pipe(map(user => {
            this.userCache[user.id()] = user;
            records.forEach(rec => {
                if (user.id() === rec.creator()) {
                    rec.creator(user);
                }
                if (user.id() === rec.editor()) {
                    rec.editor(user);
                }
            });
        })).toPromise();
    }
开发者ID:jamesrf,项目名称:Evergreen,代码行数:38,代码来源:bib-record.service.ts


示例9: getRole

 getRole(): Observable<string> {
   return this.authService.onTokenChange()
     .pipe(
       map((token: NbAuthJWTToken) => {
         return token.isValid() ? token.getPayload()['r'] : 'guest';
       }),
     );
 }
开发者ID:Sistets,项目名称:AppDoctors,代码行数:8,代码来源:role.provider.ts


示例10: map

const epic9_1: Epic<FluxStandardAction, State, Dependencies, Epic9_Output> = (action$, store, dependencies) =>
  action$.pipe(
    ofType<FluxStandardAction, Epic9_Input>('NINTH'),
    map(({ type, payload }) => ({
      type: 'ninth' as 'ninth',
      payload: dependencies.func("ninth-" + payload),
    }))
  );
开发者ID:swathysoman,项目名称:redux-observable,代码行数:8,代码来源:typings.ts



注:本文中的rxjs/operators/map.map函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript mergeMap.mergeMap函数代码示例发布时间:2022-05-25
下一篇:
TypeScript ignoreElements.ignoreElements函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap