本文整理汇总了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]]
}
}
示例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)
]
};
示例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)
},
''
)
}
示例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)),
});
}
示例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)
];
};
示例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),
};
}
示例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);
}
示例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);
});
});
});
示例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);
示例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);
}