本文整理汇总了TypeScript中ramda.range函数的典型用法代码示例。如果您正苦于以下问题:TypeScript range函数的具体用法?TypeScript range怎么用?TypeScript range使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了range函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: range
.then(({ data: firstPageData, page, pages, results }) => {
// If we only have one page, return it.
if (page === pages) {
return {
data: firstPageData,
results
};
}
// Create an iterable list of the remaining pages.
const remainingPages = range(page + 1, pages + 1);
//
return Bluebird
.map(remainingPages, nextPage =>
getter({ ...pagination, page: nextPage }, filter).then(response => response.data),
)
/** We're given Linode.NodeBalancer[][], so we flatten that, and append the first page response. */
.then(resultPages => {
const combinedData = resultPages.reduce((result, nextPage) => {
return [...result, ...nextPage]
}, firstPageData);
return {
data: combinedData,
results
}
});
});
示例2: pins
function pins(
{ frame, squareNumber }: FramePinState,
dispatch: (action: FrameAction) => void,
) {
const frameOptions = {
key: frame.id,
onclick() {
dispatch({ type: "cycle" })
},
style: "cursor: pointer;",
className: frame.id === 10 ? "tenth-frame" : "",
}
const standingPins = frame.squares[squareNumber - 1].standingPins
return m("li", frameOptions, [
m(".frame-number-container", frame.id),
m(".score-container", [
m(".shot-number", squareNumber),
m(
".pins",
range(0, 10).map(n => {
const isStanding = standingPins & (1 << n) ? ".isStanding" : ""
return m(`.pin.pin-${n + 1}${isStanding}`)
}),
),
]),
])
}
示例3: range
const MainComponent = () => {
const lanes = range(1, 11)
return {
view() {
return m(".bowling-container.container-fluid", [
m("a[href=/stats].stats-link", [
m("i.fa.fa-bar-chart-o"),
"\u00a0",
"See Statistics from EYC",
]),
m("h1.page-title", "EYC 2016 Live Scoring"),
m("h2.sub-title", "Scores are refreshed every 30 seconds"),
m(
".row",
lanes.map(function(laneNumber) {
const l1 = laneNumber * 2 + 1
const l2 = laneNumber * 2 + 2
return [
m(
".col-xs-12.col-sm-12.col-md-6.col-lg-6",
m(Lane, { laneNumber: l1 }),
),
m(
".col-xs-12.col-sm-12.col-md-6.col-lg-6",
m(Lane, { laneNumber: l2 }),
),
]
}),
),
m(".footer", [
m("p", [
m("i.fa.fa-heart"),
" from ",
m("a[href=https://twitter.com/enordfjord]", "Einar"),
m(
"a[href=#].center",
{
onclick: scrollToTop,
},
[
m("i.fa.fa-arrow-circle-o-up", {
style: "font-size: 24px",
title: "Scroll to top",
}),
],
),
m("span.pull-right", [
"Powered by ",
m("a[href=https://xbowling.com]", "MSCN XBowling"),
" API",
]),
]),
]),
])
},
}
}
示例4: upToConditional
static upToConditional(n) {
const isModuloOf = mod => i => i % mod === 0;
const fb = R.cond([
[isModuloOf(15), R.always('fizzbuzz')],
[isModuloOf(5), R.always('buzz')],
[isModuloOf(3), R.always('fizz')],
[R.T, i => '' + i]
]);
return R.map(fb, R.range(1, R.inc(n)));
}
示例5: upToPipeline
static upToPipeline(n) {
const isModuloOf = mod => (i: any): boolean => i % mod === 0;
const apply = (m, s) => R.when(isModuloOf(m), R.always(s))
const fizzBuzz = apply(15, 'fizzbuzz')
const fizz = apply(3, 'fizz')
const buzz = apply(5, 'buzz')
const fizzbuzzPipeline = R.pipe(fizzBuzz, fizz, buzz, (i) => '' + i)
return R.map(fizzbuzzPipeline, R.range(1, R.inc(n)));
}
示例6: upToLookUp
static upToLookUp(n) {
const s = R.toString
const f = R.always('fizz');
const b = R.always('buzz');
const fb = R.always(f() + b());
const funs = [s, s, f, s, b, f, s, s, f, b, s, f, s, s, fb];
const selectFun: any = (n) => R.nth(R.modulo(R.dec(n), 15), funs);
const fizzBuzzify = (n) => R.call(selectFun(n), n);
return R.map(fizzBuzzify, R.range(1, R.inc(n)));
}
示例7: constructor
constructor (width: number, height: number) {
if (width % 2 == 0 || height % 2 == 0) {
throw new Error('FaceGrid expects uneven width and height!')
}
this.width = width
this.height = height
this.centerX = Math.floor(width / 2)
this.centerY = Math.floor(height / 2)
// Generate the drawing structure
this.coordsMap = range(0, this.height).map(row => range(0, this.width).map(col => 0))
// Mark center for debug reasons
//this.markDrawPoint(this.centerX, this.centerY)
this.generateFaceDimensions()
this.generateSkeleton()
}
示例8:
// Join: [1,2,3], [4,5,6], [7,8,9] -> [1,4,7], [2,5,8], [3,6,9]
(results) => R.map((i) => R.map((item) => item[i], results), R.range(0, results[0].length)),
示例9: range
this.coordsMap = range(0, this.height).map(row => range(0, this.width).map(col => 0))
示例10: solve
function solve(maxValue: number): number {
return R.sum(R.map((n: number) => (n % 5 == 0 || n % 3 == 0) ? n : 0,
R.range(1, maxValue)));
}