Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Monster
Manage
Activity
Members
Plan
Jira
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
OSS
Libraries
Javascript
Monster
Commits
69718fe7
Verified
Commit
69718fe7
authored
1 year ago
by
Volker Schukai
Browse files
Options
Downloads
Patches
Plain Diff
fix: reset config #136
parent
d94697cf
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/data/extend.mjs
+56
-47
56 additions, 47 deletions
source/data/extend.mjs
with
56 additions
and
47 deletions
source/data/extend.mjs
+
56
−
47
View file @
69718fe7
...
@@ -5,17 +5,15 @@
...
@@ -5,17 +5,15 @@
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
* License text available at https://www.gnu.org/licenses/agpl-3.0.en.html
*/
*/
import
{
isArray
,
isObject
}
from
"
../types/is.mjs
"
;
import
{
isArray
,
isObject
}
from
"
../types/is.mjs
"
;
import
{
typeOf
}
from
"
../types/typeof.mjs
"
;
import
{
typeOf
}
from
"
../types/typeof.mjs
"
;
export
{
extend
};
export
{
extend
};
/**
/**
* Extend copies all enumerable own properties from one or
* Extend copies all enumerable own properties from one or
* more source objects to a target object. It returns the modified target object.
* more source objects to a target object. It returns the modified target object.
*
*
* @param {object} target
* @param {object}
* @return {object}
* @return {object}
* @license AGPLv3
* @license AGPLv3
* @since 1.10.0
* @since 1.10.0
...
@@ -24,57 +22,68 @@ export { extend };
...
@@ -24,57 +22,68 @@ export { extend };
* @throws {Error} unsupported argument
* @throws {Error} unsupported argument
* @throws {Error} type mismatch
* @throws {Error} type mismatch
* @throws {Error} unsupported argument
* @throws {Error} unsupported argument
* @param args
*/
*/
function
extend
(...
args
)
{
function
extend
(...
args
)
{
let
o
;
let
o
;
let
i
;
let
i
;
if
(
typeof
args
!==
"
object
"
||
args
[
0
]
===
null
)
{
if
(
typeof
args
!==
"
object
"
||
args
[
0
]
===
null
)
{
throw
new
Error
(
`unsupported argument
${
JSON
.
stringify
(
args
[
0
])}
`
);
throw
new
Error
(
`unsupported argument
${
JSON
.
stringify
(
args
[
0
])}
`
);
}
}
for
(
i
=
0
;
i
<
args
.
length
;
i
++
)
{
for
(
i
=
0
;
i
<
args
.
length
;
i
++
)
{
const
a
=
args
[
i
];
const
a
=
args
[
i
];
if
(
!
(
isObject
(
a
)
||
isArray
(
a
)))
{
if
(
!
(
isObject
(
a
)
||
isArray
(
a
)))
{
throw
new
Error
(
`unsupported argument
${
JSON
.
stringify
(
a
)}
`
);
throw
new
Error
(
`unsupported argument
${
JSON
.
stringify
(
a
)}
`
);
}
}
if
(
o
===
undefined
)
{
if
(
o
===
undefined
)
{
o
=
a
;
o
=
a
;
continue
;
continue
;
}
}
for
(
const
k
in
a
)
{
for
(
const
k
in
a
)
{
const
v
=
a
?.[
k
];
const
v
=
a
?.[
k
];
if
(
v
===
o
?.[
k
])
{
if
(
v
===
o
?.[
k
])
{
continue
;
continue
;
}
}
if
((
isObject
(
v
)
&&
typeOf
(
v
)
===
"
object
"
)
||
isArray
(
v
))
{
if
((
isObject
(
v
)
&&
typeOf
(
v
)
===
"
object
"
)
||
isArray
(
v
))
{
if
(
o
[
k
]
===
undefined
)
{
if
(
o
[
k
]
===
undefined
)
{
if
(
isArray
(
v
))
{
if
(
isArray
(
v
))
{
o
[
k
]
=
[];
o
[
k
]
=
[];
}
else
{
}
else
{
o
[
k
]
=
{};
o
[
k
]
=
{};
}
}
}
else
{
}
else
{
if
(
typeOf
(
o
[
k
])
!==
typeOf
(
v
))
{
if
(
typeOf
(
o
[
k
])
!==
typeOf
(
v
))
{
throw
new
Error
(
throw
new
Error
(
`type mismatch:
${
JSON
.
stringify
(
o
[
k
])}
(
${
typeOf
(
`type mismatch:
${
JSON
.
stringify
(
o
[
k
])}
(
${
typeOf
(
o
[
k
],
o
[
k
],
)}
) !=
${
JSON
.
stringify
(
v
)}
(
${
typeOf
(
v
)}
)`
,
)}
) !=
${
JSON
.
stringify
(
v
)}
(
${
typeOf
(
v
)}
)`
,
);
);
}
}
}
}
if
(
isArray
(
o
[
k
]))
{
o
[
k
]
=
[];
o
[
k
].
push
(...
v
);
continue
;
}
o
[
k
]
=
extend
(
o
[
k
],
v
);
o
[
k
]
=
extend
(
o
[
k
],
v
);
}
else
{
}
else
{
o
[
k
]
=
v
;
if
(
isArray
(
o
))
{
}
o
.
push
(
v
);
}
continue
;
}
}
o
[
k
]
=
v
;
}
}
}
return
o
;
return
o
;
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment