How to use the wikidata-sdk.isWikidataEntityId function in wikidata-sdk

To help you get started, we’ve selected a few wikidata-sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github larsgw / citation.js / src / wikidata.Citation-0.1.js View on Github external
var handleInput = function ( input, lang ) {
  
  console.log( 'Entering Wikidata module...' )
  
  var call = 'getEntities'
    , result
  
  if ( Array.isArray( input ) && wdk.isWikidataEntityId( input[ 0 ] ) ) {
    if ( input.length >= 50 )
      call = 'getManyEntities'
  } else if ( typeof input === 'string' && wdk.isWikidataEntityId( input ) ) {
    input = [ input ]
  }
  
  var url = wdk[ call ]( {
    ids: input,
    languages: [ lang ]
  } )
  
  if ( Array.isArray( url ) ) {
    var urls = url
      , outs = []
    
    for ( var urlIndex = 0; urlIndex < urls.length; urlIndex++ ) {
      var url = urls[ urlIndex ]
        , out = getOutput( url, lang )
          outs= outs.concat( out )
github larsgw / citation.js / src / wikidata.Citation-0.1.js View on Github external
var handleInput = function ( input, lang ) {
  
  console.log( 'Entering Wikidata module...' )
  
  var call = 'getEntities'
    , result
  
  if ( Array.isArray( input ) && wdk.isWikidataEntityId( input[ 0 ] ) ) {
    if ( input.length >= 50 )
      call = 'getManyEntities'
  } else if ( typeof input === 'string' && wdk.isWikidataEntityId( input ) ) {
    input = [ input ]
  }
  
  var url = wdk[ call ]( {
    ids: input,
    languages: [ lang ]
  } )
  
  if ( Array.isArray( url ) ) {
    var urls = url
      , outs = []
    
    for ( var urlIndex = 0; urlIndex < urls.length; urlIndex++ ) {