Add concat function (#2640)
This commit is contained in:
parent
f428372869
commit
3cace734c7
@ -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);
|
||||
});
|
||||
},
|
||||
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user