当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript List.merge方法代码示例

本文整理汇总了TypeScript中Immutable.List.merge方法的典型用法代码示例。如果您正苦于以下问题:TypeScript List.merge方法的具体用法?TypeScript List.merge怎么用?TypeScript List.merge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Immutable.List的用法示例。


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

示例1: addNoRetweetUserIds

    addNoRetweetUserIds(ids: number[]) {
        const predicate = (i: Item) => {
            if (i instanceof Tweet) {
                return !i.isRetweet() || ids.indexOf(i.retweeted_status.user.id) === -1;
            } else {
                return true;
            }
        };

        const next_home = this.home.filter(predicate).toList();
        const next_mention = this.mention.filter(predicate).toList();
        const next_no_retweet_ids = this.no_retweet_ids.merge(ids);

        // XXX:
        // Next focus index calculation is too complicated.  I skipped it.

        return new TimelineState(
            this.kind,
            next_home,
            next_mention,
            this.user,
            this.notified,
            this.rejected_ids,
            next_no_retweet_ids,
            this.focus_index
        );
    }
开发者ID:DevenLu,项目名称:YourFukurou,代码行数:27,代码来源:timeline.ts

示例2: addRejectedIds

    addRejectedIds(ids: number[]) {
        const will_added = ids.filter(id => !this.rejected_ids.contains(id));
        if (will_added.length === 0) {
            return this;
        }

        const predicate = (i: Item) => {
            if (i instanceof Tweet) {
                const id = i.getMainStatus().user.id;
                return will_added.indexOf(id) === -1;
            }
            return true;
        };

        const next_home = this.home.filter(predicate).toList();
        const next_mention = this.mention.filter(predicate).toList();
        const home_updated = next_home.size !== this.home.size;
        const mention_updated = next_mention.size !== this.mention.size;
        const next_rejected_ids = this.rejected_ids.merge(will_added);

        // XXX:
        // Next focus index calculation is too complicated.  I skipped it.

        return new TimelineState(
            this.kind,
            home_updated ? next_home : this.home,
            mention_updated ? next_mention : this.mention,
            this.user,
            this.notified,
            next_rejected_ids,
            this.no_retweet_ids,
            this.focus_index
        );
    }
开发者ID:DevenLu,项目名称:YourFukurou,代码行数:34,代码来源:timeline.ts


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