src/future/linked.js
function mk_NodeSet(k_graph, a_terms, s_term_types) {
	// prep to reduce nodes to a set
	let h_nodes = {};

	// nodes are all NamedNodes
	if('NamedNode' === s_term_types) {
		for(let i_term=0; i_term<a_terms.length; i_term++) {
			let h_term = a_terms[i_term];
			h_nodes[h_term.value] = h_term;
		}
	}
	// nodes are all BlankNodes
	else if('BlankNodes' === s_term_types) {
		for(let i_term=0; i_term<a_terms.length; i_term++) {
			let h_term = a_terms[i_term];
			h_nodes['_:'+h_term.value] = h_term;
		}
	}
	// nodes are mixed
	else {
		for(let i_term=0; i_term<a_terms.length; i_term++) {
			let h_term = a_terms[i_term];
			h_nodes[h_term.isBlankNode? '_:'+h_term.value: h_term.value] = h_term;
		}
	}

	// reduce nodes to a set
	let as_nodes = [];
	for(let s_node_id in h_nodes) {
		let k_node = k_graph.nodes[s_node_id]
			|| k_graph.leafs[s_node_id]
			|| (k_graph.leafs[s_node_id] = new Node(k_graph, [], h_nodes[s_node_id]));

		// only add subject nodes that exist to the set
		if(k_node) as_nodes.push(k_node);
	}

	// make instance
	let h_methods = Object.assign(Object.create(NodeSet_prototype), {
		graph: k_graph,
		nodes: as_nodes,

		areNodes: true,
	});

	// construct 'that'
	let f_bound = NodeSet_operator.bind(h_methods);

	// save to list so we can reuse it
	a_terms.set = f_bound;

	// make & return operator
	Object.setPrototypeOf(f_bound, NodeSet_prototype);
	return Object.assign(f_bound, h_methods);
}
function mk_NodeSet(k_graph, a_terms, s_term_types) {
	// prep to reduce nodes to a set
	let h_nodes = {};

	// nodes are all NamedNodes
	if('NamedNode' === s_term_types) {
		for(let i_term=0; i_term<a_terms.length; i_term++) {
			let h_term = a_terms[i_term];
			h_nodes[h_term.value] = h_term;
		}
	}
	// nodes are all BlankNodes
	else if('BlankNodes' === s_term_types) {
		for(let i_term=0; i_term<a_terms.length; i_term++) {
			let h_term = a_terms[i_term];
			h_nodes['_:'+h_term.value] = h_term;
		}
	}
	// nodes are mixed
	else {
		for(let i_term=0; i_term<a_terms.length; i_term++) {
			let h_term = a_terms[i_term];
			h_nodes[h_term.isBlankNode? '_:'+h_term.value: h_term.value] = h_term;
		}
	}

	// reduce nodes to a set
	let as_nodes = [];
	for(let s_node_id in h_nodes) {
		let k_node = k_graph.nodes[s_node_id]
			|| k_graph.leafs[s_node_id]
			|| (k_graph.leafs[s_node_id] = new Node(k_graph, [], h_nodes[s_node_id]));

		// only add subject nodes that exist to the set
		if(k_node) as_nodes.push(k_node);
	}

	// make instance
	let h_methods = Object.assign(Object.create(NodeSet_prototype), {
		graph: k_graph,
		nodes: as_nodes,

		areNodes: true,
	});

	// construct 'that'
	let f_bound = NodeSet_operator.bind(h_methods);

	// save to list so we can reuse it
	a_terms.set = f_bound;

	// make & return operator
	Object.setPrototypeOf(f_bound, NodeSet_prototype);
	return Object.assign(f_bound, h_methods);
}
function mk_NodeSet ( k_graph , a_terms , s_term_types ) { // prep to reduce nodes to a set let h_nodes = { } ; // nodes are all NamedNodes if ( 'NamedNode' === s_term_types ) { for ( let i_term = 0 ; i_term < a_terms . length ; i_term ++ ) { let h_term = a_terms [ i_term ] ; h_nodes [ h_term . value ] = h_term ; } } // nodes are all BlankNodes else if ( 'BlankNodes' === s_term_types ) { for ( let i_term = 0 ; i_term < a_terms . length ; i_term ++ ) { let h_term = a_terms [ i_term ] ; h_nodes [ '_:' + h_term . value ] = h_term ; } } // nodes are mixed else { for ( let i_term = 0 ; i_term < a_terms . length ; i_term ++ ) { let h_term = a_terms [ i_term ] ; h_nodes [ h_term . isBlankNode ? '_:' + h_term . value : h_term . value ] = h_term ; } } // reduce nodes to a set let as_nodes = [ ] ; for ( let s_node_id in h_nodes ) { let k_node = k_graph . nodes [ s_node_id ] || k_graph . leafs [ s_node_id ] || ( k_graph . leafs [ s_node_id ] = new Node ( k_graph , [ ] , h_nodes [ s_node_id ] ) ) ; // only add subject nodes that exist to the set if ( k_node ) as_nodes . push ( k_node ) ; } // make instance let h_methods = Object . assign ( Object . create ( NodeSet_prototype ) , { graph : k_graph , nodes : as_nodes , areNodes : true , } ) ; // construct 'that' let f_bound = NodeSet_operator . bind ( h_methods ) ; // save to list so we can reuse it a_terms . set = f_bound ; // make & return operator Object . setPrototypeOf ( f_bound , NodeSet_prototype ) ; return Object . assign ( f_bound , h_methods ) ; }
makes a new NodeSet
makes a new NodeSet