Add concat function (#2640)
This commit is contained in:
parent
f428372869
commit
3cace734c7
|
@ -85,6 +85,7 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import { host, copyright } from '../../../config';
|
import { host, copyright } from '../../../config';
|
||||||
|
import { concat } from '../../../../../prelude/array';
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
data() {
|
data() {
|
||||||
|
@ -119,8 +120,8 @@ export default Vue.extend({
|
||||||
(this as any).api('notes/local-timeline', {
|
(this as any).api('notes/local-timeline', {
|
||||||
fileType: image,
|
fileType: image,
|
||||||
limit: 6
|
limit: 6
|
||||||
}).then(notes => {
|
}).then((notes: any[]) => {
|
||||||
const files = [].concat(...notes.map(n => n.files));
|
const files = concat(notes.map((n: any): any[] => n.files));
|
||||||
this.photos = files.filter(f => image.includes(f.type)).slice(0, 6);
|
this.photos = files.filter(f => image.includes(f.type)).slice(0, 6);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Vue from 'vue';
|
import Vue from 'vue';
|
||||||
import { apiUrl, copyright, host } from '../../../config';
|
import { apiUrl, copyright, host } from '../../../config';
|
||||||
|
import { concat } from '../../../../../prelude/array';
|
||||||
|
|
||||||
export default Vue.extend({
|
export default Vue.extend({
|
||||||
data() {
|
data() {
|
||||||
|
@ -79,8 +80,8 @@ export default Vue.extend({
|
||||||
(this as any).api('notes/local-timeline', {
|
(this as any).api('notes/local-timeline', {
|
||||||
fileType: image,
|
fileType: image,
|
||||||
limit: 6
|
limit: 6
|
||||||
}).then(notes => {
|
}).then((notes: any[]) => {
|
||||||
const files = [].concat(...notes.map(n => n.files));
|
const files = concat(notes.map((n: any): any[] => n.files));
|
||||||
this.photos = files.filter(f => image.includes(f.type)).slice(0, 6);
|
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
|
// 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);
|
return countIf(y => x === y, xs);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function intersperse<T>(sep: T, xs: T[]): T[] {
|
export function concat<T>(xss: T[][]): T[] {
|
||||||
return [].concat(...xs.map(x => [sep, x])).slice(1);
|
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 a new issue