本文整理汇总了TypeScript中lodash.pickBy函数的典型用法代码示例。如果您正苦于以下问题:TypeScript pickBy函数的具体用法?TypeScript pickBy怎么用?TypeScript pickBy使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pickBy函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: getStandaloneSecondarySections
export function getStandaloneSecondarySections(sysInfoData: SysInfo): SysInfoSection {
return {
Web: pickBy(sysInfoData, (_, key) => key.startsWith('Web')) as SysValueObject,
'Compute Engine': pickBy(sysInfoData, (_, key) =>
key.startsWith('Compute Engine')
) as SysValueObject,
'Search Engine': pickBy(sysInfoData, (_, key) => key.startsWith('Search')) as SysValueObject
};
}
示例2: getRefPaths
function getRefPaths(obj: object, paths: { [key: string]: any }): { [key: string]: string } {
// pick because it's an object (map)
const singleRefsFiltered = pickBy(paths, schemaType => schemaType.options && schemaType.options.ref);
const singleRefs = mapValues(singleRefsFiltered, schemaType => schemaType.options.ref);
const arrayRefsFiltered = pickBy(paths, schemaType => schemaType.caster && schemaType.caster.instance && schemaType.caster.options && schemaType.caster.options.ref);
const arrayRefs = mapValues(arrayRefsFiltered, schemaType => schemaType.caster.options.ref);
return explodePaths(obj, singleRefs, arrayRefs);
}
示例3: getStandaloneSecondarySections
export function getStandaloneSecondarySections(sysInfoData: T.SysInfoBase): T.SysInfoSection {
return {
Web: pickBy(sysInfoData, (_, key) => key.startsWith(WEB_PREFIX)) as T.SysInfoValueObject,
'Compute Engine': pickBy(sysInfoData, (_, key) =>
key.startsWith(CE_FIELD_PREFIX)
) as T.SysInfoValueObject,
'Search Engine': pickBy(sysInfoData, (_, key) =>
key.startsWith(SEARCH_PREFIX)
) as T.SysInfoValueObject
};
}
示例4: it
it('#remove', () => {
let arr = [
{ id: '10' },
{ id: '15' },
{ id: '18' },
{ id: '17' },
{ id: '10', name: 'mo' },
];
console.log(_.find(arr, _.pickBy(route.match('/name=mo'), _.identity)));
_.remove(arr, _.pickBy(route.match('/10'), _.identity));
expect(arr.length).toEqual(3);
});
示例5: infer
function infer(argv: IArgv): Stream {
return argv.stream = handler(argv)
.pipe(eclint.infer(_.pickBy(argv) as eclint.InferOptions))
.pipe(tap((file) => {
console.log(file.contents + '');
}));
}
示例6: async
return async (dispatch: (action: any) => void, getState: () => GertyState, bundle: Bundle) => {
const state = getState();
const process = _.get<Process>(state.data, buildProcessDataPath(globalProcessId));
const commandCwd = buildCommandCwd(state.configuration, globalProcessId, process.stopCommand);
const stopCommand = [
process.stopCommand.executable,
...process.stopCommand.parameters,
];
const processManager = bundle.container
.get<ProcessManager>(gertyDomainSymbols.ProcessManager);
const deferred = createDeferred();
const stopCommandPid = await processManager.run(stopCommand, commandCwd);
processManager.onExit(stopCommandPid, () => deferred.resolve());
await deferred.promise;
const processHistoryState = JSON.parse(localStorage.getItem("gerty:process-history")) as ProcessHistoryState || {};
const updatedProcessHistoryState = _.pickBy(processHistoryState, (processHistories: ProcessHistory[], historicGlobalProcessId: GlobalProcessId) =>
historicGlobalProcessId !== globalProcessId);
localStorage.setItem("gerty:process-history", JSON.stringify(updatedProcessHistoryState));
};
示例7: describeRoom
export default function describeRoom(room: Cell.Room, map: Map.Map): string {
let description: string;
if (Cell.isTreasureRoom(room)) {
description = 'Behold! The riches of Xanadu!\nYou have found the treasure room!\n';
} else if (Cell.isPassageRoom(room)) {
description = 'You have reached a passage room!\n';
} else {
description = 'It is a dark room.\n';
}
const allNeighbors = Cell.getCardinalNeighboringPositions({
row: room.row,
col: room.col
});
const pathNeighbors = _.pickBy(allNeighbors, (pos) => Map.isValidRoom(map, pos));
const pathDirections = _.keys(pathNeighbors);
if (pathDirections.length === 1) {
description += `There is one path to the ${pathDirections[ 0 ]}.`;
} else {
const dirStr = `${_.initial(pathDirections).join(', ')} and ${_.last(pathDirections)}`;
description += `There are paths to the ${dirStr}.`;
}
return description;
}
示例8: get
export async function get(doi: string): Promise<CSL.Data | ResponseError> {
const response = await fetch(`https://doi.org/${encodeURIComponent(doi)}`, {
headers: {
accept: 'application/vnd.citationstyles.csl+json',
},
});
if (!response.ok) {
return new ResponseError(doi, response);
}
const data: any = _.pickBy<CSL.Data>(
await response.json(),
(value, key: any) => {
if (CSL_KEYS.indexOf(key) === -1) {
return false;
}
if (
CSL_STRING_KEYS.indexOf(key) >= 0 &&
typeof value !== 'string'
) {
return false;
}
if (
CSL_NUMBER_KEYS.indexOf(key) >= 0 &&
typeof value !== 'number'
) {
return false;
}
return key !== 'abstract';
},
);
return data;
}
示例9: async
return async (dispatch: (action: any) => void, getState: () => GertyState, bundle: Bundle) => {
const state = getState();
const activePids = _.map(state.configuration.processStates, (processState) =>
processState.pid);
const processHistoryState = JSON.parse(localStorage.getItem("gerty:process-history")) as ProcessHistoryState || {};
const orphanedProcesses = _.pickBy(processHistoryState, (processHistories: ProcessHistory[]) =>
!_.chain(processHistories)
.map((processHistory: ProcessHistory) => processHistory.pid)
.flatten()
.difference(activePids)
.isEmpty()
.value());
const kills = _.chain(orphanedProcesses)
.map((processHistory: ProcessHistory[], globalProcessId: GlobalProcessId) =>
dispatch(stopOrphanedProcess(globalProcessId, processHistory)))
.uniq()
.value();
localStorage.setItem("gerty:process-history", JSON.stringify({}));
await Promise.all(kills);
};
示例10: getItemRequirementsString
static getItemRequirementsString(item) {
const newItem = _.pickBy(item, (val, key) => {
return _.includes(key, 'Req') && val > 0;
});
return _(newItem)
.map(ItemInfo.parseRequirement)
.join('\n');
}