object-hierarchy-access
Version:
Get/Set value from/to JS object hierarchy properties
20 lines (17 loc) • 380 B
text/typescript
import {GetNameCallback, IGotPropDescriptor, PropName} from '../type';
function normalizeDescriptor(info: PropName | GetNameCallback | IGotPropDescriptor): IGotPropDescriptor {
if (typeof info === 'object') {
return info;
} else if (typeof info === 'function') {
return {
getName: info
};
} else {
return {
name: info
};
}
}
export {
normalizeDescriptor
};