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


TypeScript lodash.extend函数代码示例

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


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

示例1: set

 set(config) {
     _.extend(this, DEFAULTS, config);
 }
开发者ID:xsurge83,项目名称:d3-charts,代码行数:3,代码来源:main.ts

示例2: function

 const decorator = function (Target: any, propertyKey: string, propertyIndex) {
     const handler = getHandler(Target, propertyKey);
     const bodyConfig = handler.bodyConfig || {};
     _.extend(bodyConfig, {index: propertyIndex, factory: factory});
 };
开发者ID:vsuhanov,项目名称:listocity-server,代码行数:5,代码来源:HandleRequest.ts

示例3: create

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

		// default type is "personal".
		ctx.request.body.type = ctx.request.body.type || 'personal';

		// check if the plan allows application token creation
		if (scope.has(ctx.request.body.scopes, Scope.ALL) && !ctx.state.user.planConfig.enableAppTokens) {
			throw new ApiError('Your current plan "%s" does not allow the creation of application tokens. Upgrade or contact an admin.', ctx.state.user.planConfig.id).status(401);
		}

		// tokenType == "jwt" means the token comes from a "fresh" login (not a
		// refresh token) from either user/password or oauth2.
		if (ctx.state.tokenType === 'jwt') {

			// in this case, the user is allowed to create login tokens without
			// additionally supplying the password.
			if (!scope.has(ctx.request.body.scopes, Scope.LOGIN) && !ctx.request.body.password) {
				throw new ApiError('You cannot create other tokens but login tokens without supplying a password, ' +
					'even when logged with a "short term" token.').warn().status(401);
			}
		} else {

			// if the token type is not "jwt" (but "jwt-refreshed" or "access-token"),
			// the user must provide a password.
			if (!ctx.request.body.password) {
				throw new ApiError('When logged with a "long term" token (either from a X-Token-Refresh header or ' +
					'from an access token), you must provide your password.').warn().status(401);
			}
		}

		// in any case, if a password is supplied, check it.
		if (ctx.request.body.password) {

			if (!ctx.state.user.passwordSet()) {
				throw new ApiError('First set a password under your profile before adding tokens.').status(400);
			}
			if (!ctx.state.user.authenticate(ctx.request.body.password)) {
				throw new ApiError('Wrong password.').warn().status(401);
			}
		}

		// for provider tokens, check additional permissions.
		let newToken: TokenDocument;
		if (ctx.request.body.type === 'provider') {
			const granted = await acl.isAllowed(ctx.state.user.id, 'tokens', 'provider-token');
			if (!granted) {
				throw new ApiError('Permission denied.').status(401);
			}
			newToken = new state.models.Token(extend(ctx.request.body, {
				label: sanitize(ctx.request.body.label),
				is_active: true,
				created_at: new Date(),
				expires_at: new Date(new Date().getTime() + 315360000000), // 10 years
				_created_by: ctx.state.user._id,
			}));

		} else {
			newToken = new state.models.Token(extend(ctx.request.body, {
				label: ctx.request.body.label || ctx.get('user-agent'),
				is_active: true,
				created_at: new Date(),
				expires_at: new Date(new Date().getTime() + 31536000000), // 1 year
				_created_by: ctx.state.user._id,
			}));
		}
		await newToken.save();

		logger.info(ctx.state, '[TokenApi.create] Token "%s" successfully created.', newToken.label);
		this.success(ctx, state.serializers.Token.detailed(ctx, newToken), 201);
	}
开发者ID:freezy,项目名称:node-vpdb,代码行数:76,代码来源:token.api.ts

示例4: convertAggregatorToQueryObject

 private convertAggregatorToQueryObject(aggregatorDefinition: Aggregator, defaultInterval: string) {
     const convertedAggregator =
         this.samplingParameterConverter.convertSamplingParameters(_.cloneDeep(aggregatorDefinition));
     return _.extend({name: convertedAggregator.name},
         this.convertParameters(convertedAggregator, defaultInterval));
 }
开发者ID:ppbizapps,项目名称:kairosdb-datasource,代码行数:6,代码来源:query_builder.ts

