当前位置: 首页>>代码示例>>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;未经允许,请勿转载。