本文整理汇总了TypeScript中lodash.without函数的典型用法代码示例。如果您正苦于以下问题:TypeScript without函数的具体用法?TypeScript without怎么用?TypeScript without使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了without函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: curryParams
function curryParams(
baseName: string,
sourceOverloadId: number,
sourceOverload: Overload,
interfaceIndex: number,
): Interface {
const params = getInterfaceParams(sourceOverload, interfaceIndex);
const interfaceTypeParams = getInterfaceTypeParams(sourceOverload, interfaceIndex);
const prevParams = _.without(sourceOverload.params, ...params);
const prevTypeParams = getUsedTypeParams(prevParams, sourceOverload.typeParams);
const typeParams = _.without(sourceOverload.typeParams, ...prevTypeParams);
// 1st overload takes no parameters and just returns the same interface (effectively a no-op)
// HACK: omit the parameterless overload because it's not very useful, and it causes the build to run out of memory
// This assumes params.length > 0, which is true because curryParams is only called when params.length >= 2.
/*const overloads: Overload[] = [{
typeParams: [],
params: [],
returnType: getInterfaceName(baseName, sourceOverloadId, interfaceIndex, interfaceTypeParams),
jsdoc: sourceOverload.jsdoc,
}];*/
const overloads: Overload[] = [];
const lastOverload = (1 << params.length) - 1;
for (let i = 1; i <= lastOverload; ++i) {
// xxxx i = number of parameters used by this overload
// const totalCombinations = nCk(params.length, i);
// i = binary representation of which parameters are used for this overload (reversed), e.g.
// 1 = 0001 -> 1000 = 1st parameter
// 6 = 1010 -> 0101 = 2nd and 4th parameters
const currentParams = params.map((p, j) => (i & (1 << j)) ? p : `${getParamName(p)}: __`);
while (currentParams.length > 0 && _.last(currentParams)!.endsWith("__"))
currentParams.pop(); // There's no point in passing a placeholder as the last parameter, so don't allow it.
const usedTypeParams = i < lastOverload ? getUsedTypeParams(currentParams, typeParams) : typeParams;
const combinedIndex = combineIndexes(interfaceIndex, i);
const passTypeParams = getInterfaceTypeParams(sourceOverload, combinedIndex);
const currentReturnType = i < lastOverload ? getInterfaceName(baseName, sourceOverloadId, combinedIndex, passTypeParams) : sourceOverload.returnType;
overloads.push({
typeParams: _.cloneDeep(usedTypeParams),
params: currentParams,
returnType: currentReturnType,
jsdoc: interfaceIndex === 0 ? sourceOverload.jsdoc : "",
});
}
const interfaceDef: Interface = {
name: getInterfaceName(baseName, sourceOverloadId, interfaceIndex, []),
typeParams: _.cloneDeep(interfaceTypeParams),
overloads,
constants: [],
};
// Remove the `extends` constraint from interface type parameters, because sometimes they extend things that aren't passed to the interface.
for (const typeParam of interfaceDef.typeParams) {
// 1. retain `extends keyof X` constraints so that TObject[TKey] still works.
// 2. retain `any[]` constraints so that variadic generics work.
if (!_.startsWith(typeParam.extends, "keyof ") && typeParam.extends !== "any[]")
delete typeParam.extends;
}
return interfaceDef;
}
开发者ID:csrakowski,项目名称:DefinitelyTyped,代码行数:60,代码来源:generate-fp.ts
示例2: kickMember
kickMember(member: GuildMember, propagate = true) {
// check if they're online, remove guildName (basically, call memberLeave)
const onlinePlayer = GameState.getInstance().getPlayer(member.name);
if(onlinePlayer && onlinePlayer.guildName !== this.name) return;
if(onlinePlayer) {
this.memberLeave(onlinePlayer);
// check if member is even in guild (ie, could just be an invite)
const memberInList = _.find(this.members, { name: member.name });
this.members = _.without(this.members, memberInList);
this.save(true);
} else if(propagate) {
GuildKickRedis(this.name, member.name);
} else if(!propagate) {
// if not online, dig into db and unset guildName
const memberInList = _.find(this.members, { name: member.name });
this.members = _.without(this.members, memberInList);
this.$guildDb.removePlayerFromGuild(member.name, this.name);
this.save(true);
}
}
开发者ID:IdleLands,项目名称:IdleLands,代码行数:26,代码来源:guild.ts
示例3: removeValue
removeValue(commandClass: number, index) {
if (this.commandClassExists(commandClass)) {
const filteredCommandClass = without(this.values[commandClass], index);
this.values.set(commandClass, filteredCommandClass);
}
}
开发者ID:lmeijvogel,项目名称:my_node_openzwave,代码行数:7,代码来源:Node.ts
示例4: function
.add<{ index: number }>("REMOVE_STEP", function (state, action) {
let seq = state.all[state.current];
let index = action.payload.index;
seq.body = _.without(seq.body, seq.body[index]);
markDirty(state);
return state;
})
开发者ID:roryaronson,项目名称:farmbot-web-frontend,代码行数:7,代码来源:reducer.ts
示例5: async
return async (dispatch: (action: any) => void, getState: () => GertyState, bundle: Bundle) => {
const state = getState();
const isWorkspace = relativePath === state.configuration.workspacePath;
const repositoryDataPath = isWorkspace
? "workspace.hosts"
: `repositories.${relativePath}.hosts`;
const hosts = _.get(state.data, repositoryDataPath, []) as Host[];
const newHosts = _.without(hosts, hosts[index]);
dispatch({
type: "set-data-value",
path: repositoryDataPath,
value: newHosts,
} as SetDataValueAction);
if (isWorkspace) {
await dispatch(saveWorkspace());
}
else {
await dispatch(saveRepository(relativePath));
}
};
开发者ID:atrauzzi,项目名称:Gerty,代码行数:29,代码来源:RemoveHost.ts
示例6: removeTag
removeTag(tag, evt) {
this.query.tag = _.without(this.query.tag, tag);
this.search();
this.giveSearchFocus = this.giveSearchFocus + 1;
evt.stopPropagation();
evt.preventDefault();
}
开发者ID:cboggs,项目名称:grafana,代码行数:7,代码来源:search.ts
示例7: getMetricFieldKey
static getMetricFieldKey(segment) {
const keys = _.keys(segment);
return _.filter(_.without(keys, 'start', 'end'), key => {
return _.isObject(segment[key]);
})[0];
}
开发者ID:grafana,项目名称:grafana,代码行数:7,代码来源:response_parser.ts
示例8: removeQuery
removeQuery() {
if (this.panelCtrl.__collapsedQueryCache) {
delete this.panelCtrl.__collapsedQueryCache[this.target.refId];
}
this.panel.targets = _.without(this.panel.targets, this.target);
this.panelCtrl.refresh();
}
开发者ID:0x01feng,项目名称:grafana,代码行数:8,代码来源:query_editor_row.ts
示例9: stopInstance
public stopInstance(dotEnsime: DotEnsime): void {
for (const instance of this.instances) {
if (instance.rootDir === dotEnsime.rootDir) {
instance.destroy()
this.instances = _.without(this.instances, instance)
}
}
}
开发者ID:ensime,项目名称:ensime-node,代码行数:8,代码来源:ensime-instance-manager.ts
示例10: stopInstance
stopInstance(dotEnsime: DotEnsime) {
for (let instance of this.instances) {
if(instance.rootDir == dotEnsime.rootDir) {
instance.destroy()
this.instances = _.without(this.instances, instance)
}
}
}
开发者ID:tomverran,项目名称:ensime-node,代码行数:8,代码来源:ensime-instance-manager.ts
注:本文中的lodash.without函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论