示例5: withVertices

 // return a new polyhedron with the given vertices
 withVertices(vertices: VertexArg[]) {
   _.extend(this.solidData, { vertices: vertices.map(normalizeVertex) });
   return this;
 }
开发者ID:tessenate,项目名称:polyhedra-viewer,代码行数:5,代码来源:SolidBuilder.ts

示例6: function

  this.show = function(options) {
    if (openDrop) {
      openDrop.close();
      openDrop = null;
    }

    var scope = _.extend($rootScope.$new(true), options.model);
    var drop;

    var cleanUp = () => {
      setTimeout(() => {
        scope.$destroy();

        if (drop.tether) {
          drop.destroy();
        }

        if (options.onClose) {
          options.onClose();
        }
      });

      openDrop = null;
    };

    scope.dismiss = () => {
      drop.close();
    };

    var contentElement = document.createElement('div');
    contentElement.innerHTML = options.template;

    $compile(contentElement)(scope);

    $timeout(() => {
      drop = new Drop({
        target: options.element,
        content: contentElement,
        position: options.position,
        classes: options.classNames || 'drop-popover',
        openOn: options.openOn,
        hoverCloseDelay: 200,
        tetherOptions: {
          constraints: [{ to: 'scrollParent', attachment: 'together' }],
        },
      });

      drop.on('close', () => {
        cleanUp();
      });

      openDrop = drop;
      openDrop.open();
    }, 100);

    // return close function
    return function() {
      if (drop) {
        drop.close();
      }
    };
  };
开发者ID:arcolife,项目名称:grafana,代码行数:62,代码来源:popover_srv.ts

示例7:

 _.each(this.preBootModules, module => {
   _.extend(module, this.registerFunctions);
 });
开发者ID:GPegel,项目名称:grafana,代码行数:3,代码来源:app.ts

示例8: function

import * as nunjucks from 'nunjucks';
import * as path from 'path';
import * as _ from 'lodash';

declare var hexo: HexoStatic;

var nunjucksDefaults: NunjucksOptions = {
    autoescape: false,
    watch: false,
};

if (typeof hexo.config.nunjucks == 'undefined') {
    hexo.config.nunjucks = {};
}

_.extend(hexo.config.nunjucks, nunjucksDefaults);

var renderer: HexoSyncRenderer = function (data, locals) {
    
    var templateDir = path.dirname(data.path);
    var env = nunjucks.configure(templateDir, hexo.config.nunjucks);
    
    return env.renderString(data.text, locals);  
}

hexo.extend.renderer.register('nunjucks', 'html', renderer, true);
hexo.extend.renderer.register('j2', 'html', renderer, true);
开发者ID:kfitzgerald,项目名称:hexo-renderer-nunjucks,代码行数:27,代码来源:index.ts

