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