本文整理匯總了TypeScript中ramda.merge函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript merge函數的具體用法?TypeScript merge怎麽用?TypeScript merge使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了merge函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: checkOneBrowser
function checkOneBrowser(browser: Browser) {
const platform = os.platform()
const pickBrowserProps = pick([
'name',
'displayName',
'type',
'version',
'path'
])
const logBrowser = (props: any) => {
log('setting major version for %j', props)
}
const failed = (err: NotInstalledError) => {
if (err.notInstalled) {
log('browser %s not installed', browser.name)
return false
}
throw err
}
log('checking one browser %s', browser.name)
return lookup(platform, browser)
.then(merge(browser))
.then(pickBrowserProps)
.then(tap(logBrowser))
.then(setMajorVersion)
.catch(failed)
}
示例2: merge
const set = data => {
for (let x = 0; x < data.width; x++) {
for (let y = 0; y < data.height; y++) {
// cant read from MST array above bounds, so check length first
// @ts-ignore
self.field[x] = x === self.field.length ? [] : self.field[x]
self.field[x][y] = y === self.field[x].length ? {} : self.field[x][y]
// merge to preserve flags on UI
self.field[x][y] = merge(self.field[x][y], data.field[x][y])
}
}
Object.assign(
self,
pick(
[
'width',
'height',
'bombCount',
'cellsLeft',
'isFinished',
'isWon',
'isLost'
],
data
)
)
}
示例3: writeFileStreamCB
function writeFileStreamCB(e, file) {
if (e) return observer.error(e);
observer.next(merge(
getFilenameMetaData(path || ''),
{file}
));
observer.complete();
}
示例4: merge
const frameReducer = (state: FrameState, action: FrameAction): FrameState => {
if (action.type === "cycle") {
if (state.view === "score") {
return merge(state, {
view: "pins",
squareNumber: 1,
})
} else {
const nextSquare = state.squareNumber + 1
if (nextSquare > state.frame.squares.length) {
return merge(state, { view: "score" })
}
return merge(state, {
view: "pins",
squareNumber: nextSquare,
})
}
}
return state
}
示例5:
this[actionType] = (_payload) => {
// Check to see if the payload is an object or not
let payload = R.is(Object, _payload) ? _payload : {};
// Attach action type to the payload
payload = R.merge(_payload, { actionType: actionType });
this.dispatcher.dispatch(payload);
// return payload for testing
return payload;
};
示例6: reduceHealth
const damageMinionHandler = (
state: Minion,
payload: DealDamagePayload
): Minion => {
const health = reduceHealth(state, payload.amount);
return R.merge(state, {
destroyed: health <= 0,
health: health,
});
};
示例7: reduceHealth
const damageHeroHandler = (state: Hero, payload: DealDamagePayload): Hero => {
const health = reduceHealth(state, payload.amount);
const destroyed = health <= 0;
return R.merge(state, {
armor: reduceArmor(state, payload.amount),
destroyed,
playState: destroyed ? PlayState.Lost : state.playState,
health: health,
});
};
示例8: switch
const panesReducer = (previousState = initialState, action) => {
if (isPanesModule(action)) {
switch (action.type) {
case panesActionTypes.OPEN: {
const {
payload: { pane },
} = action;
return { activeKey: pane.key, panes: { ...previousState.panes, [pane.key]: pane } };
}
case panesActionTypes.ACTIVE: {
const {
payload: { key },
} = action;
return { ...previousState, activeKey: key };
}
case panesActionTypes.CLOSE: {
const { activeKey, panes } = previousState;
const {
payload: { key },
} = action;
// prettier-ignore
const index = R.compose(R.indexOf(activeKey), R.keys)(panes);
const nextPanes = _.omit(panes, key);
const nextKeys = _.keys(nextPanes);
const nextKey =
activeKey && _.has(nextPanes, activeKey)
? activeKey
: // 關閉當前 tab 時定位到後麵一個 tab
nextKeys[_.min([index, nextKeys.length - 1]) as number];
return { activeKey: nextKey, panes: nextPanes };
}
case panesActionTypes.CLOSE_ALL: {
return {};
}
case panesActionTypes.CLOSE_WITHOUT: {
const {
payload: { activeKey },
} = action;
if (activeKey) {
const panes = R.pick([activeKey])(previousState.panes);
return R.merge(previousState, { panes });
}
return {};
}
default:
return { ...previousState, ...action.payload };
}
}
return previousState;
};
示例9: detect
export function detect(browser: Browser): Promise<FoundBrowser> {
let fn = browsers[browser.name]
if (!fn) {
// ok, maybe it is custom alias?
log('detecting custom browser %s on darwin', browser.name)
return linuxHelper.detect(browser)
}
return fn()
.then(merge({ name: browser.name }))
.catch(() => {
log('could not detect %s using traditional Mac methods', browser.name)
log('trying linux search')
return linuxHelper.detect(browser)
})
}
示例10: constructors
function constructors(state = [], action): Array<Constructor> {
// CREATE A NEW TEST CONTROLER
let newConstructorcopy = Array.from(state);
switch (action.type) {
case constants.CREATE_NEW_CONSTRUCTOR:
newConstructorcopy.push(R.merge(action.elements, {
browsers: R.clone(getState("browsersSelect"))
}));
return newConstructorcopy;
default:
return state;
}
}