semantic-network
Version:
A utility library for manipulating a list of links that form a semantic interface to a network of resources.
23 lines • 750 B
JavaScript
import { LinkRelConvertUtil } from './linkRelConvertUtil';
export class ResourceUtil {
/**
* Given a set of {@link ApiOptions}, use the {@link ApiOptions.name} and {@ApiOptions.rel}
* properties to determine a name.
*
* Note: a valid name is always returns or throw error
*/
static makeName(options) {
const { name = undefined, rel = undefined } = Object.assign({}, options);
if (name) {
return name;
}
if (rel) {
const relName = LinkRelConvertUtil.relTypeToCamel(rel);
if (relName) {
return relName;
}
}
throw new Error(`Options must have a rel or name`);
}
}
//# sourceMappingURL=resourceUtil.js.map