import is from "is" ; import removeArticle from "./removeArticle" ; import insertArticle from "./insertArticle" ; param { Summary } summary param { String | SummaryArticle } origin param { String | SummaryArticle } target return { Summary } function moveArticle ( summary , origin , target ) { const originLevel = is . string ( origin ) ? origin : origin . getLevel ( ) ; const targetLevel = is . string ( target ) ? target : target . getLevel ( ) ; const article = summary . getByLevel ( originLevel ) ; const removed = removeArticle ( summary , originLevel ) ; return insertArticle ( removed , article , targetLevel ) ; } export default moveArticle ;