Repository URL to install this package:
|
Version:
0.0.15 ▾
|
import get from 'lodash/get';
import { defaultSuggestionList } from './fixture';
function processFeatureNotBugPipes() {
console.warn('processFeatureNotBugPipes @todo');
}
const searchSuggestionMap = {
label: 'properties.suggestion.0.label',
value: 'properties.suggestion.0.value',
};
function flattenSnap(snapshot = {}) {
Object.keys(searchSuggestionMap).forEach(key => {
// here would do toDefault(get(types[key])) for fallback
// defaulting to empty string for now though
const longPath = searchSuggestionMap[key];
snapshot[key] = get(snapshot, longPath, '');
});
// hot reloader really messes with toArray ;-(
snapshot.value = Array.prototype.concat.apply([], [snapshot.value]);
const isEmptyResult = snapshot.value.length === 0 || snapshot.value[0] === '';
if (isEmptyResult) {
// using as because frozen !== normal
snapshot.value = defaultSuggestionList;
}
return snapshot;
}
export { flattenSnap, processFeatureNotBugPipes };
export default flattenSnap;
//# sourceMappingURL=transform.js.map