Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* make room for post processing query * first very ugly cut at field detection * translate date fields to unix time for esri * update docs * remove stray comment * remove console log
- Loading branch information
Daniel Fenton
committed
Jun 15, 2017
1 parent
6f47f01
commit e3004ce
Showing
11 changed files
with
282 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
const moment = require('moment') | ||
const DATE_FORMATS = [moment.ISO_8601] | ||
|
||
module.exports = function (properties) { | ||
return Object.keys(properties).map(name => { | ||
return { | ||
name, | ||
type: detectType(properties[name]) | ||
} | ||
}) | ||
} | ||
|
||
function detectType (value) { | ||
var type = typeof value | ||
|
||
if (type === 'number') { | ||
return isInt(value) ? 'Integer' : 'Double' | ||
} else if (type && moment(value, DATE_FORMATS, true).isValid()) { | ||
return 'Date' | ||
} else { | ||
return 'String' | ||
} | ||
} | ||
|
||
function isInt (value) { | ||
return Math.round(value) === value | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.