本文整理汇总了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;
}
示例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);
}
}
示例3: removeValue
removeValue(commandClass: number, index) {
if (this.commandClassExists(commandClass)) {
const filteredCommandClass = without(this.values[commandClass], index);
this.values.set(commandClass, filteredCommandClass);
}
}
示例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;
})
示例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));
}
};
示例6: removeTag
removeTag(tag, evt) {
this.query.tag = _.without(this.query.tag, tag);
this.search();
this.giveSearchFocus = this.giveSearchFocus + 1;
evt.stopPropagation();
evt.preventDefault();
}
示例7: getMetricFieldKey
static getMetricFieldKey(segment) {
const keys = _.keys(segment);
return _.filter(_.without(keys, 'start', 'end'), key => {
return _.isObject(segment[key]);
})[0];
}
示例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();
}
示例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)
}
}
}
示例10: stopInstance
stopInstance(dotEnsime: DotEnsime) {
for (let instance of this.instances) {
if(instance.rootDir == dotEnsime.rootDir) {
instance.destroy()
this.instances = _.without(this.instances, instance)
}
}
}