芝麻web文件管理V1.00
编辑当前文件:/home/freeclou/app.optimyar.com/backend/node_modules/draft-js/lib/insertIntoList.js
/** * 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 * * @emails oncall+draft_js */ 'use strict'; /** * Maintain persistence for target list when appending and prepending. */ function insertIntoList(targetListArg, toInsert, offset) { var targetList = targetListArg; if (offset === targetList.count()) { toInsert.forEach(function (c) { targetList = targetList.push(c); }); } else if (offset === 0) { toInsert.reverse().forEach(function (c) { targetList = targetList.unshift(c); }); } else { var head = targetList.slice(0, offset); var tail = targetList.slice(offset); targetList = head.concat(toInsert, tail).toList(); } return targetList; } module.exports = insertIntoList;