當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript map.map函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。