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


TypeScript lodash.zip函數代碼示例

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


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

示例1: mt2tpb

/**
 * Get T,P and B axes from moment tensor 
 * 
 * @param mt - moment tensor matrix
 */
function mt2tpb(mt: number[][]) {
    var {
        eigenvalues,
        eigenvectors
    } = eigen(mt)

    var t = [eigenvalues[0], eigenvalues[1], eigenvalues[2]]
    var azelever = cart2sph(eigenvectors[1], numeric.mul(eigenvectors[2], -1), eigenvectors[0])
    var b = azelever.az
    var p = azelever.elev

    // get into degrees
    b = b.map(item => item * bbmath.R2D)

    p = p.map(item => item * bbmath.R2D)

    b = _.zip(p, b).map(pb => pb[0] < 0 ? pb[1] + 180 : pb[1])

    p = p.map(item => Math.abs(item))

    //force azimuth to be in 0-360
    b = b.map(item => item >= 360 ? item - 360 : item)
    b = b.map(item => item < 0 ? item + 360 : item)

    return {
        t: [t[2], p[2], b[2]],
        p: [t[0], p[0], b[0]],
        b: [t[1], p[1], b[1]]
    }
}
開發者ID:timofeevda,項目名稱:seismic-beachballs,代碼行數:35,代碼來源:bbutils.ts

示例2: iterchunks

export function iterchunks (orbs: Orb[][], chunkLimitRange: [number, number] = [4, 2], includePositionInformation = false): types.Chunk[] {
    let transposedOrbs: Orb[][] = _.zip(...orbs);
    return [
            ..._iterchunks(orbs, chunkLimitRange, includePositionInformation, false),
            ..._iterchunks(transposedOrbs, chunkLimitRange, includePositionInformation, true)
    ]
};
開發者ID:rbcasperson,項目名稱:match-three-js,代碼行數:7,代碼來源:tools.ts

示例3: htmlPrintPpCmdsDiff

export function htmlPrintPpCmdsDiff(l : PpCmds, old : PpCmds) : string {
  _(patterns).each(pattern => {
    l = pattern(l)
    old = pattern(old)
  })
  if (!ppCmdsSameShape(l, old)) {
    return markDifferent(
      _.reduce(
        l,
        (acc : string, p : PpCmdType) => {
          return acc + htmlPrintPpCmd(p)
        },
        ''
      )
    )
  }
  const z = _.zip(l, old)
  return _.reduce(
    z,
    (acc : string, [p, oldP] : [PpCmdType, PpCmdType]) => {
      return acc + htmlPrintPpCmdDiff(p, oldP)
    },
    ''
  )
}
開發者ID:Ptival,項目名稱:PeaCoq,代碼行數:25,代碼來源:printers.ts

示例4: buildRoute

function buildRoute(route: UncompiledRoute, currentPath: Array<string>): NgrxRoute {
  const { path, children } = route;
  const relativePath = path && map(dropWhile(zip(path.parts, currentPath), ([a, b]) => a === b), a => a[0]);

  return Object.assign({}, route, {
    path: path && (currentPath.length === 0 ? '/' : '') + relativePath.join('/'),
    children: children && children.map(child => buildRoute(child, relativePath || currentPath)),
  });
}
開發者ID:angryzor,項目名稱:typesafe-urls-ngrx-router,代碼行數:9,代碼來源:index.ts

示例5: find

export function find(orbs: Orb[][]): number[][][] {
    let chunksOriginal = tools._iterchunks(orbs, [3, 1], true, false);
    let chunksTransposed = tools._iterchunks(_.zip(...orbs), [3, 1], true, true);

    return [
            ..._findTriples(chunksOriginal, false),
            ..._findTriples(chunksTransposed, true)
    ];
};
開發者ID:rbcasperson,項目名稱:match-three-js,代碼行數:9,代碼來源:triples.ts

示例6: makePiece

export function makePiece(shape: string[], color: ColorIndex): Piece {
  // Map 1s to filled squares and 0s to to empty squares (null)
  const rows = shape.map((row) => row.split('').map((tile) => (tile === '1' ? { color } : null)));

  const tiles = zip(...rows) as Board;

  return {
    tiles,
    ...originalPosition(tiles),
  };
}
開發者ID:nusmodifications,項目名稱:nusmods,代碼行數:11,代碼來源:board.ts

示例7: sortColorsByHue

function sortColorsByHue(hexColors: string[]) {
  const hslColors = _.map(hexColors, hexToHsl);

  const sortedHSLColors = _.sortBy(hslColors, ['h']);
  const chunkedHSLColors = _.chunk(sortedHSLColors, PALETTE_ROWS);
  const sortedChunkedHSLColors = _.map(chunkedHSLColors, chunk => {
    return _.sortBy(chunk, 'l');
  });
  const flattenedZippedSortedChunkedHSLColors = _.flattenDeep(_.zip(...sortedChunkedHSLColors));

  return _.map(flattenedZippedSortedChunkedHSLColors, hslToHex);
}
開發者ID:CorpGlory,項目名稱:grafana,代碼行數:12,代碼來源:colors.ts

示例8: describe

 describe(suiteName, () => {
   zip(testNames, tests).forEach(([name, value]) => {
     if (name.includes(":skip")) {
       return;
     }
     const testName = name.replace("// it:", "").trim();
     it(testName, async () => {
       const result = await evaluate(value);
       return assert.isTrue(typeof result === "boolean" && result);
     });
   });
 });
開發者ID:metaes,項目名稱:metaes,代碼行數:12,代碼來源:runner.ts

示例9:

 const report = getters.reports.reduce((report1, report2) => {
   const chances1 = report1.roundedChances || [];
   const chances2 = report2.roundedChances || [];
   for (const [chance1 = 0, chance2 = 0] of zip(chances1, chances2)) {
     if (chance1 > chance2) return report1;
     if (chance2 > chance1) return report2;
   }
   if (!report2.damage) return report1;
   if (!report1.damage) return report2;
   if (report2.damage.max(NaN) > report1.damage.max(NaN)) return report2;
   return report1;
 }, emptyReport);
開發者ID:Sulcata,項目名稱:Sulcata-Damage-Calculator,代碼行數:12,代碼來源:getters.ts

示例10: sortColorsByHue

export function sortColorsByHue(hexColors) {
  const hslColors = _.map(hexColors, hexToHsl);

  let sortedHSLColors = _.sortBy(hslColors, ['h']);
  sortedHSLColors = _.chunk(sortedHSLColors, PALETTE_ROWS);
  sortedHSLColors = _.map(sortedHSLColors, chunk => {
    return _.sortBy(chunk, 'l');
  });
  sortedHSLColors = _.flattenDeep(_.zip(...sortedHSLColors));

  return _.map(sortedHSLColors, hslToHex);
}
開發者ID:acedrew,項目名稱:grafana,代碼行數:12,代碼來源:colors.ts


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