Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
variety
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-gitdep
variety
Commits
4422ab1c
Commit
4422ab1c
authored
Sep 19, 2014
by
Tomas Dvorak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for #42: unnamed inside objects analysed correctly
parent
ec698098
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
1 deletions
+6
-1
variety.js
variety.js
+6
-1
No files found.
variety.js
View file @
4422ab1c
...
...
@@ -107,13 +107,14 @@ function serializeDoc(doc, maxDepth){
var
result
=
{};
//determining if an object is a Hash vs Array vs something else is hard
//returns true, if object in argument may have nested objects and makes sense to analyse its content
function
isHash
(
v
)
{
var
isArray
=
Array
.
isArray
(
v
);
var
isObject
=
typeof
v
===
'object'
;
var
specialObject
=
v
instanceof
Date
||
v
instanceof
ObjectId
||
v
instanceof
BinData
;
return
!
specialObject
&&
!
isArray
&&
isObject
;
return
!
specialObject
&&
(
isArray
||
isObject
)
;
}
function
serialize
(
document
,
parentKey
,
maxDepth
){
...
...
@@ -144,6 +145,10 @@ db[collection].find(query).sort(sort).limit(limit).forEach(function(obj) {
//printjson(flattened)
for
(
var
key
in
flattened
){
var
value
=
flattened
[
key
];
//translate unnamed object key from {_parent_name_}.{_index_} to {_parent_name_}.XX
key
=
key
.
replace
(
/
\.\d
+/g
,
'.XX'
);
var
valueType
=
varietyTypeOf
(
value
);
if
(
!
(
key
in
interimResults
)){
//if it's a new key we haven't seen yet
//for the moment, store 'types' as a dictionary. An easy way to prevent duplicates
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment