packages/extension-map/doc/webpacks/shexmap-webapp.js
/* LoadPromise - load shex and json files into a single Schema and turtle into
   * a graph (Data).
   */
load shex and json files into a single Schema and turtle into
a graph (Data).
load shex and json files into a single Schema and turtle into a graph ( Data ) .
async function LoadPromise (shex, json, turtle, jsonld, schemaOptions = {}, dataOptions = {}) {
    const returns = {
      schema: ShExUtil.emptySchema(),
      data: config.rdfjs ? new config.rdfjs.Store() : null,
      schemaMeta: [],
      dataMeta: []
    }
    const promises = []
    const schemasSeen = shex.concat(json).map(p => {
      return typeof p === "object" ? p.url : p
    })
    let transform = null
    if (schemaOptions && "iriTransform" in schemaOptions) {
      transform = schemaOptions.iriTransform
      delete schemaOptions.iriTransform
    }
    const allLoaded = DynamicPromise()
    function loadImports (schema) {
      if (!("imports" in schema))
        return schema
      if (schemaOptions.keepImports) {
        return schema
      }
      const ret = Object.assign({}, schema)
      const imports = ret.imports
      delete ret.imports
      schema.imports.map(function (i) {
        return transform ? transform(i) : i
      }).filter(function (i) {
        return schemasSeen.indexOf(i) === -1
      }).map(i => {
        schemasSeen.push(i)
        allLoaded.add(api.GET(i).then(function (loaded) {
          const meta = {
            url: loaded.url,
            base: loaded.url,
            prefixes: {}
          }
          return parseShExC(loaded.text, "text/shex", loaded.url,
                            returns.schema, meta, schemaOptions, loadImports)
        })); 
      })
      return ret
    }
    [].push.apply(promises, [
      loadList(shex, returns.schemaMeta, "text/shex",
               parseShExC, returns.schema, schemaOptions, loadImports),
      loadList(json, returns.schemaMeta, "text/json",
               parseShExJ, returns.schema, schemaOptions, loadImports),
      loadList(turtle, returns.dataMeta, "text/turtle",
               parseTurtle, returns.data, dataOptions),
      loadList(jsonld, returns.dataMeta, "application/ld+json",
               parseJSONLD, returns.data, dataOptions)
    ].reduce((acc, l) => acc.concat(l), [])) 
    return allLoaded.all(promises).then(function (resources) {
      if (returns.schemaMeta.length > 0)
        ShExUtil.isWellDefined(returns.schema)
      return returns
    })
  }
async function LoadPromise ( shex , json , turtle , jsonld , schemaOptions = { } , dataOptions = { } ) { const returns = { schema : ShExUtil . emptySchema ( ) , data : config . rdfjs ? new config . rdfjs . Store ( ) : null , schemaMeta : [ ] , dataMeta : [ ] } const promises = [ ] const schemasSeen = shex . concat ( json ) . map ( p => { return typeof p === "object" ? p . url : p } ) let transform = null if ( schemaOptions && "iriTransform" in schemaOptions ) { transform = schemaOptions . iriTransform delete schemaOptions . iriTransform } const allLoaded = DynamicPromise ( ) function loadImports ( schema ) { if ( ! ( "imports" in schema ) ) return schema if ( schemaOptions . keepImports ) { return schema } const ret = Object . assign ( { } , schema ) const imports = ret . imports delete ret . imports schema . imports . map ( function ( i ) { return transform ? transform ( i ) : i } ) . filter ( function ( i ) { return schemasSeen . indexOf ( i ) === - 1 } ) . map ( i => { schemasSeen . push ( i ) allLoaded . add ( api . GET ( i ) . then ( function ( loaded ) { const meta = { url : loaded . url , base : loaded . url , prefixes : { } } return parseShExC ( loaded . text , "text/shex" , loaded . url , returns . schema , meta , schemaOptions , loadImports ) } ) ) ; } ) return ret } [ ] . push . apply ( promises , [ loadList ( shex , returns . schemaMeta , "text/shex" , parseShExC , returns . schema , schemaOptions , loadImports ) , loadList ( json , returns . schemaMeta , "text/json" , parseShExJ , returns . schema , schemaOptions , loadImports ) , loadList ( turtle , returns . dataMeta , "text/turtle" , parseTurtle , returns . data , dataOptions ) , loadList ( jsonld , returns . dataMeta , "application/ld+json" , parseJSONLD , returns . data , dataOptions ) ] . reduce ( ( acc , l ) => acc . concat ( l ) , [ ] ) ) return allLoaded . all ( promises ) . then ( function ( resources ) { if ( returns . schemaMeta . length > 0 ) ShExUtil . isWellDefined ( returns . schema ) return returns } ) }
LoadPromise - load shex and json files into a single Schema and turtle into
 a graph (Data).
LoadPromise - load shex and json files into a single Schema and turtle into a graph ( Data ) .
// might be already loaded objects with a url property. // mediaType: mediaType, // metaList.push(meta) // addAfter would be after invoking schema. // gather all the potentially remote inputs // .flat() in node > 8.x