changeset 1792:a07bfbe1e9de

make graph sortKey public Ignore-this: f4c5a41044eb864d71a4ccb409de3c88
author Drew Perttula <drewp@bigasterisk.com>
date Thu, 07 Jun 2018 23:03:32 +0000
parents 6cdbc76d1cd5
children bf3b8f7a334e
files light9/web/graph.coffee
diffstat 1 files changed, 11 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/light9/web/graph.coffee	Thu Jun 07 17:51:56 2018 +0000
+++ b/light9/web/graph.coffee	Thu Jun 07 23:03:32 2018 +0000
@@ -372,6 +372,8 @@
 
   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 = []
 
@@ -400,14 +402,16 @@
       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) ->