Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit a3d45b8b
authored
Jul 01, 2015
by
Daniel Friesen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change method to abort customization of plain objects/arrays first
1 parent
3d316493
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
7 deletions
lib/utils.js
lib/utils.js
View file @
a3d45b8
...
@@ -95,16 +95,14 @@ var Utils = module.exports = {
...
@@ -95,16 +95,14 @@ var Utils = module.exports = {
},
},
cloneDeep
:
function
(
obj
,
fn
)
{
cloneDeep
:
function
(
obj
,
fn
)
{
return
lodash
.
cloneDeep
(
obj
,
function
(
elem
)
{
return
lodash
.
cloneDeep
(
obj
,
function
(
elem
)
{
// Do not try to customize cloning of plain objects and strings
if
(
Array
.
isArray
(
elem
)
||
lodash
.
isPlainObject
(
elem
))
{
return
undefined
;
}
// Preserve special data-types like `fn` across clones. _.get() is used for checking up the prototype chain
// Preserve special data-types like `fn` across clones. _.get() is used for checking up the prototype chain
if
(
elem
)
{
if
(
elem
&&
typeof
elem
.
clone
===
'function'
)
{
// Allow objects to implement their own clone method
if
(
typeof
elem
.
clone
===
'function'
)
{
// However do not mistakenly call clone methods on arrays and plain objects
if
(
!
Array
.
isArray
(
elem
)
&&
!
lodash
.
isPlainObject
(
elem
))
{
return
elem
.
clone
();
return
elem
.
clone
();
}
}
}
}
// Unfortunately, lodash.cloneDeep doesn't preserve Buffer.isBuffer, which we have to rely on for binary data
// Unfortunately, lodash.cloneDeep doesn't preserve Buffer.isBuffer, which we have to rely on for binary data
if
(
Buffer
.
isBuffer
(
elem
))
{
return
elem
;
}
if
(
Buffer
.
isBuffer
(
elem
))
{
return
elem
;
}
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment