@@ -20,44 +20,47 @@ function WOQLResult(results, query, config) {
2020 //console.log(results, this.variable_names)
2121 this . query = query ? query : WOQL . query ( )
2222 this . cursor = 0
23- if ( ! ( config && config . no_compress ) ) {
24- const context = config && config . context ? config . context : false
25- this . compress ( context )
26- }
23+ // if (!(config && config.no_compress)) {
24+ // const context = results && results.prefixes ? results.prefixes : false
25+ // this.compress(context)
26+ // }
2727}
2828
2929/**
3030 * @param {Object } [context] optional context to use for compression - if ommitted query context is used
3131 */
3232WOQLResult . prototype . compress = function ( context ) {
3333 context = context || this . query . getContext ( )
34- for ( let i = 0 ; i < this . bindings . length ; i ++ ) {
35- for ( const prop of Object . keys ( this . bindings [ i ] ) ) {
36- const nprop = UTILS . shorten ( prop , context )
37- var nval = this . bindings [ i ] [ prop ]
38- if ( typeof this . bindings [ i ] [ prop ] == 'string' ) {
39- nval = UTILS . shorten ( this . bindings [ i ] [ prop ] , context )
40- } else if ( Array . isArray ( this . bindings [ i ] [ prop ] ) ) {
41- nval = [ ]
42- for ( var j = 0 ; j < this . bindings [ i ] [ prop ] . length ; j ++ ) {
43- let oval = this . bindings [ i ] [ prop ] [ j ]
44- if ( typeof oval == 'string' ) oval = UTILS . shorten ( oval , context )
45- else if ( Array . isArray ( oval ) ) {
46- let noval = [ ]
47- for ( var k = 0 ; k < oval . length ; k ++ ) {
48- let kval = oval [ k ]
49- if ( typeof kval == 'string' ) kval = UTILS . shorten ( kval , context )
50- noval . push ( kval )
34+ if ( context ) {
35+ for ( let i = 0 ; i < this . bindings . length ; i ++ ) {
36+ for ( const prop of Object . keys ( this . bindings [ i ] ) ) {
37+ const nprop = UTILS . shorten ( prop , context )
38+ var nval = this . bindings [ i ] [ prop ]
39+ if ( typeof this . bindings [ i ] [ prop ] == 'string' ) {
40+ nval = UTILS . shorten ( this . bindings [ i ] [ prop ] , context )
41+ } else if ( Array . isArray ( this . bindings [ i ] [ prop ] ) ) {
42+ nval = [ ]
43+ for ( var j = 0 ; j < this . bindings [ i ] [ prop ] . length ; j ++ ) {
44+ let oval = this . bindings [ i ] [ prop ] [ j ]
45+ if ( typeof oval == 'string' ) oval = UTILS . shorten ( oval , context )
46+ else if ( Array . isArray ( oval ) ) {
47+ let noval = [ ]
48+ for ( var k = 0 ; k < oval . length ; k ++ ) {
49+ let kval = oval [ k ]
50+ if ( typeof kval == 'string' ) kval = UTILS . shorten ( kval , context )
51+ noval . push ( kval )
52+ }
53+ oval = noval
5154 }
52- oval = noval
55+ nval . push ( oval )
5356 }
54- nval . push ( oval )
5557 }
58+ delete this . bindings [ i ] [ prop ]
59+ this . bindings [ i ] [ nprop ] = nval
5660 }
57- delete this . bindings [ i ] [ prop ]
58- this . bindings [ i ] [ nprop ] = nval
5961 }
6062 }
63+ //console.log(this.bindings)
6164 return this
6265}
6366
0 commit comments