From e8948452fdc18f8a85af34bc4687e304cd39c987 Mon Sep 17 00:00:00 2001 From: Aya Morisawa Date: Thu, 6 Sep 2018 02:28:04 +0900 Subject: [PATCH] Resolve #2629 (#2630) --- src/mfm/html.ts | 5 +---- src/prelude/array.ts | 4 ++++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/mfm/html.ts b/src/mfm/html.ts index 2e38fe10a0..b7fa5b6f03 100644 --- a/src/mfm/html.ts +++ b/src/mfm/html.ts @@ -4,10 +4,7 @@ const { JSDOM } = jsdom; import config from '../config'; import { INote } from '../models/note'; import { TextElement } from './parse'; - -function intersperse(sep: T, xs: T[]): T[] { - return [].concat(...xs.map(x => [sep, x])).slice(1); -} +import { intersperse } from '../prelude/array'; const handlers: { [key: string]: (window: any, token: any, mentionedRemoteUsers: INote['mentionedRemoteUsers']) => void } = { bold({ document }, { bold }) { diff --git a/src/prelude/array.ts b/src/prelude/array.ts index e944030a7f..aee17640ed 100644 --- a/src/prelude/array.ts +++ b/src/prelude/array.ts @@ -5,3 +5,7 @@ export function countIf(f: (x: T) => boolean, xs: T[]): number { export function count(x: T, xs: T[]): number { return countIf(y => x === y, xs); } + +export function intersperse(sep: T, xs: T[]): T[] { + return [].concat(...xs.map(x => [sep, x])).slice(1); +}