示例9: it

      it('should create local prebuild', co(function *() {
        const fundingAddress = 't2CgWUKFKRaKzPXQF2cooNFtVZR1gTM8xxM';
        const fundingRedeemScript = '522103dc94182103c93690c2bca3fe013c19c956b940645b11b0a752e0e56b156bf4e22103b5f4aa0348bf339400ed7e16c6e960a4a46a1ea4c4cbe21abf6d0403161dc4f22103706ff6b11a8d9e3d63a455788d5d96738929ca642f1f3d8f9acedb689e759f3753ae';

        const receiveAddress = 't2HPJLxLLXLbKkfQngpwhZCGKAhHuqyqPk4';
        const unspent = {
          id: '8047839532dcfec617661120e1baa0e3b9135662ac8e1f97561e500d430dccb1:0',
          address: fundingAddress,
          value: 300000000,
          valueString: '300000000',
          blockHeight: 999999999,
          date: '2018-05-20T01:44:13.713Z'
        };
        const [txHash, vout] = unspent.id.split(':');

        const txb = new bitGoUtxoLib.TransactionBuilder(testCoin.network);
        txb.addInput(txHash, parseInt(vout, 16), 0xffffffff);
        txb.addOutput(receiveAddress, unspent.value - 50000);

        const tx = txb.buildIncomplete();
        tx.coin = coin.type;
        tx.overwintered = 1;
        tx.versionGroupId = 0x03C48270;

        const prebuild = {
          txHex: tx.toHex(),
          txInfo: {
            unspents: [
              {
                chain: 1,
                index: 113,
                redeemScript: fundingRedeemScript,
                value: 300000000
              }
            ]
          }
        };

        const wallet = new Wallet(bitgo, testCoin, {});
        const halfSigned = yield wallet.signTransaction({
          txPrebuild: prebuild,
          prv: keychains[0].prv
        });
        const halfSignedTx = bitGoUtxoLib.Transaction.fromHex(halfSigned.txHex, testCoin.network);
        halfSignedTx.network.coin.should.equal('zec');
        halfSignedTx.version.should.equal(bitGoUtxoLib.Transaction.ZCASH_SAPLING_VERSION);
        halfSignedTx.versionGroupId.should.equal(2301567109);
        halfSignedTx.overwintered.should.equal(1);
        halfSignedTx.expiryHeight.should.equal(0);
        halfSigned.txHex.should.equal('0400008085202f8901b1cc0d430d501e56971f8eac625613b9e3a0bae120116617c6fedc329583478000000000b600473044022034c624b44051fd6d3cf665b6117a614c683c918f9b6087d65d7043479bb60c3402205eef0d7032c98902c56a4337c4de7feba44704786fa9d4968af1699e1eede5b80100004c69522103dc94182103c93690c2bca3fe013c19c956b940645b11b0a752e0e56b156bf4e22103b5f4aa0348bf339400ed7e16c6e960a4a46a1ea4c4cbe21abf6d0403161dc4f22103706ff6b11a8d9e3d63a455788d5d96738929ca642f1f3d8f9acedb689e759f3753aeffffffff01b0dfe0110000000017a91476dce7beb23d0e0d53edf5895716d4c80dce60938700000000000000000000000000000000000000');

        const halfSignedPrebuild = _.extend({}, prebuild, halfSigned);
        const fullySigned = yield wallet.signTransaction({
          txPrebuild: halfSignedPrebuild,
          prv: keychains[2].prv,
          isLastSignature: true
        });
        const fullySignedTx = bitGoUtxoLib.Transaction.fromHex(fullySigned.txHex, testCoin.network);
        fullySignedTx.network.coin.should.equal('zec');
        fullySignedTx.version.should.equal(bitGoUtxoLib.Transaction.ZCASH_SAPLING_VERSION);
        fullySignedTx.versionGroupId.should.equal(2301567109);
        fullySignedTx.overwintered.should.equal(1);
        fullySignedTx.expiryHeight.should.equal(0);
        fullySignedTx.getId().should.equal('d16b14e8312661ca7570f587b102610c35e97e87c0668349ea216f9b0173864d');

        fullySigned.txHex.should.equal('0400008085202f8901b1cc0d430d501e56971f8eac625613b9e3a0bae120116617c6fedc329583478000000000fc00473044022034c624b44051fd6d3cf665b6117a614c683c918f9b6087d65d7043479bb60c3402205eef0d7032c98902c56a4337c4de7feba44704786fa9d4968af1699e1eede5b801473044022052df70f6e0e40082382cea9ce4f76347c436f92f56523ca9a2198a45de5145fa0220782f43b17d9013c9a611a027ab139f45c45a0f0e942525aa3e6e63796df1918f014c69522103dc94182103c93690c2bca3fe013c19c956b940645b11b0a752e0e56b156bf4e22103b5f4aa0348bf339400ed7e16c6e960a4a46a1ea4c4cbe21abf6d0403161dc4f22103706ff6b11a8d9e3d63a455788d5d96738929ca642f1f3d8f9acedb689e759f3753aeffffffff01b0dfe0110000000017a91476dce7beb23d0e0d53edf5895716d4c80dce60938700000000000000000000000000000000000000');
      }));
开发者ID:BitGo,项目名称:BitGoJS,代码行数:67,代码来源:zec.ts

示例10: checkOneBrowser

 return Bluebird.map(browser.binary, (binary: string) => {
   return checkOneBrowser(extend({}, browser, { binary }))
 })
