lodash#head JavaScript Examples
The following examples show how to use
lodash#head.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: search.js From mapstore2-cadastrapp with GNU General Public License v3.0 | 6 votes |
export function cadastrappSearch(action$, store) {
return action$.ofType(SEARCH).switchMap(({searchType, rawParams, target}) => {
return searchParcelles({searchType, rawParams})
.flatMap(parcelle => // for each parcelle,
getParcelleFeature(parcelle, store.getState) // create a request for the releated feature
.map(({ features = []} = {}) => { // add the feature to the parcelle object
const parcelleProperty = cadastreLayerIdParcelle(store.getState());
return {
...parcelle,
feature: head(features.filter(workaroundDuplicatedParcelle(parcelleProperty))) // removes duplicates
};
})
)
.reduce((acc, next) => [...acc, next], [])
.map(parcelles => addPlots(parcelles, target ?? targetFromSearch(searchType, rawParams)))
.let(wrapStartStop(
[loading(true, "plotSelection", "count"), loading(true, 'search')],
[loading(false, "plotSelection", "count"), loading(false, 'search')],
e => Rx.Observable.of(error({ title: "error during search", message: e.message ?? "unknown error"}))
));
});
}
Example #2
Source File: configuration.js From mapstore2-cadastrapp with GNU General Public License v3.0 | 6 votes |
/**
*
* @param {object} configuration the configuration from `getConfiguration`
* @returns {array} array of {index , title, thumbnail}
*/
export function getBaseMapsFromConfig({ pdfbasemaptitles: titles, pdfbasemapthumbnails: previews} = {}) {
return sortBy((titles || []).map(({value, key}) => ({
title: value,
index: key.split(".").reverse()[1], // need to take "0" from "pdf.baseMap.0.title" --> split --> reverse --> [title, 0, ...]. So I get the element at index 1 to get the number.
thumbnail: head((previews || []).filter(({key: kk}) => kk.indexOf(key) === 0).map(({value: vv}) => vv))
})), "index");
}
Example #3
Source File: app.js From agenda with MIT License | 5 votes |
ReactDOM.render( <AppContainer> <Root store={store} App={App}/> </AppContainer>, head(document.getElementsByTagName('article')) );
Example #4
Source File: workarounds.js From mapstore2-cadastrapp with GNU General Public License v3.0 | 5 votes |
workaroundDuplicatedParcelle = parcelleProperty => (v, index, array) => {
const sameParcelleElements = array.filter((vv) => vv?.properties?.[parcelleProperty] === v?.properties?.[parcelleProperty]);
const correctValue = head(sortBy(sameParcelleElements, 'lot').reverse());
return v?.properties?.lot === correctValue?.properties?.lot;
}