lib/replicant/shared.js
function assertSingleOwner(replicant, value) {
	let metadata;
	if (proxySet.has(value)) {
		metadata = proxyMetadataMap.get(value);
	} else if (metadataMap.has(value)) {
		metadata = metadataMap.get(value);
	} else {
		// If there's no metadata for this value, then it doesn't belong to any Replicants yet,
		// and we're okay to continue.
		return;
	}

	if (metadata.replicant !== replicant) {
		/* eslint-disable function-paren-newline */
		throw new Error(
			`This object belongs to another Replicant, ${metadata.replicant.namespace}::${metadata.replicant.name}.` +
			`\nA given object cannot belong to multiple Replicants. Object value:\n${JSON.stringify(value, null, 2)}`
		);
		/* eslint-enable function-paren-newline */
	}
}
function assertSingleOwner(replicant, value) {
	let metadata;
	if (proxySet.has(value)) {
		metadata = proxyMetadataMap.get(value);
	} else if (metadataMap.has(value)) {
		metadata = metadataMap.get(value);
	} else {
		// If there's no metadata for this value, then it doesn't belong to any Replicants yet,
		// and we're okay to continue.
		return;
	}

	if (metadata.replicant !== replicant) {
		/* eslint-disable function-paren-newline */
		throw new Error(
			`This object belongs to another Replicant, ${metadata.replicant.namespace}::${metadata.replicant.name}.` +
			`\nA given object cannot belong to multiple Replicants. Object value:\n${JSON.stringify(value, null, 2)}`
		);
		/* eslint-enable function-paren-newline */
	}
}
function assertSingleOwner ( replicant , value ) { let metadata ; if ( proxySet . has ( value ) ) { metadata = proxyMetadataMap . get ( value ) ; } else if ( metadataMap . has ( value ) ) { metadata = metadataMap . get ( value ) ; } else { // If there's no metadata for this value, then it doesn't belong to any Replicants yet, // and we're okay to continue. return ; } if ( metadata . replicant !== replicant ) { /* eslint-disable function-paren-newline */ throw new Error ( ` ${ metadata . replicant . namespace } ${ metadata . replicant . name } ` + ` \n \n ${ JSON . stringify ( value , null , 2 ) } ` ) ; /* eslint-enable function-paren-newline */ } }
Throws an exception if an object belongs to more than one Replicant.
@param replicant {object} - The Replicant that this value should belong to.
@param value {*} - The value to check ownership of.
Throws an exception if an object belongs to more than one Replicant .