本文整理汇总了TypeScript中lodash.forOwn函数的典型用法代码示例。如果您正苦于以下问题:TypeScript forOwn函数的具体用法?TypeScript forOwn怎么用?TypeScript forOwn使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了forOwn函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: callback
worker.addEventListener("message", ({data}) => {
_.forOwn(callbacks, (callback, name) => {
if (data.type == name) {
callback(data.content)
}
})
})
示例2: switch
export const pricingServiceReducer = (state: PricingOperationsReducerState = {}, action): PricingOperationsReducerState => {
const { type, payload } = action
switch (type) {
case ACTION_TYPES.SPOT_PRICES_UPDATE:
const updatedPrices = keyBy(action.payload, 'symbol')
const updatedPricesDataObj = {}
_.forOwn(updatedPrices, (value, key) => {
const prevItem = state[key] || {}
const newItem:SpotPriceTick = { ...value }
newItem.priceStale = false
newItem.priceMovementType = getPriceMovementType(prevItem, newItem)
updatedPricesDataObj[key] = newItem
})
return { ...state, ...updatedPricesDataObj }
case ACTION_TYPES.PRICING_STALE:
return {
...state,
[payload.symbol]: {
...state[payload.symbol],
priceStale: true,
notification: buildNotification(null, stalePriceErrorMessage)
}
}
default:
return state
}
}
示例3:
_.forEach(result, (resource) => {
_.forOwn(resource["metrics"], (id, name) => {
if (re.test(name)) {
metrics[id] = this._compute_label(user_label, resource, name, target.aggregator);
}
});
});
示例4: it
it('successful password update', co(function *isSuccessfulPasswordUpdate() {
const oldPassword = 'oldPassword';
const newPassword = 'newPassword';
const otherPassword = 'otherPassword';
nock(bgUrl)
.post('/api/v1/user/encrypted')
.reply(200, {
keychains: {
xpub1: bitgo.encrypt({ input: 'xprv1', password: oldPassword }),
xpub2: bitgo.encrypt({ input: 'xprv2', password: otherPassword })
},
version: 1
});
const result = yield keychains.updatePassword({ oldPassword: oldPassword, newPassword: newPassword });
_.forOwn(result.keychains, function(encryptedXprv, xpub) {
xpub.should.startWith('xpub');
try {
const decryptedPrv = bitgo.decrypt({ input: encryptedXprv, password: newPassword });
decryptedPrv.should.startWith('xprv');
} catch (e) {
// the decryption didn't work because of the wrong password, this is one of the keychains that didn't match
// the old password
e.message.should.startWith('password error');
}
});
result.should.hasOwnProperty('version');
}));
示例5: transform
transform(iterable: any, args: any[]): any {
let result = [];
_.forOwn(iterable, (value, key) => {
result.push({key: key, value: value, id: cuid() });
});
return result;
}
示例6:
_.forEach(groupPaths, (groupPath) => {
badgesByGroup[groupPath] = [];
_.forOwn(badges, (badge) => {
if (_.includes(badge.groups, groupPath)) {
badgesByGroup[groupPath].push(badge);
}
});
});
示例7: getQueryStringPrams
private getQueryStringPrams(settings: RequestSettings): HttpParams {
let queryParams = new HttpParams();
_.forOwn(settings.queryString.getParams(), (value: string, key: string) => {
queryParams = queryParams.set(key, value);
});
return queryParams;
}
示例8: objectToMap
function objectToMap(input: object): Map<string, object> {
const result = new Map<string, object>();
forOwn(input, (value, key) => {
result.set(key, value);
});
return result;
}
示例9: buildLookupTable
private buildLookupTable(periodStarts: object): Map<string, TimePeriod> {
let result = new Map<string, TimePeriod>();
forOwn(periodStarts, (value, key) => {
result.set(key, value);
});
return result;
}
示例10: replaceTemplateTokensWithValues
private replaceTemplateTokensWithValues(urlTemplate: string, tokens: {[name: string]:any} ): string {
forOwn(tokens, (value: any, key: string) => {
urlTemplate = this.replaceRouteTokens(urlTemplate, key, value);
urlTemplate = this.replaceRouteTokens(urlTemplate, lowerFirst(key), value);
});
return this.removeOptionalRouteTokens(urlTemplate);
}
示例11: forOwn
return forOwn(groupsByProvider, (groupsByRegion: IRegions, provider: string) => {
forOwn(groupsByRegion, (groups: IRegionAccount[]) => {
groups.forEach((group: IRegionAccount) => {
group.provider = provider;
group.account = account;
});
});
securityGroups.push({account, provider, securityGroups: groupsByProvider[provider]});
});
示例12: forOwn
return forOwn(groupsByProvider, (groupsByRegion, provider) => {
forOwn(groupsByRegion, (groups: ISecurityGroup[]) => {
groups.forEach((group) => {
group.provider = provider;
group.account = account;
});
});
securityGroups.push({account, provider, securityGroups: groupsByProvider[provider]});
});
示例13: function
return function(items, checkModel) {
const keyArr = [];
_.forOwn(checkModel, (value, key) => {
if (value) {
keyArr.push(key);
}
});
return _.filter(items, (item: any) => _.some(keyArr, key => key === item.OrderStatus));
};
示例14: getOperatonFunctionName
export function getOperatonFunctionName(term: ParsedTerm): string {
if (term.type !== 'function') {
return null;
}
let result = null;
_.forOwn(operationFunctions, (value, key) => {
if (value === term.name) {
result = key;
return false;
}
});
_.forOwn(singleArgOperationFunctions, (value, key) => {
if (value === term.name) {
result = key;
return false;
}
});
return result;
}
示例15: getLinks
private getLinks(resource: IHalResource): Link[] {
let links: Link[] = [];
_.forOwn(resource._links, (link: Link, rel: string) => {
link.rel = rel;
links.push(link);
});
return links;
}