コード例 #1
0
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
0
ファイル: guild.ts プロジェクト: IdleLands/IdleLands
  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
0
ファイル: Node.ts プロジェクト: lmeijvogel/my_node_openzwave
  removeValue(commandClass: number, index) {
    if (this.commandClassExists(commandClass)) {
      const filteredCommandClass = without(this.values[commandClass], index);

      this.values.set(commandClass, filteredCommandClass);
    }
  }
コード例 #4
0
 .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
0
ファイル: RemoveHost.ts プロジェクト: atrauzzi/Gerty
    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
0
ファイル: search.ts プロジェクト: cboggs/grafana
 removeTag(tag, evt) {
   this.query.tag = _.without(this.query.tag, tag);
   this.search();
   this.giveSearchFocus = this.giveSearchFocus + 1;
   evt.stopPropagation();
   evt.preventDefault();
 }
コード例 #7
0
ファイル: response_parser.ts プロジェクト: grafana/grafana
  static getMetricFieldKey(segment) {
    const keys = _.keys(segment);

    return _.filter(_.without(keys, 'start', 'end'), key => {
      return _.isObject(segment[key]);
    })[0];
  }
コード例 #8
0
ファイル: query_editor_row.ts プロジェクト: 0x01feng/grafana
  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
0
 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
0
 stopInstance(dotEnsime: DotEnsime) {
   for (let instance of this.instances) {
     if(instance.rootDir == dotEnsime.rootDir) {
       instance.destroy()
       this.instances = _.without(this.instances, instance)
     }
   } 
 }