@vtmap/vtmap-sdk-js
Version:
JS SDK for accessing Viettelmaps APIs
50 lines (43 loc) • 1.1 kB
JavaScript
;
var xtend = require('xtend');
var v = require('@mapbox/fusspot');
function file(value) {
// If we're in a browser so Blob is available, the file must be that.
// In Node, however, it could be a filepath or a pipeable (Readable) stream.
if (typeof window !== 'undefined') {
if (value instanceof global.Blob || value instanceof global.ArrayBuffer) {
return;
}
return 'Blob or ArrayBuffer';
}
if (typeof value === 'string' || value.pipe !== undefined) {
return;
}
return 'Filename or Readable stream';
}
function assertShape(validatorObj, apiName) {
return v.assert(v.strictShape(validatorObj), apiName);
}
function date(value) {
var msg = 'date';
if (typeof value === 'boolean') {
return msg;
}
try {
var date = new Date(value);
if (date.getTime && isNaN(date.getTime())) {
return msg;
}
} catch (e) {
return msg;
}
}
function coordinates(value) {
return v.tuple(v.number, v.number)(value);
}
module.exports = xtend(v, {
file: file,
date: date,
coordinates: coordinates,
assertShape: assertShape
});