本文整理汇总了TypeScript中lodash.defaults函数的典型用法代码示例。如果您正苦于以下问题:TypeScript defaults函数的具体用法?TypeScript defaults怎么用?TypeScript defaults使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了defaults函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor($scope, $injector, $rootScope) {
super($scope, $injector);
this.$rootScope = $rootScope;
_.defaults(this.panel, panelDefaults);
_.defaults(this.panel.legend, panelDefaults.legend);
this.events.on('data-received', this.onDataReceived.bind(this));
this.events.on('data-error', this.onDataError.bind(this));
this.events.on('data-snapshot-load', this.onDataReceived.bind(this));
this.events.on('init-edit-mode', this.onInitEditMode.bind(this));
}
示例2: addModels
function addModels(kiln) {
extensionA = _.defaults({name: 'A'}, extensionApi)
const extensionB = _.defaults({name: 'B'}, extensionApi)
const extensionC = _.defaults({name: 'C'}, extensionApi)
jest.spyOn(extensionA, 'build').mockReturnValue({resultA: 'foo'})
jest.spyOn(extensionB, 'build').mockReturnValue({resultB: 'bar'})
jest.spyOn(extensionC, 'build').mockReturnValue({resultC: 'baz'})
kiln
.addModel({name: 'user', model})
.addExtension({modelName: 'user', extension: extensionA})
.addExtension({modelName: 'user', extension: extensionB})
.addModel({name: 'photo', model})
.addExtension({modelName: 'photo', extension: extensionC})
}
示例3: async
export const shipOrder = async (transactionId: string, orderLines?: Array<IMollieOrderLine>, tracking?: IMollieTracking): Promise<any> => {
const [
{ default: store },
] = await Promise.all([
import(/* webpackPrefetch: true, webpackChunkName: "transaction" */ '@transaction/store'),
]);
try {
const ajaxEndpoint = store.getState().config.ajaxEndpoint;
const { data } = await axios.post(ajaxEndpoint, {
resource: 'orders',
action: 'ship',
transactionId,
orderLines,
tracking,
});
if (!data.success && typeof data.message === 'string') {
throw data.detailed ? data.detailed : data.message;
}
return defaults(data, { success: false, order: null });
} catch (e) {
if (typeof e === 'string') {
throw e;
}
console.error(e);
return false;
}
};
示例4: constructor
constructor(config: IConfig) {
this._config = _.defaults({}, config, {
request: axiosAdapter({
forceHttpAdaptor: config.environment === 'node',
}),
userAgent: 'anx-api/' + packageJson.version,
timeout: 60 * 1000,
headers: {},
target: null,
token: null,
rateLimiting: true,
chunkSize: DEFAULT_CHUNK_SIZE,
});
this.request = __request;
// Install optional rate limiting adapter
this.request = this._config.rateLimiting ? rateLimitAdapter(_.assign({}, config, {
request: __request.bind(this),
})) : __request.bind(this);
// Install optional concurrency adapter
this._config.request = this._config.concurrencyLimit ? concurrencyAdapter({
limit: this._config.concurrencyLimit,
request: this._config.request,
}) : this._config.request;
}
示例5:
.then(() => {
_.each(datasources, (value, key) => {
inputs.push(value);
});
// templatize constants
for (let variable of saveModel.templating.list) {
if (variable.type === 'constant') {
var refName = 'VAR_' + variable.name.replace(' ', '_').toUpperCase();
inputs.push({
name: refName,
type: 'constant',
label: variable.label || variable.name,
value: variable.current.value,
description: '',
});
// update current and option
variable.query = '${' + refName + '}';
variable.options[0] = variable.current = {
value: variable.query,
text: variable.query,
};
}
}
// make inputs and requires a top thing
var newObj = {};
newObj['__inputs'] = inputs;
newObj['__requires'] = _.sortBy(requires, ['id']);
_.defaults(newObj, saveModel);
return newObj;
})
示例6: test
test('TCP/HTTP RPC command', function (done) {
var server = new stratum.RPCServer(_.defaults({ mode: 'both' }, this.opts)),
exposed = {
'func': function (args, opts, callback) {
callback(null, args)
}
},
spy = sinon.spy(exposed, 'func'),
client = new rpc.Client(server.opts.port, 'localhost')
server.expose('func', exposed.func, exposed).listen()
client.connectSocket(function (err, conn) {
conn.call('func', ['MTIz', 1, 2], function (err, result) {
expect(result).to.eql([1, 2])
expect(spy.calledWith([1, 2])).to.equal(true)
client.call('func', ['MTIz', 1, 2], function (err, result) {
expect(result).to.eql([1, 2])
expect(spy.calledWith([1, 2])).to.equal(true)
server.close()
done()
})
})
})
})
示例7: addParams
function addParams(request: PathFindRequest, result: RippledPathsResponse
): RippledPathsResponse {
return _.defaults(_.assign({}, result, {
source_account: request.source_account,
source_currencies: request.source_currencies
}), {destination_amount: request.destination_amount})
}
示例8: setDefaults
private setDefaults(): void {
this.config = _.defaults<Partial<RouteActiveConfig>, RouteActiveConfig>({
activeClass: this.activeClass,
attribute: this.attribute,
matchExact: this.matchExact
}, routeActiveConfig);
}
示例9: buildSassFile
function buildSassFile (srcFile, dstFile) {
let sassOptions = _.defaults({ file: srcFile }, sassDefaults)
return sassRender(sassOptions)
.then((result) => {
return writeFile(dstFile, result.css)
})
}
示例10: convertServerGroupCommandToDeployConfiguration
public convertServerGroupCommandToDeployConfiguration(base: any): any {
// use _.defaults to avoid copying the backingData, which is huge and expensive to copy over
const command = defaults({ backingData: [], viewState: [] }, base);
command.cloudProvider = 'aws';
command.availabilityZones = {};
command.availabilityZones[command.region] = base.availabilityZones;
command.loadBalancers = (base.loadBalancers || []).concat(base.vpcLoadBalancers || []);
command.targetGroups = base.targetGroups || [];
command.account = command.credentials;
command.subnetType = command.subnetType || '';
if (base.viewState.mode !== 'clone') {
delete command.source;
}
if (!command.ramdiskId) {
delete command.ramdiskId; // TODO: clean up in kato? - should ignore if empty string
}
delete command.region;
delete command.viewState;
delete command.backingData;
delete command.selectedProvider;
delete command.instanceProfile;
delete command.vpcId;
return command;
}