当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript lodash.pick函数代码示例

本文整理汇总了TypeScript中lodash.pick函数的典型用法代码示例。如果您正苦于以下问题:TypeScript pick函数的具体用法?TypeScript pick怎么用?TypeScript pick使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了pick函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: toResponseErrorJson

export function toResponseErrorJson(request: JsonRpcRequest, error: any) {
    return toJson({
        ...pick(request, ['jsonrpc', 'id']),
        error
    });
}
开发者ID:chevtche,项目名称:Brayns,代码行数:6,代码来源:testing.ts

示例2: getEvents

export function getEvents(req: EventsRequestMessage, timeout?: moment.Duration): Promise<EventsResponseMessage> {
  const queryString = propsToQueryString(_.pick(req, ["type", "target_id"]));
  return timeoutFetch(serverpb.EventsResponse, `${API_PREFIX}/events?${queryString}`, null, timeout);
}
开发者ID:jordanlewis,项目名称:cockroach,代码行数:4,代码来源:api.ts

示例3: transform

 resourcePrivileges: transform(applicationPrivilegesResponse, (result, value, key) => {
   result[key!] = pick(value, privileges);
 }),
开发者ID:spalger,项目名称:kibana,代码行数:3,代码来源:check_privileges.ts

示例4: _influxRequest

  _influxRequest(method: string, url: string, data: any, options?: any) {
    const currentUrl = this.urls.shift();
    this.urls.push(currentUrl);

    const params: any = {};

    if (this.username) {
      params.u = this.username;
      params.p = this.password;
    }

    if (options && options.database) {
      params.db = options.database;
    } else if (this.database) {
      params.db = this.database;
    }

    if (method === 'POST' && _.has(data, 'q')) {
      // verb is POST and 'q' param is defined
      _.extend(params, _.omit(data, ['q']));
      data = this.serializeParams(_.pick(data, ['q']));
    } else if (method === 'GET' || method === 'POST') {
      // verb is GET, or POST without 'q' param
      _.extend(params, data);
      data = null;
    }

    const req: any = {
      method: method,
      url: currentUrl + url,
      params: params,
      data: data,
      precision: 'ms',
      inspect: { type: 'influxdb' },
      paramSerializer: this.serializeParams,
    };

    req.headers = req.headers || {};
    if (this.basicAuth || this.withCredentials) {
      req.withCredentials = true;
    }
    if (this.basicAuth) {
      req.headers.Authorization = this.basicAuth;
    }

    if (method === 'POST') {
      req.headers['Content-type'] = 'application/x-www-form-urlencoded';
    }

    return this.backendSrv.datasourceRequest(req).then(
      result => {
        return result.data;
      },
      err => {
        if (err.status !== 0 || err.status >= 300) {
          if (err.data && err.data.error) {
            throw {
              message: 'InfluxDB Error: ' + err.data.error,
              data: err.data,
              config: err.config,
            };
          } else {
            throw {
              message: 'Network Error: ' + err.statusText + '(' + err.status + ')',
              data: err.data,
              config: err.config,
            };
          }
        }
      }
    );
  }
开发者ID:grafana,项目名称:grafana,代码行数:72,代码来源:datasource.ts

示例5: pick

					base.file.compatibility = f._compatibility.map((c: BuildDocument) => pick(c, ['id', 'label']));
开发者ID:freezy,项目名称:node-vpdb,代码行数:1,代码来源:file.blockmatch.api.ts

示例6: getDefinitions


