nuǝɯ pǝɥsᴉꞁod mǝu
Have opinions about JavaScript? We want to hear them. Take the 2018 JavaScript Ecosystem Survey »

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
 

install

npm i wd-type-parser

Downloadsweekly downloads

23

version

0.0.3

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability