Comparing version 0.1.4 to 0.1.5
@@ -29,2 +29,6 @@ /** | ||
var _rapunzel = require('rapunzel'); | ||
var _rapunzel2 = _interopRequireDefault(_rapunzel); | ||
// local classes | ||
@@ -230,4 +234,4 @@ // ... | ||
// bundle this node in an array | ||
return [h_jsonld]; | ||
// no keys! | ||
return []; | ||
} | ||
@@ -698,2 +702,7 @@ | ||
$: { | ||
// hide this property when iterating | ||
enumerable: false, | ||
// | ||
value: function value(s_namespace) { | ||
@@ -735,2 +744,5 @@ return network_node(h_node, expand(s_namespace)); | ||
// hide this property when iterating | ||
enumerable: false, | ||
// do not expand iri | ||
@@ -749,2 +761,7 @@ value: s_value | ||
h_properties[s_key] = { | ||
// hide this property when iterating | ||
enumerable: false, | ||
// | ||
value: p_iri | ||
@@ -758,2 +775,7 @@ }; | ||
h_properties['$' + s_key.substr(1)] = { | ||
// hide this property when iterating | ||
enumerable: false, | ||
// | ||
value: p_iri.substr(n_namespace_length) | ||
@@ -783,5 +805,2 @@ }; | ||
// prepare an acces value | ||
var h_accessor = {}; | ||
// wrap the node so it is an array of standardized objects | ||
@@ -889,6 +908,16 @@ var a_nodes = wrap_node(z_value, h_node_context); | ||
// map each node to network node | ||
var a_nodes = a_top_nodes.map(function (p_node) { | ||
return network_node(h_graph[p_node], p_namespace); | ||
}); | ||
var a_nodes = (function () { | ||
// there are multiple things | ||
if (a_top_nodes.length) { | ||
return a_top_nodes.map(function (p_node) { | ||
return network_node(h_graph[p_node], p_namespace); | ||
}); | ||
} | ||
// there are 0 or there is only one thing | ||
else { | ||
return [network_node(h_jsonld, p_namespace)]; | ||
} | ||
})(); | ||
// user passed implicit each callback | ||
@@ -911,3 +940,2 @@ if ('function' === typeof f_each) { | ||
var local = function local() { | ||
return __construct.apply(this, arguments); | ||
@@ -925,2 +953,55 @@ }; | ||
}; | ||
// | ||
local.stringify = function (z_what) { | ||
// | ||
var stringify_thing = function stringify_thing(add, z_thing) { | ||
// ref thing type | ||
var s_type = typeof z_thing; | ||
// string | ||
if ('string' === s_type) { | ||
add('\'' + z_thing.replace(/'/g, '\\\'') + '\'', true); | ||
} | ||
// array | ||
else if (Array.isArray()) { | ||
this.open('[ ', ',', true); | ||
for (var i_item in z_thing) { | ||
add(''); | ||
stringify_thing.apply(this, [add, z_thing[i_item]]); | ||
} | ||
this.close(']'); | ||
} | ||
// something with enumerable properties | ||
else { | ||
if ('function' === s_type) { | ||
this.open('(function){', ',', true); | ||
} else { | ||
this.open('{', ',', true); | ||
} | ||
var b_was_found = false; | ||
for (var s_property in z_thing) { | ||
b_was_found = true; | ||
add('\'' + s_property.replace(/'/g, '\\\'') + '\': '); | ||
stringify_thing.apply(this, [add, z_thing[s_property]]); | ||
} | ||
if (!b_was_found) { | ||
this.close('', ''); | ||
} else { | ||
this.close('}'); | ||
} | ||
} | ||
}; | ||
return (0, _rapunzel2['default'])({ | ||
body: function body(add) { | ||
return stringify_thing.apply(this, [add, z_what]); | ||
} | ||
}).produce({ | ||
indent: ' ' | ||
}); | ||
}; | ||
} | ||
@@ -927,0 +1008,0 @@ |
{ | ||
"name": "graphy", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"description": "Query linked-data graphs by abstracting away traditional JSON-LD interaction", | ||
@@ -42,4 +42,5 @@ "author": { | ||
"clone": "^1.0.2", | ||
"rapunzel": "0.0.5", | ||
"rmprop": "^1.0.0" | ||
} | ||
} |
@@ -111,2 +111,8 @@ # graphy [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url] [![Coverage percentage][coveralls-image]][coveralls-url] | ||
## Iterating | ||
`for..in` | ||
`for..of` | ||
## License | ||
@@ -113,0 +119,0 @@ |
30373
820
130
5
+ Addedrapunzel@0.0.5
+ Addedrapunzel@0.0.5(transitive)