Comparing version 0.1.19 to 0.1.20
@@ -480,4 +480,11 @@ /** | ||
// wraps a json-ld object with our javascript interface | ||
var wrap_node = function wrap_node(z_object, h_node_context) { | ||
var wrap_node = function wrap_node(z_object, h_parent_context) { | ||
var s_key = arguments.length <= 2 || arguments[2] === undefined ? '' : arguments[2]; | ||
// | ||
var b_ignore_context = s_key.includes(':'); | ||
// local node's context | ||
var h_node_context = {}; | ||
// ref object type | ||
@@ -499,4 +506,4 @@ var s_type = typeof z_object; | ||
// create deep copy of context before changing properties | ||
h_node_context = (0, _clone2['default'])(h_node_context, false); | ||
// // create deep copy of context before changing properties | ||
// h_node_context = clone(h_node_context, false); | ||
@@ -537,3 +544,3 @@ // alias object before traversing | ||
list: z_object['@list'].map(function (z_item) { | ||
return wrap_node(z_item, h_node_context); | ||
return wrap_node(z_item, b_ignore_context ? h_node_context : h_parent_context, s_key); | ||
}) | ||
@@ -543,3 +550,3 @@ }]; | ||
// override the property set on node context | ||
// set the property on node context | ||
h_node_context[s_property.substr(1)] = h_object[s_property]; | ||
@@ -570,4 +577,7 @@ } | ||
// ref context type | ||
var s_context_type = h_node_context.type || h_parent_context.type; | ||
// points to an iri | ||
if ('@id' === h_node_context.type) { | ||
if ('@id' === s_context_type) { | ||
@@ -588,3 +598,3 @@ // object type is a javascript string | ||
return z_object.map(function (z_item) { | ||
var a_nodes = wrap_node(z_item, h_node_context); | ||
var a_nodes = wrap_node(z_item, h_parent_context); | ||
@@ -609,3 +619,3 @@ // make sure only one node was created | ||
// literal type | ||
else if ('string' === typeof h_node_context.type) { | ||
else if ('string' === typeof s_context_type) { | ||
@@ -615,7 +625,7 @@ // return literal | ||
type: 'literal', | ||
datatype: h_node_context.type, | ||
datatype: s_context_type, | ||
value: z_object | ||
}]; | ||
} | ||
// raw string | ||
// plain literal | ||
else { | ||
@@ -771,3 +781,3 @@ | ||
'@full': { | ||
value: s_quoted_value + '^^<' + s_datatype + '>' | ||
value: s_quoted_value + '^^' + (s_datatype ? '<' + s_datatype + '>' : '') | ||
}, | ||
@@ -777,3 +787,3 @@ | ||
'@value': { | ||
value: z_value | ||
value: s_quoted_value | ||
} | ||
@@ -952,10 +962,9 @@ }; | ||
// generate terse string representation of this node | ||
// generate terse SPARQL/TTL-compatible string representation of this node | ||
$terse: { | ||
value: function value() { | ||
// only do this for named things | ||
if (!b_blanknode) { | ||
return shorten(expand(h_node['@id'])); | ||
} | ||
get: function get() { | ||
return function () { | ||
// not yet implemented | ||
local.fail('$terse-ing a node is not yet implemented'); | ||
}; | ||
} | ||
@@ -973,3 +982,14 @@ }, | ||
})) | ||
}, | ||
// generate full SPARQL/TTL-compatible string representation of this node | ||
'@full': { | ||
get: function get() { | ||
return function () { | ||
// not yet implemented | ||
local.fail('@full-ing a node is not yet implemented'); | ||
}; | ||
} | ||
} | ||
}; | ||
@@ -1058,3 +1078,3 @@ | ||
// wrap the node so it is an array of standardized objects | ||
var a_nodes = wrap_node(z_value, h_node_context); | ||
var a_nodes = wrap_node(z_value, h_node_context, s_key); | ||
@@ -1101,3 +1121,3 @@ // store these nodes to the suffixed object hash | ||
if (!a_nodes) { | ||
return local.error('no objects are pointed to by namespaced suffix "' + s_suffix + '" in {' + shorten(p_namespace) + ':}'); | ||
return local.error('no objects are pointed to by namespaced suffix "' + s_suffix + '" in {' + shorten(p_namespace) + '}'); | ||
} | ||
@@ -1104,0 +1124,0 @@ |
{ | ||
"name": "graphy", | ||
"version": "0.1.19", | ||
"version": "0.1.20", | ||
"description": "Query linked-data graphs by abstracting away traditional JSON-LD interaction", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -73,4 +73,6 @@ # 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] | ||
// get full SPARQL/TTL-compatible string representation of a literal | ||
// get full SPARQL/TTL-compatible string representation of any entity | ||
k_banana.class['@full']; // '<vocab://ns/Berry>' | ||
k_banana.tastes['@full']; // '"good"^^<http://www.w3.org/2001/XMLSchema#string>' | ||
k_banana.stages['@full']; // '[<http://www.w3.org/1999/02/22-rdf-syntax-ns#first> <vocab://ns/FindSpace>;<http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> (<vocab://plant/Seed> <vocab://plant/Grow> <vocab://plant/Harvest>)]' | ||
@@ -77,0 +79,0 @@ // change namespace to get suffixed datatype of literal |
41235
1047
218