wd-type-parser

0.0.3 • Public • Published

Build Status

wd-type-parser

Given a value object as returned from Wikidata Query Service, returns a simplified value

wtp = require('wd-type-parser');
 
= { type:'uri', value:'http://www.wikidata.org/entity/Q12345' };
wtp(o); // 'Q12345'
 
= { type:'literal', datatype:'http://www.opengis.net/ont/geosparql#wktLiteral', value:'Point(-64.2 -36.62)' };
wtp(o); // [-64.2, -36.62]
 
= { type:'literal', datatype:'http://www.w3.org/2001/XMLSchema#integer', value:'42' };
wtp(o); // 42
 
// Unrecognized value
= { type:'some type', datatype:'some unknown datatype', value:'la la la' };
wtp(o);       // 'la la la'
wtp(o, true); // undefined
 

Package Sidebar

Install

npm i wd-type-parser

Weekly Downloads

25

Version

0.0.3

License

MIT

Last publish

Collaborators

  • nyurik