//.........这里部分代码省略.........
          vm.lockedchanged = true;
        }
      },
      excludeItem(item: D1Item) {
        vm.onExcludedDrop(item.index, item.type);
      },
      onExcludedDrop(droppedId, type) {
        droppedId = getId(droppedId);
        if (
          alreadyExists(vm.excludeditems, droppedId) ||
          (vm.lockeditems[type] && alreadyExists([vm.lockeditems[type]], droppedId))
        ) {
          return;
        }
        const item = getItemById(droppedId, type)!;
        vm.excludeditems.push(item);
        vm.highestsets = vm.getSetBucketsStep(vm.active);
        if (vm.progress < 1) {
          vm.excludedchanged = true;
        }
      },
      onExcludedRemove(removedIndex) {
        vm.excludeditems = vm.excludeditems.filter(
          (excludeditem) => excludeditem.index !== removedIndex
        );
        vm.highestsets = vm.getSetBucketsStep(vm.active);
        if (vm.progress < 1) {
          vm.excludedchanged = true;
        }
      },
      lockEquipped() {
        const store = vm.activeCharacters[vm.selectedCharacter];
        const loadout = filterLoadoutToEquipped(store.loadoutFromCurrentlyEquipped(''));
        const items = _.pick(
          loadout.items,
          'helmet',
          'gauntlets',
          'chest',
          'leg',
          'classitem',
          'artifact',
          'ghost'
        );
        // Do not lock items with no stats
        vm.lockeditems.Helmet = items.helmet[0].stats ? (items.helmet[0] as D1Item) : null;
        vm.lockeditems.Gauntlets = items.gauntlets[0].stats ? (items.gauntlets[0] as D1Item) : null;
        vm.lockeditems.Chest = items.chest[0].stats ? (items.chest[0] as D1Item) : null;
        vm.lockeditems.Leg = items.leg[0].stats ? (items.leg[0] as D1Item) : null;
        vm.lockeditems.ClassItem = items.classitem[0].stats ? (items.classitem[0] as D1Item) : null;
        vm.lockeditems.Artifact = items.artifact[0].stats ? (items.artifact[0] as D1Item) : null;
        vm.lockeditems.Ghost = items.ghost[0].stats ? (items.ghost[0] as D1Item) : null;
        vm.highestsets = vm.getSetBucketsStep(vm.active);
        if (vm.progress < 1) {
          vm.lockedchanged = true;
        }
      },
      clearLocked() {
        vm.lockeditems = {
          Helmet: null,
          Gauntlets: null,
          Chest: null,
          Leg: null,
          ClassItem: null,
          Artifact: null,
          Ghost: null
        };
开发者ID:w1cked,项目名称:DIM,代码行数:67,代码来源:loadout-builder.component.ts

示例7: createStatementForIndex

function createStatementForIndex(tableName: string, index: ISequelizeIndex): string {
  const subset = pick(index, ['name', 'unique', 'fields'])
  return `queryInterface.addIndex('${tableName}', ${JSON.stringify(subset).replace(/"/g, `'`)})`
}
开发者ID:patrickhulce,项目名称:klay,代码行数:4,代码来源:migration.ts

示例8: serializeDetailed

	public serializeDetailed(metadata: { [p: string]: any }): { [p: string]: any } {
		return pick(metadata, 'format', 'size', 'depth', 'JPEG-Quality');
	}
开发者ID:freezy,项目名称:node-vpdb,代码行数:3,代码来源:image.metadata.ts

示例9: function

Wallets.prototype.add = function(params, callback) {
  params = params || {};
  common.validateParams(params, [], ['label', 'enterprise', 'type'], callback);

  // no need to pass keys for (single) custodial wallets
  if (params.type !== 'custodial') {
    if (Array.isArray(params.keys) === false || !_.isNumber(params.m) || !_.isNumber(params.n)) {
      throw new Error('invalid argument');
    }

    // TODO: support more types of multisig
    if (!this.baseCoin.isValidMofNSetup(params)) {
      throw new Error('unsupported multi-sig type');
    }
  }

  if (params.tags && Array.isArray(params.tags) === false) {
    throw new Error('invalid argument for tags - array expected');
  }

  if (params.clientFlags && Array.isArray(params.clientFlags) === false) {
    throw new Error('invalid argument for clientFlags - array expected');
  }

  if (params.isCold && !_.isBoolean(params.isCold)) {
    throw new Error('invalid argument for isCold - boolean expected');
  }

  if (params.isCustodial && !_.isBoolean(params.isCustodial)) {
    throw new Error('invalid argument for isCustodial - boolean expected');
  }

  const self = this;
  const walletParams: any = _.pick(params, ['label', 'm', 'n', 'keys', 'enterprise', 'isCold', 'isCustodial', 'tags', 'clientFlags', 'type']);

  // Additional params needed for xrp
  if (params.rootPub) {
    walletParams.rootPub = params.rootPub;
  }

  // In XLM this private key is used only for wallet creation purposes, once the wallet is initialized then we
  // update its weight to 0 making it an invalid key.
  // https://www.stellar.org/developers/guides/concepts/multi-sig.html#additional-signing-keys
  if (params.rootPrivateKey) {
    walletParams.rootPrivateKey = params.rootPrivateKey;
  }

  if (params.initializationTxs) {
    walletParams.initializationTxs = params.initializationTxs;
  }

  if (params.disableTransactionNotifications) {
    walletParams.disableTransactionNotifications = params.disableTransactionNotifications;
  }

  return self.bitgo.post(self.baseCoin.url('/wallet')).send(walletParams).result()
  .then(function(newWallet) {
    return {
      wallet: new self.coinWallet(self.bitgo, self.baseCoin, newWallet)
    };
  })
  .nodeify(callback);
};
开发者ID:BitGo,项目名称:BitGoJS,代码行数:63,代码来源:wallets.ts

示例10: create

	/**
	 * Creates a new release.
	 *
	 * @see POST /v1/releases
	 * @param {Context} ctx Koa context
	 */
	public async create(ctx: Context) {

		const span = this.apmStartSpan('ReleaseApi.create');
		let release: ReleaseDocument;
		const now = new Date();

		try {
			// defaults
			if (ctx.request.body.versions) {
				ctx.request.body.versions.forEach((version: ReleaseVersionDocument) => {
					version.released_at = version.released_at || now.toISOString();
					if (version.files) {
						const releasedAt = version.released_at || now.toISOString();
						version.files.forEach((file: ReleaseVersionFileDocument) => {
							file.released_at = file.released_at || releasedAt;
						});
					}
				});
			}

			logger.info(ctx.state, '[ReleaseApi.create] Body: %s', JSON.stringify(ctx.request.body));
			const newRelease = await state.models.Release.getInstance(ctx.state, extend(ctx.request.body, {
				_created_by: ctx.state.user._id,
				modified_at: now,
				created_at: now,
			}));

			release = newRelease;
			await this.preProcess(ctx, newRelease.getFileIds());
			await release.validate();

			logger.info(ctx.state, '[ReleaseApi.create] Validations passed.');
			release.versions = orderBy(release.versions, ['released_at'], ['desc']);
			release.released_at = release.versions[0].released_at as Date;
			await release.save();

			await this.postProcess(ctx.state, release.getPlayfieldImageIds());

			logger.info(ctx.state, '[ReleaseApi.create] Release "%s" created.', release.name);
			await release.activateFiles();

			logger.info(ctx.state, '[ReleaseApi.create] All referenced files activated, returning object to client.');

			release = await this.getDetails(release._id);
			const game = release._game as GameDocument;

			// log event
			await LogEventUtil.log(ctx, 'create_release', true, {
				release: state.serializers.Release.detailed(ctx, release, { thumbFormat: 'medium', includedFields: ['moderation'] }),
				game: pick(state.serializers.Game.simple(ctx, game), ['id', 'title', 'manufacturer', 'year', 'ipdb', 'game_type']),
			}, {
				release: release._id,
				game: release._game._id,
			});

			// invalidate cache
			await apiCache.invalidateCreatedRelease(ctx.state, release);
			if (game.game_type === 'og' && release.moderation.is_approved && game.counter.releases === 0) {
				// empty original games aren't shown in lists, so we need to invalidate when that changes.
				await apiCache.invalidateCreatedGame(ctx.state);
			}

			this.success(ctx, state.serializers.Release.detailed(ctx, release, { includedFields: ['is_active'] }), 201);

		} catch (err) {
			throw err;

		} finally {
			this.apmEndSpan(span);
		}

		this.noAwait(async () => {

			// notify (co-)author(s)
			for (const author of release.authors) {
				if ((author._user as UserDocument).id !== ctx.state.user.id) {
					await mailer.releaseAdded(ctx.state, ctx.state.user, author._user as UserDocument, release);
				}
			}

			// handle moderation mails
			if (release.moderation.is_approved) {
				await (release._game as GameDocument).incrementCounter('releases');
				await mailer.releaseAutoApproved(ctx.state, ctx.state.user, release);
			} else {
				await mailer.releaseSubmitted(ctx.state, ctx.state.user, release);
			}

			// update game modification date
			await (release._game as GameDocument).update({ modified_at: new Date() });
		});
	}
开发者ID:freezy,项目名称:node-vpdb,代码行数:98,代码来源:release.api.ts


注:本文中的lodash.pick函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。