芝麻web文件管理V1.00
编辑当前文件:/home/freeclou/app.optimyar.com/backend/node_modules/draft-js/lib/insertIntoList.js.flow
/** * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @format * @flow strict-local * @emails oncall+draft_js */ 'use strict'; import type { List } from "immutable"; /** * Maintain persistence for target list when appending and prepending. */ function insertIntoList
(targetListArg: List
, toInsert: List
, offset: number): List
{ let targetList = targetListArg; if (offset === targetList.count()) { toInsert.forEach(c => { targetList = targetList.push(c); }); } else if (offset === 0) { toInsert.reverse().forEach(c => { targetList = targetList.unshift(c); }); } else { const head = targetList.slice(0, offset); const tail = targetList.slice(offset); targetList = head.concat(toInsert, tail).toList(); } return targetList; } module.exports = insertIntoList;