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
45d26e73
Commit
45d26e73
authored
May 25, 2012
by
James Cropcho
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
capitalizing types
parent
3693bc46
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
13 deletions
+15
-13
README.markdown
README.markdown
+7
-7
variety.js
variety.js
+8
-6
No files found.
README.markdown
View file @
45d26e73
...
@@ -15,13 +15,13 @@ So, let's see what we've got here:
...
@@ -15,13 +15,13 @@ So, let's see what we've got here:
$ mongo test --eval "var collection = 'users'" variety.js
$ mongo test --eval "var collection = 'users'" variety.js
{ "_id" : { "key" : "_id" }, "value" : { "types" : [ "
o
bjectId" ] }, "totalOccurrences" : 5, "percentContaining" : 100 }
{ "_id" : { "key" : "_id" }, "value" : { "types" : [ "
O
bjectId" ] }, "totalOccurrences" : 5, "percentContaining" : 100 }
{ "_id" : { "key" : "name" }, "value" : { "types" : [ "
s
tring" ] }, "totalOccurrences" : 5, "percentContaining" : 100 }
{ "_id" : { "key" : "name" }, "value" : { "types" : [ "
S
tring" ] }, "totalOccurrences" : 5, "percentContaining" : 100 }
{ "_id" : { "key" : "bio" }, "value" : { "types" : [ "
s
tring" ] }, "totalOccurrences" : 3, "percentContaining" : 60 }
{ "_id" : { "key" : "bio" }, "value" : { "types" : [ "
S
tring" ] }, "totalOccurrences" : 3, "percentContaining" : 60 }
{ "_id" : { "key" : "birthday" }, "value" : { "types" : [ "
d
ate" ] }, "totalOccurrences" : 2, "percentContaining" : 40 }
{ "_id" : { "key" : "birthday" }, "value" : { "types" : [ "
D
ate" ] }, "totalOccurrences" : 2, "percentContaining" : 40 }
{ "_id" : { "key" : "pets" }, "value" : { "types" : [ "
string", "a
rray" ] }, "totalOccurrences" : 2, "percentContaining" : 40 }
{ "_id" : { "key" : "pets" }, "value" : { "types" : [ "
String", "A
rray" ] }, "totalOccurrences" : 2, "percentContaining" : 40 }
{ "_id" : { "key" : "someBinData" }, "value" : { "type" : "
b
inData" }, "totalOccurrences" : 1, "percentContaining" : 20 }
{ "_id" : { "key" : "someBinData" }, "value" : { "type" : "
B
inData" }, "totalOccurrences" : 1, "percentContaining" : 20 }
{ "_id" : { "key" : "someWeirdLegacyKey" }, "value" : { "type" : "
s
tring" }, "totalOccurrences" : 1, "percentContaining" : 20 }
{ "_id" : { "key" : "someWeirdLegacyKey" }, "value" : { "type" : "
S
tring" }, "totalOccurrences" : 1, "percentContaining" : 20 }
_("test" is the database containing the collection we are analyzing.)_
_("test" is the database containing the collection we are analyzing.)_
...
...
variety.js
View file @
45d26e73
...
@@ -51,26 +51,28 @@ varietyTypeOf = function(thing) {
...
@@ -51,26 +51,28 @@ varietyTypeOf = function(thing) {
if
(
typeof
thing
===
"undefined"
)
{
throw
"varietyTypeOf() requires an argument"
;
}
if
(
typeof
thing
===
"undefined"
)
{
throw
"varietyTypeOf() requires an argument"
;
}
if
(
typeof
thing
!==
"object"
)
{
if
(
typeof
thing
!==
"object"
)
{
return
typeof
thing
;
// 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
);
}
}
else
{
else
{
if
(
thing
&&
thing
.
constructor
===
Array
)
{
if
(
thing
&&
thing
.
constructor
===
Array
)
{
return
"
a
rray"
;
return
"
A
rray"
;
}
}
else
if
(
thing
===
null
)
{
else
if
(
thing
===
null
)
{
return
"null"
;
return
"null"
;
}
}
else
if
(
thing
instanceof
Date
)
{
else
if
(
thing
instanceof
Date
)
{
return
"
d
ate"
;
return
"
D
ate"
;
}
}
else
if
(
thing
instanceof
ObjectId
)
{
else
if
(
thing
instanceof
ObjectId
)
{
return
"
o
bjectId"
;
return
"
O
bjectId"
;
}
}
else
if
(
thing
instanceof
BinData
)
{
else
if
(
thing
instanceof
BinData
)
{
return
"
b
inData"
;
return
"
B
inData"
;
}
}
else
{
else
{
return
"
o
bject"
;
return
"
O
bject"
;
}
}
}
}
}
}
...
...
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