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


TypeScript lodash.difference函数代码示例

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


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

示例1: get_tags_for_event

        get_tags_for_event(ev, transaction).then((tags: EventTagMessage[]) => {
            var cur_tag_ids = tags.filter(is_set).map(tag => tag.tag_id),
                msg_tag_ids = data.tags.filter(is_set).map(tag => tag.id),
                delete_ids = difference<string>(cur_tag_ids, msg_tag_ids),
                create_ids = difference<string>(msg_tag_ids, cur_tag_ids);

            // delete remove tags
            Promise.all(delete_ids.map(id => {
                return EventTag.destroy({
                    transaction,
                    where: {
                        event_id: ev.id,
                        tag_id: id,
                    },
                });
            })).then(() => {
                // upsert the rest
                Promise.all(create_ids.map(id => {
                    return EventTag.create(build_event_tag(ev, id, user), {
                        transaction
                    }).then(() => id);
                }))
                    .then(tags => resolve(tags))
                    .catch(reject);
            }).catch(reject);
        });
开发者ID:consumr-project,项目名称:cp,代码行数:26,代码来源:event.ts

示例2: get_companies_for_event

        get_companies_for_event(ev, transaction).then((companies: CompanyEventMessage[]) => {
            var cur_company_ids = companies.filter(is_set).map(company => company.company_id),
                msg_company_ids = data.companies.filter(is_set).map(company => company.id),
                delete_ids = difference<string>(cur_company_ids, msg_company_ids),
                create_ids = difference<string>(msg_company_ids, cur_company_ids);

            // delete remove companies
            Promise.all(delete_ids.map(id => {
                return CompanyEvent.destroy({
                    transaction,
                    where: {
                        event_id: ev.id,
                        company_id: id,
                    },
                });
            })).then(() => {
                // upsert the rest
                Promise.all(create_ids.map(id => {
                    return CompanyEvent.create(build_event_company(ev, id, user), {
                        transaction
                    }).then(() => id);
                }))
                    .then(companies => resolve(companies))
                    .catch(reject);
            }).catch(reject);
        });
开发者ID:consumr-project,项目名称:cp,代码行数:26,代码来源:event.ts

示例3: filterPicksFromPickLists

function filterPicksFromPickLists() {
  const pickedGids = _picks.map(p => p.golfer);
  if (_pickList !== _pendingPickList) {
    _pickList = difference(_pickList, pickedGids);
    _pendingPickList = difference(_pendingPickList, pickedGids);
  } else {
    _pickList = difference(_pickList, pickedGids);
    _pendingPickList = _pickList;
  }
}
开发者ID:odetown,项目名称:golfdraft,代码行数:10,代码来源:DraftStore.ts

示例4: stethoscope

  // TODO: Refactor out logging logic into seperate file
  async function stethoscope() {
    try {
      const currentTab = await getCurrentTab();
      const currentTabArray = (await isTabActive(currentTab))
        ? [currentTab]
        : [];
      const audibleTabs = await browser.tabs.query({ audible: true });
      const tabs = filter(
        unionBy(currentTabArray, audibleTabs, 'url'),
        tab => !tab.incognito
      );

      const timeSinceLastPoll = pollTimer();
      if (timeSinceLastPoll > 70) {
        // If significantly more than 60s, reset timers.
        // This is usually indicative of computer being suspended.
        // See: https://github.com/SuperuserLabs/thankful/issues/61
        console.log('suspend detected, resetting timers');
        each(tabTimers, tabTimer => tabTimer());
      }

      const currentUrls = tabs.map(tab => canonicalizeUrl(tab.url));
      const goneUrls = difference(Object.keys(tabTimers), currentUrls);
      const stillUrls = intersection(Object.keys(tabTimers), currentUrls);
      const newUrls = difference(currentUrls, Object.keys(tabTimers));

      goneUrls.forEach(url => {
        const duration = tabTimers[url]();
        const title = tabTitles[url];
        delete tabTimers[url];
        delete tabTitles[url];
        db.logActivity(url, duration, { title: title });
      });
      stillUrls.forEach(url => {
        const duration = tabTimers[url]();
        let title = find(tabs, tab => canonicalizeUrl(tab.url) === url).title;
        tabTitles[url] = title;
        db.logActivity(url, duration, { title: title });
      });
      newUrls.forEach(url => {
        tabTimers[url] = valueConstantTicker();
        tabTimers[url]();
        tabTitles[url] = find(
          tabs,
          tab => canonicalizeUrl(tab.url) === url
        ).title;
      });
      await rescheduleAlarm();
    } catch (error) {
      console.log(`Stethoscope error: ${error}`);
    }
  }
开发者ID:ActivityWatch,项目名称:thankful,代码行数:53,代码来源:background.ts

示例5: function

 ctrl.cleanupUnsavedContent = function() {
   const removeIds = difference(
     keys(ctrl.unsavedContent),
     ctrl.discussion.replies.map(reply => reply.id),
   );
   removeIds.forEach(id => delete ctrl.unsavedContent[id]);
 };
开发者ID:paperhive,项目名称:paperhive-frontend,代码行数:7,代码来源:margin-discussion.ts

