main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
1.0 KB
|
Rev | Line | |
---|
[d565449] | 1 | import baseRest from './_baseRest.js';
|
---|
| 2 | import isIterateeCall from './_isIterateeCall.js';
|
---|
| 3 |
|
---|
| 4 | /**
|
---|
| 5 | * Creates a function like `_.assign`.
|
---|
| 6 | *
|
---|
| 7 | * @private
|
---|
| 8 | * @param {Function} assigner The function to assign values.
|
---|
| 9 | * @returns {Function} Returns the new assigner function.
|
---|
| 10 | */
|
---|
| 11 | function createAssigner(assigner) {
|
---|
| 12 | return baseRest(function(object, sources) {
|
---|
| 13 | var index = -1,
|
---|
| 14 | length = sources.length,
|
---|
| 15 | customizer = length > 1 ? sources[length - 1] : undefined,
|
---|
| 16 | guard = length > 2 ? sources[2] : undefined;
|
---|
| 17 |
|
---|
| 18 | customizer = (assigner.length > 3 && typeof customizer == 'function')
|
---|
| 19 | ? (length--, customizer)
|
---|
| 20 | : undefined;
|
---|
| 21 |
|
---|
| 22 | if (guard && isIterateeCall(sources[0], sources[1], guard)) {
|
---|
| 23 | customizer = length < 3 ? undefined : customizer;
|
---|
| 24 | length = 1;
|
---|
| 25 | }
|
---|
| 26 | object = Object(object);
|
---|
| 27 | while (++index < length) {
|
---|
| 28 | var source = sources[index];
|
---|
| 29 | if (source) {
|
---|
| 30 | assigner(object, source, index, customizer);
|
---|
| 31 | }
|
---|
| 32 | }
|
---|
| 33 | return object;
|
---|
| 34 | });
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 | export default createAssigner;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.