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
c465b9c7
Commit
c465b9c7
authored
Mar 07, 2015
by
James Cropcho
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #82 from variety/upgrade-jshintrc
more strict JSHinting
parents
ad7c0629
507707a7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
13 deletions
+35
-13
.jshintrc
.jshintrc
+27
-2
variety.js
variety.js
+8
-11
No files found.
.jshintrc
View file @
c465b9c7
{
"camelcase": false,
"sub": true
"bitwise": true,
"curly": true,
"eqeqeq": true,
"freeze": true,
"globals": {
"__quiet": false,
"collection": false,
"print": false,
"db": false,
"tojson": false,
"ObjectId": false,
"BinData": false,
"DBQuery": false,
"printjson": false,
"query": true,
"limit": true,
"maxDepth": true,
"sort": true,
"outputFormat": true,
"persistResults": true
},
"latedef": true,
"singleGroups": true,
"strict": true,
"undef": true,
"unused": true
}
variety.js
View file @
c465b9c7
...
...
@@ -23,10 +23,6 @@ log('Version 1.4.1, released 14 Oct 2014');
var
dbs
=
[];
var
emptyDbs
=
[];
if
(
typeof
db_name
===
'string'
)
{
db
=
db
.
getMongo
().
getDB
(
db_name
);
}
var
knownDatabases
=
db
.
adminCommand
(
'listDatabases'
).
databases
;
if
(
typeof
knownDatabases
!==
'undefined'
)
{
// not authorized user receives error response (json) without databases key
knownDatabases
.
forEach
(
function
(
d
){
...
...
@@ -111,7 +107,8 @@ var varietyTypeOf = function(thing) {
if
(
typeof
thing
!==
'object'
)
{
// the messiness below capitalizes the first letter, so the output matches
// the other return values below. -JC
return
(
typeof
thing
)[
0
].
toUpperCase
()
+
(
typeof
thing
).
slice
(
1
);
var
typeofThing
=
typeof
thing
;
// edgecase of JSHint's "singleGroups"
return
typeofThing
[
0
].
toUpperCase
()
+
typeofThing
.
slice
(
1
);
}
else
{
if
(
thing
&&
thing
.
constructor
===
Array
)
{
...
...
@@ -160,7 +157,7 @@ var serializeDoc = function(doc, maxDepth) {
function
serialize
(
document
,
parentKey
,
maxDepth
){
for
(
var
key
in
document
){
//skip over inherited properties such as string, length, etch
if
(
!
(
document
.
hasOwnProperty
(
key
)
))
{
if
(
!
document
.
hasOwnProperty
(
key
))
{
continue
;
}
var
value
=
document
[
key
];
...
...
@@ -168,7 +165,7 @@ var serializeDoc = function(doc, maxDepth) {
//if(typeof value != 'object')
result
[
parentKey
+
key
]
=
value
;
//it's an object, recurse...only if we haven't reached max depth
if
(
isHash
(
value
)
&&
(
maxDepth
>
1
)
)
{
if
(
isHash
(
value
)
&&
maxDepth
>
1
)
{
serialize
(
value
,
parentKey
+
key
+
'.'
,
maxDepth
-
1
);
}
}
...
...
@@ -222,8 +219,8 @@ var convertResults = function(interimResults, documentsCount) {
varietyResults
.
push
({
'_id'
:
{
'key'
:
key
},
'value'
:
{
'types'
:
getKeys
(
entry
.
types
)},
'totalOccurrences'
:
entry
[
'totalOccurrences'
]
,
'percentContaining'
:
entry
[
'totalOccurrences'
]
*
100
/
documentsCount
'totalOccurrences'
:
entry
.
totalOccurrences
,
'percentContaining'
:
entry
.
totalOccurrences
*
100
/
documentsCount
});
}
return
varietyResults
;
...
...
@@ -285,11 +282,11 @@ if($outputFormat === 'json') {
return
Math
.
max
.
apply
(
null
,
arr
.
map
(
function
(
row
){
return
row
[
index
].
toString
().
length
;}));
};
var
pad
=
function
(
width
,
string
,
symbol
)
{
return
(
width
<=
string
.
length
)
?
string
:
pad
(
width
,
string
+
symbol
,
symbol
);
};
var
pad
=
function
(
width
,
string
,
symbol
)
{
return
width
<=
string
.
length
?
string
:
pad
(
width
,
string
+
symbol
,
symbol
);
};
var
output
=
''
;
table
.
forEach
(
function
(
row
,
ri
){
output
+=
(
'| '
+
row
.
map
(
function
(
cell
,
i
)
{
return
pad
(
colMaxWidth
(
table
,
i
),
cell
,
ri
==
1
?
'-'
:
' '
);}).
join
(
' | '
)
+
' |
\
n'
)
;
output
+=
'| '
+
row
.
map
(
function
(
cell
,
i
)
{
return
pad
(
colMaxWidth
(
table
,
i
),
cell
,
ri
===
1
?
'-'
:
' '
);}).
join
(
' | '
)
+
' |
\
n'
;
});
var
lineLength
=
output
.
split
(
'
\
n'
)[
0
].
length
-
2
;
// length of first (header) line minus two chars for edges
var
border
=
'+'
+
pad
(
lineLength
,
''
,
'-'
)
+
'+'
;
...
...
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