本文整理汇总了TypeScript中lodash.min函数的典型用法代码示例。如果您正苦于以下问题:TypeScript min函数的具体用法?TypeScript min怎么用?TypeScript min使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了min函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
scope.$watch('highlightTarget', function(target) {
if (!target) {
scope.rects = undefined;
scope.highlightInfo = undefined;
return;
}
if (target.ranges.length) {
scope.rects = containerCtrl.getRangesRects(target.ranges);
// gather bbox information and expose it on the scope
const info = {
left: _.min(_.map(scope.rects, 'left')),
right: _.max(_.map(scope.rects, function(rect) {
return rect.left + rect.width;
})),
top: _.min(_.map(scope.rects, 'top')),
bottom: _.max(_.map(scope.rects, function(rect) {
return rect.top + rect.height;
})),
width: undefined,
height: undefined,
};
info.width = info.right - info.left;
info.height = info.bottom - info.top;
scope.highlightInfo = info;
}
}, true);
示例2: getRate
function getRate(yLeft, yRight) {
var rateLeft, rateRight, rate;
if (checkTwoCross(yLeft, yRight)) {
rateLeft = yRight.min ? yLeft.min / yRight.min : 0;
rateRight = yRight.max ? yLeft.max / yRight.max : 0;
} else {
if (checkOneSide(yLeft, yRight)) {
var absLeftMin = Math.abs(yLeft.min);
var absLeftMax = Math.abs(yLeft.max);
var absRightMin = Math.abs(yRight.min);
var absRightMax = Math.abs(yRight.max);
var upLeft = _.max([absLeftMin, absLeftMax]);
var downLeft = _.min([absLeftMin, absLeftMax]);
var upRight = _.max([absRightMin, absRightMax]);
var downRight = _.min([absRightMin, absRightMax]);
rateLeft = downLeft ? upLeft / downLeft : upLeft;
rateRight = downRight ? upRight / downRight : upRight;
} else {
if (yLeft.min > 0 || yRight.min > 0) {
rateLeft = yLeft.max / yRight.max;
rateRight = 0;
} else {
rateLeft = 0;
rateRight = yLeft.min / yRight.min;
}
}
}
rate = rateLeft > rateRight ? rateLeft : rateRight;
return rate;
}
示例3: tilesInView
get tilesInView(): TilesInView {
var startCol: number = _.floor(this.camera.x / this.map.tileWidth);
var endCol: number = startCol + (this.camera.width / this.map.tileWidth);
var startRow: number = _.floor(this.camera.y / this.map.tileHeight);
var endRow: number = startRow + (this.camera.height / this.map.tileHeight);
return {
startCol: startCol,
endCol: _.min([endCol, this.map.colCount - 1]),
startRow: startRow,
endRow: _.min([endRow, this.map.rowCount - 1])
};
}
示例4:
function removeMin<T>(array: T[]) {
if (array.length > 0) {
const minIdx = array.indexOf(min(array)!);
array[minIdx] = array[array.length - 1];
array.length--;
}
}
示例5: enabler
"!typegame": enabler((command: Tennu.Command) => {
var cache = typegameCache[command.channel] = typegameCache[command.channel] || { running: false };
if (typegameCache[command.channel].running) {
return util.format("A game is still running! Name %s PokĂŠmon with the type %s!", cache.cnt, cache.types.join("/"));
} else {
(runningCache[command.channel] = runningCache[command.channel] || []).push("typegame")
var {type, cnt} = _.sample(Data.type_count_array);
console.log(cnt);
cache = typegameCache[command.channel] = {
running: true,
type: type,
cnt: _.random(1, _.min([5, cnt])),
max: cnt,
userCount: {},
guessed: {},
types: []
};
for (var i = 0; type; type >>= 1, ++i) {
if (type&1)
cache.types.push(Data.type_list[i]);
}
return util.format("Name %s PokĂŠmon with the type %s!",
cache.cnt, cache.types.join("/")
);
}
}),
示例6: createScales
export function createScales(props: PositionsBubbleChartProps) {
const ratio = 12.5
const { width, height } = props.size
const minR = 15
const maxR = 60
const offset = maxR / 2
const positionData = getPositionsDataFromSeries(props.data, props.currencyPairs)
const baseValues = _.map(positionData, (val: any) => {
return Math.abs(val[baseTradedAmountName])
})
const maxValue = _.max(baseValues) || 0
let minValue = _.min(baseValues) || 0
if (minValue === maxValue) minValue = 0
const scales = {
x: d3.scale.linear()
.domain([0, props.data.length])
.range([(-(width / ratio)), (width / ratio) - offset]),
y: d3.scale.linear()
.domain([0, props.data.length])
.range([-(height / (ratio)), height / ratio]),
r: d3.scale.sqrt()
.domain([minValue, maxValue])
.range([minR, maxR])}
return scales
}
示例7: reposition
function reposition() {
// set height of element such that it fits the viewport
// note: the 1px prevents scroll bars in certain situations
const height = min([
jquery($window).innerHeight() - params.offsetTop -
params.offsetBottom - 1,
element[0].scrollHeight,
]);
element.css({height: height > 0 ? height + 'px' : 'auto'});
// get position of parent
const offsetParent = element[0].offsetParent;
if (!offsetParent) { return; }
const parentRect = offsetParent.getBoundingClientRect();
// positioned normally
let affixed = false;
if (parentRect.top >= params.offsetTop) {
// not affixed (aka affixed to top of container)
element.css({position: 'static', top: 0});
} else {
affixed = true;
if (parentRect.top + parentRect.height < height + params.offsetTop) {
// affixed to bottom of container
element.css({position: 'relative', top: parentRect.height - height});
} else {
// affixed to top of viewport (plus offsetTop)
element.css({
position: 'relative',
top: -parentRect.top + params.offsetTop,
});
}
}
}
示例8: addXHistogramAxis
function addXHistogramAxis(options, bucketSize) {
let ticks, min, max;
if (data.length) {
ticks = _.map(data[0].data, point => point[0]);
// Expand ticks for pretty view
min = Math.max(0, _.min(ticks) - bucketSize);
max = _.max(ticks) + bucketSize;
ticks = [];
for (let i = min; i <= max; i += bucketSize) {
ticks.push(i);
}
} else {
// Set defaults if no data
ticks = panelWidth / 100;
min = 0;
max = 1;
}
options.xaxis = {
timezone: dashboard.getTimezone(),
show: panel.xaxis.show,
mode: null,
min: min,
max: max,
label: "Histogram",
ticks: ticks
};
}
示例9: getFirstAvailableSemester
export function getFirstAvailableSemester(
semesters: ReadonlyArray<SemesterDataCondensed>,
current: Semester = config.semester, // For testing only
): Semester {
const availableSemesters = semesters.map((semesterData) => semesterData.semester);
return availableSemesters.includes(current) ? current : _.min(availableSemesters)!;
}
示例10: getDomainBoundaries
/*
* max & min value from two-dimensional array
*/
public getDomainBoundaries(tsv: TSVFile): DomainBoundaries {
const chipIndexes = this.getChipHeaderIndexes(tsv.headers);
const values = _.map(tsv.body.rows, (row: TSVRow) => row.getCellsByIndexes(chipIndexes));
const flatValues = _.map(_.flatten(values), (value: string) => parseFloat(value));
const min = _.min(flatValues);
const max = _.max(flatValues);
return new DomainBoundaries(min, max);
}