source: node_modules/ramda/es/insertAll.js

main
Last change on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 1005 bytes
RevLine 
[d24f17c]1import _curry3 from "./internal/_curry3.js";
2/**
3 * Inserts the sub-list into the list, at the specified `index`. _Note that this is not
4 * destructive_: it returns a copy of the list with the changes.
5 * <small>No lists have been harmed in the application of this function.</small>
6 *
7 * @func
8 * @memberOf R
9 * @since v0.9.0
10 * @category List
11 * @sig Number -> [a] -> [a] -> [a]
12 * @param {Number} index The position to insert the sub-list
13 * @param {Array} elts The sub-list to insert into the Array
14 * @param {Array} list The list to insert the sub-list into
15 * @return {Array} A new Array with `elts` inserted starting at `index`.
16 * @example
17 *
18 * R.insertAll(2, ['x','y','z'], [1,2,3,4]); //=> [1,2,'x','y','z',3,4]
19 */
20
21var insertAll =
22/*#__PURE__*/
23_curry3(function insertAll(idx, elts, list) {
24 idx = idx < list.length && idx >= 0 ? idx : list.length;
25 return [].concat(Array.prototype.slice.call(list, 0, idx), elts, Array.prototype.slice.call(list, idx));
26});
27
28export default insertAll;
Note: See TracBrowser for help on using the repository browser.