1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2024-11-01 15:45:58 +09:00

Add concat function (#2640)

This commit is contained in:
Aya Morisawa 2018-09-06 21:31:15 +09:00 committed by syuilo
parent f428372869
commit 3cace734c7
4 changed files with 14 additions and 8 deletions

View File

@ -85,6 +85,7 @@
<script lang="ts">
import Vue from 'vue';
import { host, copyright } from '../../../config';
import { concat } from '../../../../../prelude/array';
export default Vue.extend({
data() {
@ -119,8 +120,8 @@ export default Vue.extend({
(this as any).api('notes/local-timeline', {
fileType: image,
limit: 6
}).then(notes => {
const files = [].concat(...notes.map(n => n.files));
}).then((notes: any[]) => {
const files = concat(notes.map((n: any): any[] => n.files));
this.photos = files.filter(f => image.includes(f.type)).slice(0, 6);
});
},

View File

@ -40,6 +40,7 @@
<script lang="ts">
import Vue from 'vue';
import { apiUrl, copyright, host } from '../../../config';
import { concat } from '../../../../../prelude/array';
export default Vue.extend({
data() {
@ -79,8 +80,8 @@ export default Vue.extend({
(this as any).api('notes/local-timeline', {
fileType: image,
limit: 6
}).then(notes => {
const files = [].concat(...notes.map(n => n.files));
}).then((notes: any[]) => {
const files = concat(notes.map((n: any): any[] => n.files));
this.photos = files.filter(f => image.includes(f.type)).slice(0, 6);
});
}

View File

@ -1,4 +1,4 @@
import { count, countIf } from "../../prelude/array";
import { count, concat } from "../../prelude/array";
// MISSKEY REVERSI ENGINE
@ -286,7 +286,7 @@ export default class Reversi {
}
};
return [].concat(...diffVectors.map(effectsInLine));
return concat(diffVectors.map(effectsInLine));
}
/**

View File

@ -6,6 +6,10 @@ export function count<T>(x: T, xs: T[]): number {
return countIf(y => x === y, xs);
}
export function intersperse<T>(sep: T, xs: T[]): T[] {
return [].concat(...xs.map(x => [sep, x])).slice(1);
export function concat<T>(xss: T[][]): T[] {
return ([] as T[]).concat(...xss);
}
export function intersperse<T>(sep: T, xs: T[]): T[] {
return concat(xs.map(x => [sep, x])).slice(1);
}