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


TypeScript lodash.invert函數代碼示例

本文整理匯總了TypeScript中lodash.invert函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript invert函數的具體用法?TypeScript invert怎麽用?TypeScript invert使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了invert函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: removeExtraneousVertices

export function removeExtraneousVertices(polyhedron: Polyhedron) {
  // Vertex indices to remove
  const vertsInFaces = _.flatMap(polyhedron.faces, 'vertices');
  const toRemove = _.filter(polyhedron.vertices, v => !v.inSet(vertsInFaces));
  const numToRemove = toRemove.length;

  // Map the `numToRemove` last vertices of the polyhedron (that don't overlap)
  // to the first few removed vertices
  const newToOld = _(polyhedron.vertices)
    .takeRight(numToRemove)
    .filter(v => !v.inSet(toRemove))
    .map((v, i) => [v.index, toRemove[i].index])
    .fromPairs()
    .value();
  const oldToNew = _.invert(newToOld);

  const newVertices = _(polyhedron.vertices)
    .map(v => polyhedron.vertices[_.get(oldToNew, v.index, v.index) as any])
    .dropRight(numToRemove)
    .value();

  return polyhedron.withChanges(solid =>
    solid
      .withVertices(newVertices)
      .mapFaces(face =>
        _.map(face.vertices, v => _.get(newToOld, v.index, v.index)),
      ),
  );
}
開發者ID:tessenate,項目名稱:polyhedra-viewer,代碼行數:29,代碼來源:operationUtils.ts

示例2: invert

export const persistedQueryMiddleware = (req, res, next) => {

    if (queryMap) {
        const invertedMap = invert(queryMap);

        if (isArray(req.body)) {
            req.body = req.body.map(body => {
                const id = body['id'];
                return {
                    query: invertedMap[id],
                    ...body,
                };
            });
            next();
        } else {
            if (!__DEV__ || (req.get('Referer') || '').indexOf(GRAPHIQL_ROUTE) < 0) {
                res.status(500).send('Unknown GraphQL query has been received, rejecting...');
            } else {
                next();
            }
        }
    } else {
        next();
    }
};
開發者ID:baotaizhang,項目名稱:fullstack-pro,代碼行數:25,代碼來源:persistedQuery.ts

示例3: function

 .controller("OsaAlueController", function($scope, $q, $stateParams, PerusopetusService, ProjektinMurupolkuService) {
     $scope.isVuosiluokka = $stateParams.osanTyyppi === PerusopetusService.VUOSILUOKAT;
     $scope.isOppiaine = $stateParams.osanTyyppi === PerusopetusService.OPPIAINEET;
     $scope.isOsaaminen = $stateParams.osanTyyppi === PerusopetusService.OSAAMINEN;
     $scope.versiot = { latest: true };
     $scope.dataObject = PerusopetusService.getOsa($stateParams);
     var labels = _.invert(PerusopetusService.LABELS);
     ProjektinMurupolkuService.set("osanTyyppi", $stateParams.osanTyyppi, labels[$stateParams.osanTyyppi]);
     $scope.dataObject.then(function(res) {
         ProjektinMurupolkuService.set("osanId", $stateParams.osanId, res.nimi);
     });
 })
開發者ID:Opetushallitus,項目名稱:eperusteet,代碼行數:12,代碼來源:perusopetus.ts

示例4: get

export function bimap<K extends string | number, V extends string | number>(
  obj: Record<K, V>,
) {
  const inverse = _.invert(obj);
  return {
    get(key: string | number): V {
      return obj[key];
    },
    of(val: string | number): K {
      return inverse[val] as K;
    },
  };
}
開發者ID:tessenate,項目名稱:polyhedra-viewer,代碼行數:13,代碼來源:utils.ts

示例5: listCommands

