當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。