ramda#equals JavaScript Examples
The following examples show how to use
ramda#equals.
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: DailyCategory.jsx From archeage-tools with The Unlicense | 6 votes |
componentDidUpdate(prevProps) {
if (prevProps.collapsed !== this.props.collapsed ||
(!equals(prevProps.completedQuests, this.props.completedQuests) && this.props.hideComplete && !this.props.showHidden) ||
(!equals(prevProps.hiddenQuests, this.props.hiddenQuests) && !this.showHidden) ||
(!equals(prevProps.rewards, this.props.rewards)) ||
((!equals(prevProps.castles, this.props.castles) || !equals(prevProps.residence, this.props.residence)) && !this.showHidden)) {
this.props.onUpdate();
}
}
Example #2
Source File: Accordion.js From lundium with MIT License | 6 votes |
Accordion = forwardRef(({ openItemIndex, className, children }, ref) => {
const [indexOpen, setIndexOpen] = useState(openItemIndex);
useEffect(() => {
if (!isNaN(openItemIndex)) {
setIndexOpen(openItemIndex);
}
}, [openItemIndex]);
useImperativeHandle(ref, () => ({ setActiveIndex: setIndexOpen }));
return (
<Box className={cx('accordion', className)}>
{Children.map(children, (child, index) =>
cond([
[
o(equals(AccordionItem), prop('type')),
clone({ index, indexOpen, setIndexOpen }),
],
[T, identity],
])(child),
)}
</Box>
);
})
Example #3
Source File: RecipeList.jsx From archeage-tools with The Unlicense | 6 votes |
componentDidUpdate(prevProps, prevState) {
// ignore state updates
if (!equals(prevState, this.state)) return;
const { vocation, productQuery, materialQuery } = this.props;
const { loaded } = this.state;
if (vocation !== prevProps.vocation || productQuery !== prevProps.productQuery || materialQuery !== prevProps.materialQuery) {
this.setState({ recipeList: [] });
}
if (loaded !== this.getRecipeKey()) {
this.checkRecipes();
}
}
Example #4
Source File: staking_payouts.js From sdk with MIT License | 6 votes |
{
FullNodeEndpoint,
StakingPayoutsAlarmEmailTo,
InitiatorAccountURI,
BatchSize,
ConcurrentRequestsLimit,
ConcurrentTxLimit,
RetryTimeout,
MaxCommission,
AlarmBalance,
TxFinalizationTimeout,
IterationTimeout,
FinalizeTx,
} = envObj({
// Address of the node RPC.
FullNodeEndpoint: notNilAnd(String),
// List of email addresses separated by comma to send alarm email to.
StakingPayoutsAlarmEmailTo: notNilAnd(split(",")),
// Account to send transactions from.
InitiatorAccountURI: notNilAnd(String),
// Max batch size.
BatchSize: o(finiteNumber, defaultTo(5)),
// Max amount of concurrent requests.
ConcurrentRequestsLimit: o(finiteNumber, defaultTo(10)),
// Max amount of concurrent transactions.
ConcurrentTxLimit: o(finiteNumber, defaultTo(5)),
// Timeout to wait before retry transaction. In ms.
RetryTimeout: o(finiteNumber, defaultTo(5e3)),
// Max commission allowed to be set for validators. Default to 5%.
MaxCommission: o((val) => new BN(val), defaultTo("50000000")),
// Min account balance to ring alarm.
AlarmBalance: notNilAnd((val) => new BN(val)),
// Time to wait for transaction to be finalized. In ms.
TxFinalizationTimeout: o(finiteNumber, defaultTo(3e4)),
// Time to wait for all payments to be sent in an iteration before returning with an error. In ms.
IterationTimeout: o(finiteNumber, defaultTo(4e5)),
// Finalize the transaction or just wait for it to be included in the block.
FinalizeTx: either(equals("true"), o(Boolean, Number)),
})
Example #5
Source File: processOrderBookUpdate.js From binance-websocket-examples with MIT License | 6 votes |
processOrderBookUpdate = (data, bid, ask) => {
const validateValue = (v) => Big(v[0]);
const compareValueFn = cond([
[equals('ask'), () => (a, b) => (new Big(a[0])).minus(b[0])],
[equals('bid'), () => (a, b) => (new Big(b[0])).minus(a[0])],
]);
const purgeEmptyVolume = (v) => Big(v[1]).gt(0);
data.bid = uniqBy(validateValue, [...bid, ...data.bid])
.sort(compareValueFn('bid'), data.bid)
.filter(purgeEmptyVolume, data.bid);
data.ask = uniqBy(validateValue, [...ask, ...data.ask])
.sort(compareValueFn('ask'), data.ask)
.filter(purgeEmptyVolume, data.ask);
return data;
}
Example #6
Source File: processOrderBookSnapshot.js From binance-websocket-examples with MIT License | 6 votes |
processOrderBookSnapshot = (orderBookData, snapshotOrderbook) => {
const { lastUpdateId, bids, asks } = snapshotOrderbook;
// clean the order that is out of date
const cleanOutOfDateOrder = (order) => order[2] > lastUpdateId;
orderBookData.bid = filter(cleanOutOfDateOrder, orderBookData.bid);
orderBookData.ask = filter(cleanOutOfDateOrder, orderBookData.ask);
// append the updateId into snapshotOrderbook
const snapshotOrders = appendUpdatedId(lastUpdateId, asks, bids);
const compareValueFn = cond([
[equals('ask'), () => (a, b) => (new Big(a[0])).minus(b[0])],
[equals('bid'), () => (a, b) => (new Big(b[0])).minus(a[0])],
]);
const validateValue = (v) => Big(v[0]);
orderBookData.bid = uniqBy(validateValue, [...snapshotOrders[1], ...orderBookData.bid])
.sort(compareValueFn('bid'), orderBookData.bid);
orderBookData.ask = uniqBy(validateValue, [...snapshotOrders[0], ...orderBookData.ask])
.sort(compareValueFn('ask'), orderBookData.ask);
return orderBookData;
}
Example #7
Source File: index.js From web with GNU General Public License v3.0 | 6 votes |
callBridgeDataHandler = cond([ [equals(DATA_TYPE.NATIVE_SERVICES_STATUS), always(handleServicesStatus)], [equals(DATA_TYPE.HISTORICAL_DATA), always(handleUploadHistoricalDataResponse)], [equals(DATA_TYPE.EXPOSURE_STATISTICS), always(handleExposureSummary)], [equals(DATA_TYPE.NATIVE_STATE), always(handleNativeState)], [equals(DATA_TYPE.LANGUAGE), always(handleNativeLanguage)], [equals(DATA_TYPE.LAB_TEST_SUBSCRIPTION), always(handleLabTestSubscription)], [equals(DATA_TYPE.BACK_PRESSED), always(handleBackPressed)], [equals(DATA_TYPE.CHANGE_SCREEN), always(handleChangeScreen)], [equals(DATA_TYPE.SUMMARY_STATISTICS), always(handleNewSummaryStatistics)], [equals(DATA_TYPE.DETAILS_STATISTICS), always(handleNewDetailsStatistics)] ])
Example #8
Source File: AdContainer.jsx From archeage-tools with The Unlicense | 5 votes |
componentDidUpdate(prevProps) {
if (!equals(prevProps, this.props)) {
this.setState({ elapsedTime: 0 });
}
}
Example #9
Source File: Notification.js From lundium with MIT License | 5 votes |
getIcon = cond([
[equals('danger'), always('status-rejected')],
[equals('warning'), always('error')],
[T, identity],
])
Example #10
Source File: sortStories.js From lundium with MIT License | 5 votes |
getSortPosition = composeC(when(equals(-1), always(1000)), indexOf)
Example #11
Source File: HistoryActivitiesItem.helpers.js From web with GNU General Public License v3.0 | 5 votes |
resolveDatas = (content, riskChecks, riskLevel, title, type) => {
const resoleRiskLevel = cond([
[
equals(1),
always({
title: <T i18nKey="history_notifications_text_10" />,
content: <T i18nKey="history_notifications_text_14" />
})
],
[
equals(2),
always({
title: <T i18nKey="history_notifications_text_9" />,
content: <T i18nKey="history_notifications_text_13" />
})
],
[
equals(3),
always({
title: <T i18nKey="history_notifications_text_8" />,
content: <T i18nKey="history_notifications_text_12" />
})
]
]);
switch (type) {
case TYPE.NOTIFICATION: {
return { icon: <Icon3 />, content, title };
}
case TYPE.RISK_CHECK: {
return {
content: <ContentRiskCheck data={riskChecks} />,
icon: <Icon2 />,
title: <T i18nKey="history_notifications_text_11" />
};
}
case TYPE.EXPOSURE: {
return { icon: <Icon1 />, ...resoleRiskLevel(riskLevel) };
}
default: {
return null;
}
}
}
Example #12
Source File: rendering.js From web with GNU General Public License v3.0 | 5 votes |
styleIfElse = (pred, styleIfTrue, styleIfFalse) => props => {
return renderWhen(
equals(true),
always(styleIfTrue),
always(styleIfFalse)
)(pred(props));
}
Example #13
Source File: rendering.js From web with GNU General Public License v3.0 | 5 votes |
styleWhenTrue = (pred, style) => props =>
renderWhen(equals(true), always(style))(pred(props))
Example #14
Source File: rendering.js From web with GNU General Public License v3.0 | 5 votes |
renderWhenFalse = fn => renderWhen(equals(false), fn)
Example #15
Source File: rendering.js From web with GNU General Public License v3.0 | 5 votes |
renderWhenTrue = fn => renderWhen(equals(true), fn)
Example #16
Source File: logic.js From web with GNU General Public License v3.0 | 5 votes |
notEquals = complement(equals)
Example #17
Source File: PackCompare.jsx From archeage-tools with The Unlicense | 5 votes |
componentDidUpdate(prevProps) {
if (!equals(this.props.tradePacks, prevProps.tradePacks) || !equals(this.props.zones, prevProps.zones)) {
this.initialize();
}
}
Example #18
Source File: SkillCombos.jsx From archeage-tools with The Unlicense | 5 votes |
componentWillUpdate(nextProps, nextState, nextContext) {
return (!equals(this.props, nextProps) || !equals(this.state, nextState));
}
Example #19
Source File: Schedule.jsx From archeage-tools with The Unlicense | 5 votes |
UNSAFE_componentWillUpdate(nextProps) {
const { events, region } = nextProps;
if (!equals(events, this.props.events) || region !== this.props.region) {
this.setupEvents(events, region);
}
}
Example #20
Source File: CargoShip.jsx From archeage-tools with The Unlicense | 5 votes |
componentDidUpdate(prevProps) {
if (this.props.server !== prevProps.server || !equals(this.props.cargoTimers, prevProps.cargoTimers)) {
this.initialize();
}
}
Example #21
Source File: DailyQuest.jsx From archeage-tools with The Unlicense | 5 votes |
shouldComponentUpdate(nextProps) {
return !equals(this.props, nextProps);
}
Example #22
Source File: AdContainer.jsx From archeage-tools with The Unlicense | 5 votes |
// eslint-disable-next-line no-unused-vars
shouldComponentUpdate(nextProps, nextState, nextContext) {
return !equals(nextProps, this.props) || !equals(nextProps, this.state);
}
Example #23
Source File: MountViewer.jsx From archeage-tools with The Unlicense | 4 votes |
render() {
const { id, open } = this.state;
const { mobile, mountData, obtainTypes } = this.props;
const mountSet = mountData[id];
const mountObtain = MOUNT.find(mount => slug(mount.name) === id);
if (!mountSet) return null;
const [mount, ...altMounts] = mountSet;
const altSkills = Array.from(new Set(altMounts.map(altMount => altMount.skillIds).filter(s => !equals(s, mount.skillIds)).map(JSON.stringify)), JSON.parse);
return (
<Dialog
open={open}
onClose={this.onClose}
maxWidth="lg"
fullScreen={mobile}
>
<AppBar position="static">
<Toolbar variant="dense">
<Typography variant="subtitle1" className="title-text">
<div className="mount-header-icon" data-grade={mount.gradeId}>
<img src={`/images/icon/${mount.icon}.png`} alt={mount.name} />
</div>
{mount.name}
</Typography>
<Tooltip title="Close">
<IconButton onClick={this.onClose}>
<CloseIcon />
</IconButton>
</Tooltip>
</Toolbar>
</AppBar>
<DialogContent className={cn('mount-viewer', mobile)}>
<div className="info">
<div className="portrait">
<img src={Portrait[pascalCase(mount.name)] || NoPortrait} alt={mount.name} />
<div className="left-stats">
<Typography component="div" className="obtainables">
{mount.obtainIds && mount.obtainIds.length > 0
? mount.obtainIds.map(obtainId => (
<Tooltip
title={`Obtainable with ${obtainTypes[obtainId].name}`}
key={`view-obt-${mount.id}-${obtainId}`}
>
<span className={cn('dropdown-icon', obtainTypes[obtainId].icon)} />
</Tooltip>
))
: 'Unobtainable'}
</Typography>
{mountObtain && mountObtain.upgrade &&
<Typography className="upgrade">
Upgrade: <Link to={`/mounts/${slug(mountObtain.upgrade)}`}>{mountObtain.upgrade}</Link>
</Typography>}
</div>
<div className="right-stats">
<Tooltip title="Base Move Speed">
<Typography className="move-speed">{mount.moveSpeed || '?'} m/s</Typography>
</Tooltip>
{mount.imageCredit &&
<Typography className="image-credit">
Image: {mount.imageCredit}
</Typography>}
</div>
</div>
<Typography variant="h6" className="skill-header">
<span>Skills</span>
<Tooltip title="Base Level">
<Typography variant="caption">Lv. {mount.level}</Typography>
</Tooltip>
</Typography>
<div className="skills">
{mount.skillIds.map(skillId => (
<SkillIcon key={`viewer-${mount.id}-${skillId}`} id={skillId} />
))}
</div>
{altSkills.length > 0 &&
<>
<Tooltip
title="There's a possible, alternate variant of this mount that offers a different selection of skills.">
<Typography>Alternate Skills</Typography>
</Tooltip>
{altSkills.map(skillIds => {
const altMount = altMounts.find(m => equals(m.skillIds, skillIds));
return (
<div className="skills" key={`alt-mount-${altMount.id}`}>
<Tooltip title="Base Level">
<Typography variant="caption" className="skill-alt">
Lv. {mount.level}
</Typography>
</Tooltip>
{skillIds.map(skillId => (
<SkillIcon key={`viewer-${altMount.id}-${skillId}`} id={skillId} className="size-sm" />
))}
{altMount.alternateNote &&
<Typography variant="caption" className="skill-alt-note">{altMount.alternateNote}</Typography>}
</div>
);
})}
</>}
</div>
<div className="obtain">
{mount.quote &&
<blockquote>{mount.quote}</blockquote>}
<Typography variant="h6">
Getting {mount.name}
{mountObtain && mountObtain.itemName &&
<Typography component="span"> ({mountObtain.itemName})</Typography>}
</Typography>
{/* eslint-disable-next-line no-nested-ternary */}
{((!mount.obtainIds || mount.obtainIds.length === 0) && !(mountObtain && mountObtain.obtainText))
? <Typography className="alert-red">This mount is currently unavailable.</Typography>
: mountObtain && mountObtain.obtainText
? <Typography component="div">{mountObtain.obtainText}</Typography>
: <Typography component="div">Details to obtain this mount have not yet been added.</Typography>}
</div>
</DialogContent>
<AdContainer section={false} type="horizontal" />
</Dialog>
);
}
Example #24
Source File: osk-detector.js From on-screen-keyboard-detector with MIT License | 4 votes |
/**
*
* @param {function(String)} userCallback
* @return {function(): void}
*/
// initWithCallback :: (String -> *) -> (... -> undefined)
function initWithCallback(userCallback) {
if(isIOS) {
return subscribeOnIOS(userCallback);
}
const
INPUT_ELEMENT_FOCUS_JUMP_DELAY = 700,
SCREEN_ORIENTATION_TO_WINDOW_RESIZE_DELAY = 700,
RESIZE_QUIET_PERIOD = 500,
LAYOUT_RESIZE_TO_LAYOUT_HEIGHT_FIX_DELAY =
Math.max(INPUT_ELEMENT_FOCUS_JUMP_DELAY, SCREEN_ORIENTATION_TO_WINDOW_RESIZE_DELAY) - RESIZE_QUIET_PERIOD + 200,
[ induceUnsubscribe, userUnsubscription ] = createAdapter(),
scheduler = newDefaultScheduler(),
// assumes initially hidden OSK
initialLayoutHeight = window.innerHeight,
// assumes initially hidden OSK
approximateBrowserToolbarHeight = screen.availHeight - window.innerHeight,
// Implementation note:
// On Chrome window.outerHeight changes together with window.innerHeight
// They seem to be always equal to each other.
focus =
merge(focusin(document.documentElement), focusout(document.documentElement)),
documentVisibility =
applyTo(domEvent('visibilitychange', document))(pipe(
map(() => document.visibilityState),
startWith(document.visibilityState)
)),
isUnfocused =
applyTo(focus)(pipe(
map(evt =>
evt.type === 'focusin' ? now(false) : at(INPUT_ELEMENT_FOCUS_JUMP_DELAY, true)
),
switchLatest,
startWith(!isAnyElementActive()),
skipRepeats,
multicast
)),
layoutHeightOnOSKFreeOrientationChange =
applyTo(change(screen.orientation))(pipe(
// The 'change' event hits very early BEFORE window.innerHeight is updated (e.g. on "resize")
snapshot(
unfocused => unfocused || (window.innerHeight === initialLayoutHeight),
isUnfocused
),
debounce(SCREEN_ORIENTATION_TO_WINDOW_RESIZE_DELAY),
map(isOSKFree => ({
screenOrientation: getScreenOrientationType(),
height: isOSKFree ? window.innerHeight : screen.availHeight - approximateBrowserToolbarHeight
}))
)),
layoutHeightOnUnfocus =
applyTo(isUnfocused)(pipe(
filter(identical(true)),
map(() => ({screenOrientation: getScreenOrientationType(), height: window.innerHeight}))
)),
// Difficulties: The exact layout height in the perpendicular orientation is only to determine on orientation change,
// Orientation change can happen:
// - entirely unfocused,
// - focused but w/o OSK, or
// - with OSK.
// Thus on arriving in the new orientation, until complete unfocus, it is uncertain what the current window.innerHeight value means
// Solution?: Assume initially hidden OSK (even if any input has the "autofocus" attribute),
// and initialize other dimension with screen.availWidth
// so there can always be made a decision on the keyboard.
layoutHeights =
// Ignores source streams while documentVisibility is 'hidden'
// sadly visibilitychange comes 1 sec after focusout!
applyTo(mergeArray([layoutHeightOnUnfocus, layoutHeightOnOSKFreeOrientationChange]))(pipe(
delay(1000),
rejectCapture(map(equals("hidden"), documentVisibility)),
scan(
(accHeights, {screenOrientation, height}) =>
assoc(screenOrientation, height, accHeights),
{
[getScreenOrientationType()]: window.innerHeight
}
),
skipAfter(compose(isEmpty, difference(['portrait', 'landscape']), keys))
)),
layoutHeightOnVerticalResize =
applyTo(resize(window))(pipe(
debounce(RESIZE_QUIET_PERIOD),
map(evt => ({ width: evt.target.innerWidth, height: evt.target.innerHeight})),
scan(
(prev, size) =>
({
...size,
isJustHeightResize: prev.width === size.width,
dH: size.height - prev.height
}),
{
width: window.innerWidth,
height: window.innerHeight,
isJustHeightResize: false,
dH: 0
}
),
filter(propEq('isJustHeightResize', true))
)),
osk =
applyTo(layoutHeightOnVerticalResize)(pipe(
delay(LAYOUT_RESIZE_TO_LAYOUT_HEIGHT_FIX_DELAY),
snapshot(
(layoutHeightByOrientation, {height, dH}) => {
const
nonOSKLayoutHeight = layoutHeightByOrientation[getScreenOrientationType()];
if (!nonOSKLayoutHeight) {
return (dH > 0.1 * screen.availHeight) ? now("hidden")
: (dH < -0.1 * screen.availHeight) ? now("visible")
: empty();
}
return (height < 0.9 * nonOSKLayoutHeight) && (dH < 0) ? now("visible")
: (height === nonOSKLayoutHeight) && (dH > 0) ? now("hidden")
: empty();
},
layoutHeights
),
join,
merge(applyTo(isUnfocused)(pipe(
filter(identical(true)),
map(always("hidden"))
))),
until(userUnsubscription),
skipRepeats
));
runEffects(tap(userCallback, osk), scheduler);
return induceUnsubscribe;
}