示例6: groupTavoitteet

 function groupTavoitteet(tavoitteet, tavoiteMap) {
     var groups: any = {
         grouped: {},
         ungrouped: {}
     };
     var processed = [];
     _.each(tavoitteet, function(tavoite) {
         if (tavoite.pakollinen) {
             groups.grouped[tavoite.id] = [tavoite];
             processed.push(tavoite);
         }
     });
     _.each(tavoitteet, function(tavoite) {
         if (!tavoite.pakollinen && tavoite._esitieto && _.has(groups.grouped, tavoite._esitieto)) {
             groups.grouped[tavoite._esitieto].push(tavoite);
             processed.push(tavoite);
         }
     });
     groups.ungrouped = _.difference(tavoitteet, processed);
     groups.$size = _.size(groups.grouped);
     groups.$options = _.map(_.keys(groups.grouped), function(key) {
         return { label: tavoiteMap && tavoiteMap[key] ? tavoiteMap[key].nimi : "", value: key };
     });
     return groups;
 }
开发者ID:Opetushallitus,项目名称:eperusteet,代码行数:25,代码来源:tutke2osa.ts

示例7: get_sources_for_event

        get_sources_for_event(ev, transaction).then((sources: EventSourceMessage[]) => {
            var cur_source_ids = sources.filter(is_set).map(source => source.id),
                msg_source_ids = data.sources.filter(is_set).map(source => source.id),
                delete_ids = difference<string>(cur_source_ids, msg_source_ids);

            // delete remove sources
            Promise.all(delete_ids.map(id => {
                return EventSource.destroy({
                    transaction,
                    where: where(id),
                });
            })).then(() => {
                // upsert the rest
                Promise.all(data.sources.map(source => {
                    var source_data = build_event_source(ev, source, user);
                    return !source.id ?
                        EventSource.create(source_data, {
                            transaction
                        }).then(() => source_data) :
                        EventSource.update(source_data, {
                            transaction,
                            where: where(source_data.id)
                        }).then(() => source_data);
                }))
                    .then(sources => resolve(sources))
                    .catch(reject);
            }).catch(reject);
        });
开发者ID:consumr-project,项目名称:cp,代码行数:28,代码来源:event.ts

示例8: callback

            this.db.getMigrationHistory(null, (err, rows) => {
                if (err) {
                    return callback(err);
                }

                callback(null, _.difference(files, _.map(rows, 'version')));
            });
开发者ID:vruden,项目名称:node-migrate,代码行数:7,代码来源:migrate.ts

示例9: runBasicServer

runBasicServer(port, async () => {
  const browser = await puppeteer.launch();

  do {
    const page = await browser.newPage();

    const url = pendingPages[0];
    await page.goto(`${host}${url}?prerendering=${true.toString()}`);

    pages[url] = await page.evaluate(() => document.documentElement.outerHTML);
    console.log(`${url} rendered.`);

    const allLinksOnPage = await page.evaluate(() =>
      Array.from(document.querySelectorAll<HTMLAnchorElement>('a[href')).map(anchorElement => anchorElement.href)
    );

    const linkedUrls = allLinksOnPage.filter(link => parseUrl(link).hostname === 'localhost').map(link => link.replace(host, ''));
    pendingPages = difference(uniq(pendingPages.concat(linkedUrls)), Object.keys(pages));

    await page.close();
  } while (pendingPages.length > 0);

  await browser.close();

  for (const [url, pageHtml] of Object.entries(pages)) {
    writeFile(`./dist/${url === '/' ? 'index' : url}.html`, minifyHtml(pageHtml));
  }
});
开发者ID:kevinphelps,项目名称:kevinphelps.me,代码行数:28,代码来源:prerender.ts

示例10: validateModuleLessons

export function validateModuleLessons(
  semester: Semester,
  lessonConfig: ModuleLessonConfig,
  module: Module,
): [ModuleLessonConfig, LessonType[]] {
  const validatedLessonConfig: ModuleLessonConfig = {};
  const updatedLessonTypes: string[] = [];

  const validLessons = getModuleTimetable(module, semester);
  const lessonsByType = groupBy(validLessons, (lesson) => lesson.lessonType);

  each(lessonsByType, (lessons: RawLesson[], lessonType: LessonType) => {
    const classNo = lessonConfig[lessonType];

    // Check that the lesson exists and is valid. If it is not, insert a random
    // valid lesson. This covers both
    //
    // - lesson type is not in the original timetable (ie. a new lesson type was introduced)
    //   in which case classNo is undefined and thus would not match
    // - classNo is not valid anymore (ie. the class was removed)
    //
    // If a lesson type is removed, then it simply won't be copied over
    if (!lessons.some((lesson) => lesson.classNo === classNo)) {
      validatedLessonConfig[lessonType] = lessons[0].classNo;
      updatedLessonTypes.push(lessonType);
    } else {
      validatedLessonConfig[lessonType] = classNo;
    }
  });

  // Add all of the removed lesson types to the array of updated lesson types
  updatedLessonTypes.push(...difference(Object.keys(lessonConfig), Object.keys(lessonsByType)));
  return [validatedLessonConfig, updatedLessonTypes];
}
开发者ID:nusmodifications,项目名称:nusmods,代码行数:34,代码来源:timetables.ts


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