function listCommands(payload, reply) {
    let aliasLookup = _.invert(aliases);
    let msg = "Here are the commands I know how to process:\n";
    for (let k in messageHandlers) {
        if (!messageHandlers[k].adminRequired) {
            let alias = "";
            if (aliasLookup[k]) {
                alias = ` (${aliasLookup[k]})`;
            }
            msg = msg + `${k}${alias}: ${messageHandlers[k].description}\n`;
        }
    }
    reply({text: msg});
}
開發者ID:CMUBigLab,項目名稱:cmuNodeFbot,代碼行數:14,代碼來源:handlers.ts

示例6: if

        controller: (
            $scope,
            $q,
            $state,
            $stateParams,
            laajaalaiset,
            laajaalainen,
            Editointikontrollit,
            Notifikaatiot,
            YleinenData,
            ProjektinMurupolkuService,
            vaiheet,
            vaihe,
            isOsaaminen,
            isVaihe,
            isNew,
            AIPEService,
            versiot
        ) => {
            $scope.valitseKieli = _.bind(YleinenData.valitseKieli, YleinenData);
            $scope.isNew = isNew;
            $scope.osanTyyppi = $stateParams.osanTyyppi;
            $scope.versiot = {};
            $scope.$state = $state;
            $scope.aipeService = AIPEService;

            if (isOsaaminen) {
                $scope.isOsaaminen = () => $state.is("root.perusteprojekti.suoritustapa.aipeosaalue");
                $scope.dataObject = laajaalainen;
            } else if (isVaihe) {
                $scope.isVaihe = () => $state.is("root.perusteprojekti.suoritustapa.aipeosaalue");
                $scope.dataObject = vaihe;
                $scope.versiot = versiot;
            }

            $scope.edit = () => {
                Editointikontrollit.startEditing();
            };

            const labels = _.invert(AIPEService.LABELS);
            ProjektinMurupolkuService.set("osanTyyppi", $stateParams.osanTyyppi, labels[$stateParams.osanTyyppi]);
            ProjektinMurupolkuService.set("osanId", $stateParams.osanId, $scope.dataObject.nimi);
        },
開發者ID:Opetushallitus,項目名稱:eperusteet,代碼行數:43,代碼來源:state.ts

示例7:

import * as _ from 'lodash';

interface StringMap {
  [key: string]: string;
}

export const sessionAffinityViewToModelMap: StringMap = {
  'None': 'NONE',
  'Client IP': 'CLIENT_IP',
  'Generated Cookie': 'GENERATED_COOKIE',
  'Client IP and protocol': 'CLIENT_IP_PROTO',
  'Client IP, port and protocol': 'CLIENT_IP_PORT_PROTO',
};

export const sessionAffinityModelToViewMap = _.invert<StringMap, StringMap>(sessionAffinityViewToModelMap);
開發者ID:brujoand,項目名稱:deck,代碼行數:15,代碼來源:sessionAffinityNameMaps.ts

示例8: isNodeEvent

// Recorded when a cluster setting is changed.
export const SET_CLUSTER_SETTING = "set_cluster_setting";

// Node Event Types
export const nodeEvents = [NODE_JOIN, NODE_RESTART];
export const databaseEvents = [CREATE_DATABASE, DROP_DATABASE];
export const tableEvents = [CREATE_TABLE, DROP_TABLE, ALTER_TABLE, CREATE_INDEX,
  DROP_INDEX, CREATE_VIEW, DROP_VIEW, REVERSE_SCHEMA_CHANGE, FINISH_SCHEMA_CHANGE];
export const settingsEvents = [SET_CLUSTER_SETTING];
export const allEvents = [...nodeEvents, ...databaseEvents, ...tableEvents, ...settingsEvents];

interface EventSet {
  [key: string]: number;
}

const nodeEventSet = _.invert<EventSet>(nodeEvents);
const databaseEventSet = _.invert<EventSet>(databaseEvents);
const tableEventSet = _.invert<EventSet>(tableEvents);
const settingsEventSet = _.invert<EventSet>(settingsEvents);

export function isNodeEvent(e: Event): boolean {
  return !_.isUndefined(nodeEventSet[e.event_type]);
}

export function isDatabaseEvent(e: Event): boolean {
  return !_.isUndefined(databaseEventSet[e.event_type]);
}