开发者ID:YOU54F,项目名称:cypress,代码行数:3,代码来源:detect.ts

示例11: resolve

 (res: any) => {
     const remotes = _.zipObject(_.map(res, "key"), _.map(res, "value"));
     _.extend(translations, remotes);
     resolve(translations);
 },
开发者ID:Opetushallitus,项目名称:eperusteet,代码行数:5,代码来源:lokalisointi.ts

示例12:

 .then(function() {
   return self.recreateAndSignTransaction(_.extend(params, extendParams));
 });
开发者ID:BitGo,项目名称:BitGoJS,代码行数:3,代码来源:pendingapproval.ts

示例13: _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 === 'GET') {
      _.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;
    }

    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:CorpGlory,项目名称:grafana,代码行数:63,代码来源:datasource.ts

示例14: create

	/**
	 * Creates a new backglass.
	 *
	 * @see POST /v1/backglasses
	 * @see POST /v1/games/:gameId/backglasses
	 * @param {Context} ctx Koa context
	 */
	public async create(ctx: Context) {

		const now = new Date();

		const backglass = await state.models.Backglass.getInstance(ctx.state, extend(ctx.request.body, {
			_created_by: ctx.state.user._id,
			created_at: now,
		}));

		if (isArray(backglass.versions)) {
			backglass.versions.forEach(version => {
				if (!version.released_at) {
					version.released_at = now;
				}
			});

			// if this comes from /games/:gameId/backglasses, we already have a game id.
			if (ctx.params.gameId) {
				const game = await state.models.Game.findOne({ id: sanitize(ctx.params.gameId) }).exec();
				if (!game) {
					throw new ApiError('No such game with ID "%s".', ctx.params.gameId).status(404);
				}
				backglass._game = game._id;
			}

			// check for available rom
			if (backglass.versions[0] && !backglass._game) {
				let backglassFile;
				const file = await state.models.File.findById(backglass.versions[0]._file).exec();
				if (file && file.metadata && file.metadata.gamename) {
					backglassFile = file;
					const rom = await state.models.Rom.findOne({ id: file.metadata.gamename }).exec();
					if (rom) {
						logger.info(ctx.state, '[ctrl|backglass] Linking backglass to same game %s as rom "%s".', rom._game, backglassFile.metadata.gamename);
						backglass._game = rom._game;
					}
				}
			}
		}
		await backglass.save();
		logger.info(ctx.state, '[BackglassApi.create] Backglass "%s" successfully created.', backglass.id);
		await backglass.activateFiles();

		const populatedBackglass = await state.models.Backglass.findById(backglass._id)
			.populate({ path: '_game' })
			.populate({ path: 'authors._user' })
			.populate({ path: 'versions._file' })
			.populate({ path: '_created_by' })
			.exec();

		// invalidate cache
		await apiCache.invalidateCreatedBackglass(ctx.state, populatedBackglass);

		// event log
		await LogEventUtil.log(ctx, 'create_backglass', true, {
			backglass: state.serializers.Backglass.detailed(ctx, populatedBackglass),
			game: state.serializers.Game.reduced(ctx, populatedBackglass._game as GameDocument),
		}, {
			backglass: populatedBackglass._id,
			game: populatedBackglass._game._id,
		});

		// return object
		this.success(ctx, state.serializers.Backglass.detailed(ctx, populatedBackglass), 201);

		this.noAwait(async () => {
			// send moderation mail
			if (populatedBackglass.moderation.is_approved) {
				await mailer.backglassAutoApproved(ctx.state, ctx.state.user, populatedBackglass);
			} else {
				await mailer.backglassSubmitted(ctx.state, ctx.state.user, populatedBackglass);
			}
		});
	}
开发者ID:freezy,项目名称:node-vpdb,代码行数:81,代码来源:backglass.api.ts

示例15: addStyle

export function addStyle(domElement, style) {
  assert(_.isElement(domElement), 'addStyle expects the first argument to be a DOM element');
  assert(_.isPlainObject(style), 'addStyle expects the second argument to be a hash');

  _.extend(domElement.style, style);
}
开发者ID:gurdiga,项目名称:xo,代码行数:6,代码来源:addStyle.ts


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