render() { let {Month, viewDate, value = moment()} = this.props; let viewYear = viewDate.year(); let year = value.year(); let month = value.month(); let cells = YEAR_MONTH_RANGE.map(m => <Month key={m} active={m === month && viewYear === year} month={m} year={viewYear} value={MONTHS_SHORT[m]} onClick={this.onMonthClick} /> ); let rows = chunk(cells, 3).map((row, idx) => <div key={idx}>{row}</div>); return ( <Paginator title={this.props.viewDate.year()} onPrev={this.onPrevYear} onNext={this.onNextYear} onUp={this.onYearsMode}> {rows} </Paginator> ); }
function batchInsert(models, queryBuilder, batchSize, queries) { const batches = chunk(models, batchSize); for (let i = 0, l = batches.length; i < l; ++i) { queries.push(queryBuilder.clone().insert(batches[i])); } }
fetchRelation(builder, models, relation, expr) { const batchSize = this.batchSize(builder.knex()); const modelBatches = chunk(models, batchSize); return Promise .map(modelBatches, batch => this.fetchRelationBatch(builder, batch, relation, expr)) .then(flatten); }
module.exports = function chunk(array, size) { // Asserting assertArgument(array = toArray(array), 1, 'ArrayLike'); assertArgument(isVoid(size) || isIndex(size), 2, 'number'); // Returning return _chunk(array, size); };
render() { const { input, isShowScan, prefixKeyboard } = this.state; const isPrefix = input && input.length >= 9; return ( <View style={sh.viewport}> <View style={sh.input}> <Text style={sh.inputText}>{input}</Text> {!input && <Text style={sh.preholder}>災民證 / 身分證 / 居留證</Text>} {!input && <Text style={sh.tip}>請輸入證件字號後九位數字,居留證請先按 0</Text>} </View> <View style={sh.keyboard}> {isPrefix || prefixKeyboard.length ? map(chunk(prefixKeyboard, 3), (buttons, idx) => ( <View style={sh.buttonGroup} key={idx}>{buttons}</View> )) : map(chunk(this.numberKeyboard, 3), (buttons, idx) => ( <View style={sh.buttonGroup} key={idx}>{buttons}</View> )) } <View style={sh.buttonGroup} key="break"> {this.renderButton('scan')} {isPrefix || prefixKeyboard.length ? <View style={sh.button} /> : this.renderButton('0') } {this.renderButton('break')} </View> </View> <Modal visible={isShowScan} onRequestClose={this.onHideScanPress}> <Scanner ratio={1 / 0.3} onBarCodeRead={this.onBarCodeRead} /> <IconButton name="clear" style={sh.hideScanButton} onPress={this.onHideScanPress} /> </Modal> </View> ); }
/** * Create a set of statements that will initialize all of the statically-known * export names with their expected values. */ function buildExportInitializationStatements( programPath: NodePath, metadata: ModuleMetadata, ) { const initStatements = []; const exportNames = []; for (const [localName, data] of metadata.local) { if (data.kind === "import") { // No-open since these are explicitly set with the "reexports" block. } else if (data.kind === "hoisted") { initStatements.push( buildInitStatement(metadata, data.names, t.identifier(localName)), ); } else { exportNames.push(...data.names); } } for (const data of metadata.source.values()) { for (const [exportName, importName] of data.reexports) { initStatements.push( template` Object.defineProperty(EXPORTS, "EXPORT_NAME", { enumerable: true, get: function() { return NAMESPACE.IMPORT_NAME; }, }); `({ EXPORTS: metadata.exportName, EXPORT_NAME: exportName, NAMESPACE: data.name, IMPORT_NAME: importName, }), ); } for (const exportName of data.reexportNamespace) { exportNames.push(exportName); } } initStatements.push( ...chunk(exportNames, 100).map(members => { return buildInitStatement( metadata, members, programPath.scope.buildUndefinedNode(), ); }), ); return initStatements; }
render() { let {tableData, noOfColumn} = this.props; let newTableData = chunk(tableData, noOfColumn) let rows = newTableData.map((rowData, index) => { return <RenderTr noOfColumn={noOfColumn} rowData={rowData} key={index} /> }); return ( <table className="table table-bordered"> <tbody> {rows} </tbody> </table> ); }
export function stuffToAsm(frames, name, isMapping = false) { // get real mapping name const startLabel = name.replace(/[^\w]/g, '') || 'DATA' + Math.random().toString(36).slice(2).toUpperCase(); let output = `; ${'='.repeat(80)} ; Sprite ${isMapping?'Mappings' : 'DPLCs'} - generated by Flex 2 ${new Date()} ; ${'='.repeat(80)} ${startLabel}: `; let dataOutput = ''; let labels = []; frames.forEach((arrays, index) => { let label; if (arrays.length == 0) { label = 0; } else { label = `${startLabel}_${index.toString(16).toUpperCase()}`; const [header, ...data] = arrays; // header dataOutput += `${label}: dc.b ${to68kByteStr(header)}\n`; // pieces data.forEach((piece) => { piece.forEach((datum) => { dataOutput += `\tdc.b ${to68kByteStr(datum)}\n`; }); }); } labels.push(label); }); dataOutput += '\teven'; // draw headers chunk(labels, 2) .forEach((words) => { output += `\tdc.w ${words.map((word) => ( word == 0 ? '$0' : `${word}-${startLabel}` )).join`, `}\n`; }); output += dataOutput; return output; }
render() { let { date, culture, weekdayFormat, className } = this.props, month = dates.visibleDays(date, culture), weeks = chunk(month, 7) this._weekCount = weeks.length return ( <div className={cn('rbc-month-view', className)}> <div className="rbc-row rbc-month-header"> {this.renderHeaders(weeks[0], weekdayFormat, culture)} </div> {weeks.map(this.renderWeek)} {this.props.popup && this.renderOverlay()} </div> ) }
var listToGrid = function listToGrid(x) { return chunk(x, 7); };
.then(results => values(mapValues(results, entryPoints => { const chunkLength = Math.ceil(entryPoints.length / cpus.length); return chunk(entryPoints, chunkLength); })))
const chunkwords = desc => chunk( desc.split(' ').reverse(), 3 ).map( c => c.reverse().join('\u00A0') ).reverse().join(' ')
render() { if (this.props.error) { return <ErrorComponent error={this.props.error} onBack={this.props.onBack} /> } const activeMenuProof = this.state.activeMenuProof // TODO move this kind of stuff to connect and make this waaaaay dumber const friends = this.state.currentFriendshipsTab === 'Followers' ? this.props.followers : this.props.following let friendData = chunk(friends || [], 3) if (!friendData.length) { let type if (this.props.isYou) { type = this.state.currentFriendshipsTab === 'Followers' ? `You have no followers.` : `You are not following anyone.` } else { type = this.state.currentFriendshipsTab === 'Followers' ? `${this.props.username} has no followers.` : `${this.props.username} is not following anyone.` } friendData = [[{dummy: type}]] } const trackerStateColors = stateColors(this.props.currentlyFollowing, this.props.trackerState) return ( <Box style={globalStyles.fullHeight}> <NativeSectionList stickySectionHeadersEnabled={true} style={{...globalStyles.fullHeight, backgroundColor: trackerStateColors.header.background}} ref={this._setRef} initialNumToRender={2} renderSectionHeader={this._renderSections} keyExtractor={this._keyExtractor} forceRenderProofs={this.props.proofs} forceRenderBio={this.props.userInfo} sections={[ { renderItem: this._renderProfile, title: 'profile', data: [{key: 'profile'}], }, { renderItem: this._renderFriends, title: 'friends', data: friendData, }, ]} /> {!!activeMenuProof && <PopupMenu {...this._proofMenuContent(activeMenuProof)} onHidden={() => this._handleToggleMenu(this.props.proofs.indexOf(activeMenuProof))} />} </Box> ) }
/** * This will return an array of two-value arrays containing a `RunwayModel` * for each end of a runway. * * This should only be used by the `CanvasController` for drawing runways. * This returns data in this shape in an effort to maintain a previous api. * * @property runways * @return {array<array<RunwayModel>>} */ get runways() { return _chunk(this._runwayCollection.runways, 2); }
render() { let { allPostsJson, user } = this.props.data const posts = allPostsJson.edges.map(e => e.node) user = user.edges[0].node return ( <Layout location={this.props.location}> <div css={{ display: `flex`, alignItems: `stretch`, flexShrink: 0, flexDirection: `column`, }} > {/* user profile */} <div data-testid="user-avatar" css={{ paddingBottom: rhythm(2), paddingTop: rhythm(1.5), paddingLeft: rhythm(1.5), paddingRight: rhythm(1.5), display: `flex`, flexDirection: `row`, alignItems: `stretch`, flexWrap: `wrap`, }} > <div css={{ flexGrow: 2, flexShrink: 0, textAlign: `center`, [`@media (min-width: 600px)`]: { paddingTop: rhythm(1 / 2), textAlign: `left`, }, }} > <h3 data-testid="username" css={{ fontWeight: `normal`, }} > {user.username} </h3> <p data-testid="user-meta"> <strong>{posts.length}</strong> posts <strong css={{ marginLeft: rhythm(1) }}>192k</strong> followers </p> </div> </div> {/* posts */} {chunk(posts.slice(0, this.state.postsToShow), 3).map((chunk, i) => ( <div key={`chunk-${i}`} css={{ display: `flex`, alignItems: `stretch`, flexShrink: 0, flexDirection: `row`, marginBottom: rhythm(1 / 8), [presets.Tablet]: { marginBottom: rhythm(1), }, }} > {chunk.map(node => ( <Post key={node.id} post={node} location={this.props.location} onClick={post => this.setState({ activePost: post })} /> ))} </div> ))} {!this.state.showingMore && ( <a data-testid="load-more" css={{ ...scale(-0.5), border: `1px solid blue`, boxShadow: 0, background: `none`, color: `blue`, cursor: `pointer`, margin: `0 auto`, padding: rhythm(1 / 2), width: `calc(100vw - ${rhythm(1)})`, marginLeft: rhythm(0.5), marginRight: rhythm(0.5), marginBottom: rhythm(0.5), marginTop: rhythm(0.5), [presets.Tablet]: { borderRadius: `100%`, margin: `0 auto`, marginBottom: rhythm(1.5), marginTop: rhythm(1.5), padding: rhythm(1), height: rhythm(5), width: rhythm(5), lineHeight: rhythm(3), textAlign: `center`, }, }} onClick={() => { this.setState({ postsToShow: this.state.postsToShow + 12, showingMore: true, }) }} > Load More </a> )} </div> </Layout> ) }