export function isTableEvent(e: Event): boolean {
  return !_.isUndefined(tableEventSet[e.event_type]);
}
開發者ID:irfansharif,項目名稱:cockroach,代碼行數:31,代碼來源:eventTypes.ts

示例9:

export const WeatherCode = _.invert<{ [index: number]: string; }>({
    'thunderstorm with light rain': [200],
    'thunderstorm with rain': [201],
    'thunderstorm with heavy rain': [202],
    'light thunderstorm': [210],
    'thunderstorm': [211],
    'heavy thunderstorm': [212],
    'ragged thunderstorm': [221],
    'thunderstorm with light drizzle': [230],
    'thunderstorm with drizzle': [231],
    'thunderstorm with heavy drizzle': [232],
    'light intensity drizzle': [300],
    'drizzle': [301],
    'heavy intensity drizzle': [302],
    'light intensity drizzle rain': [310],
    'drizzle rain': [311],
    'heavy intensity drizzle rain': [312],
    'shower rain and drizzle': [313],
    'heavy shower rain and drizzle': [314],
    'shower drizzle': [321],
    'light rain': [500],
    'moderate rain': [501],
    'heavy intensity rain': [502],
    'very heavy rain': [503],
    'extreme rain': [504],
    'freezing rain': [511],
    'light intensity shower rain': [520],
    'shower rain': [521],
    'heavy intensity shower rain': [522],
    'ragged shower rain': [531],
    'light snow': [600],
    'snow': [601],
    'heavy snow': [602],
    'sleet': [611],
    'shower sleet': [612],
    'light rain and snow': [615],
    'rain and snow': [616],
    'light shower snow': [620],
    'shower snow': [621],
    'heavy shower snow': [622],
    'mist': [701],
    'smoke': [711],
    'haze': [721],
    'sand dust whirls': [731],
    'fog': [741],
    'sand': [751],
    'dust': [761],
    'volcanic ash': [762],
    'squalls': [771],
    'clear sky': [800],
    'few clouds': [801],
    'scattered clouds': [802],
    'broken clouds': [803],
    'overcast clouds': [804],
    'tropical storm': [901],
    'cold': [903],
    'hot': [904],
    'windy': [905],
    'hail': [906],
    'calm': [951],
    'light breeze': [952],
    'gentle breeze': [953],
    'moderate breeze': [954],
    'fresh breeze': [955],
    'strong breeze': [956],
    'high wind near gale': [957],
    'gale': [958],
    'severe gale': [959],
    'storm': [960],
    'violent storm': [961],
    'tornado': [781, 900],
    'hurricane': [902, 962]
});
開發者ID:david-driscoll,項目名稱:bike-computer,代碼行數:73,代碼來源:OpenWeatherMapService.ts

示例10: invert

  [VideoPrivacy.PUBLIC]: 'Public',
  [VideoPrivacy.UNLISTED]: 'Unlisted',
  [VideoPrivacy.PRIVATE]: 'Private'
}

const VIDEO_STATES = {
  [VideoState.PUBLISHED]: 'Published',
  [VideoState.TO_TRANSCODE]: 'To transcode'
}

const VIDEO_MIMETYPE_EXT = {
  'video/webm': '.webm',
  'video/ogg': '.ogv',
  'video/mp4': '.mp4'
}
const VIDEO_EXT_MIMETYPE = invert(VIDEO_MIMETYPE_EXT)

const IMAGE_MIMETYPE_EXT = {
  'image/png': '.png',
  'image/jpg': '.jpg',
  'image/jpeg': '.jpg'
}

// ---------------------------------------------------------------------------

const SERVER_ACTOR_NAME = 'peertube'

const ACTIVITY_PUB = {
  POTENTIAL_ACCEPT_HEADERS: [
    'application/activity+json',
    'application/ld+json',
開發者ID:jiang263,項目名稱:PeerTube,代碼行數:31,代碼來源:constants.ts


注:本文中的lodash.invert函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。