@bryandbor/selector-utils
v0.0.2
Published
Utilities for selectors
Downloads
17
Maintainers
Readme
@bryandbor/selector-utils
Utilities for selectors
Install
npm install --save @bryandbor/selector-utils
Usage
The use of the reselect library is suggested, but not required.
import {createSelector} from 'reselect';
import {
trueIfAllAreTrue,
trueIfAnyAreTrue,
not,
sum,
getIsGreaterThanOrEqual,
getIsEqual,
joinStrings,
// There are many more utils exported from this library, this is just a subset used for demo purposes
} from '@bryandbor/selector-utils';
export const getNumberOfFriends = createSelector(
getFriendsFromSchool,
getFriendsFromWork,
getFamilyFriends,
sum,
);
export const getHasLotsOfFriends = createSelector(
getNumberOfFriends,
getIsGreaterThanOrEqual(25)
);
export const getIsFirstNameSilly = createSelector(
getFirstName,
getIsEqual('Bozo')
);
export const getIsLastNameGreat = createSelector(
getLastName,
getIsEqual('Powers')
);
export const getIsNameCool = createSelector(
not(getIsFirstNameSilly),
getIsLastNameGreat,
trueIfAnyAreTrue
);
export const getIsCoolPerson = createSelector(
getHasLotsOfFriends,
getIsNameCool,
trueIfAllAreTrue
);
export const getCoolPersonGreeting = createSelector(
'Hello,'
getFirstName,
'you are officially cool!'
);
License
MIT © bryandbor