Changeset - a07bfbe1e9de
[Not reviewed]
default
0 1 0
Drew Perttula - 7 years ago 2018-06-07 23:03:32
drewp@bigasterisk.com
make graph sortKey public
Ignore-this: f4c5a41044eb864d71a4ccb409de3c88
1 file changed with 11 insertions and 7 deletions:
0 comments (0 inline, 0 general)
light9/web/graph.coffee
Show inline comments
 
@@ -369,12 +369,14 @@ class window.SyncedGraph
 
  contains: (s, p, o) ->
 
    @_autoDeps.askedFor(s, p, o, null)
 
    return @graph.getQuads(s, p, o).length > 0
 

	
 
  nextNumberedResources: (base, howMany) ->
 
    # base is NamedNode or string
 
    # Note this is unsafe before we're synced with the graph. It'll
 
    # always return 'name0'.
 
    base = base.id if base.id
 
    results = []
 

	
 
    # @contains is really slow.
 
    @_nextNumber = new Map() unless @_nextNumber?
 
    start = @_nextNumber.get(base)
 
@@ -397,20 +399,22 @@ class window.SyncedGraph
 
    @_autoDeps.askedFor(s, p, o, null)
 
    ctxs = []
 
    for q in @graph.getQuads(s, p, o)
 
      ctxs.push(q.graph)
 
    return _.unique(ctxs)
 

	
 
  sortKey: (uri) ->
 
    parts = uri.value.split(/([0-9]+)/)
 
    expanded = parts.map (p) ->
 
      f = parseInt(p)
 
      return p if isNaN(f)
 
      return p.padStart(8, '0')
 
    return expanded.join('')
 

	
 
  sortedUris: (uris) ->
 
    _.sortBy uris, (u) ->
 
      parts = u.value.split(/([0-9]+)/)
 
      expanded = parts.map (p) ->
 
        f = parseInt(p)
 
        return p if isNaN(f)
 
        return p.padStart(8, '0')
 
      return expanded.join('')
 
    _.sortBy uris, @sortKey
 

	
 
  # temporary optimization since autodeps calls too often
 
  @patchContainsPreds: (patch, preds) ->
 
    patchContainsPreds(patch, preds)
 

	
 
  prettyLiteral: (x) ->
0 comments (0 inline, 0 general)