本文整理汇总了TypeScript中extend类的典型用法代码示例。如果您正苦于以下问题:TypeScript extend类的具体用法?TypeScript extend怎么用?TypeScript extend使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了extend类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: callback
(err, resp) => {
if (err) {
callback(err, null, null, resp);
return;
}
let rows = [];
if (resp.schema && resp.rows) {
rows = this.bigQuery.mergeSchemaWithRows_(resp.schema, resp.rows);
}
let nextQuery = null;
if (resp.jobComplete === false) {
// Query is still running.
nextQuery = extend({}, options);
} else if (resp.pageToken) {
// More results exist.
nextQuery = extend({}, options, {
pageToken: resp.pageToken,
});
}
callback(null, rows, nextQuery, resp);
}
示例2: extend
issues.forEach((value) => {
if (value.type === 'open') {
issuesObject = extend(true, issuesObject, { 'open': value.total });
}
else {
issuesObject = extend(true, issuesObject, { 'closed': value.total });
}
});
示例3: Env_to_Opts
export default function getPreset
( env:WPACK.ENV
, optionsFilename:string
, type:"server"|"client"
, isProd:boolean
, returnWebpackConfig:boolean=false
):WPACK.CONFIG | WEBPACK.CONFIG
{
const isServer = (type=='server');
const defFlags = Env_to_Opts( env );
const wpack_conf = Opts_to_WpackConf
( extend
( {}
, defFlags
, { bundleName:`${defFlags.bundleName}.${type}`
, outputPath:isServer ? `${defFlags.outputPath}` : `${defFlags.outputPath}/public`
, isServer
, isProd
}
)
, optionsFilename
);
return returnWebpackConfig ? buildConfig(wpack_conf) : wpack_conf;
}
示例4: function
BigQuery.prototype.dataset = function(id, options) {
if (this.location) {
options = extend({location: this.location}, options);
}
return new Dataset(this, id, options);
};
示例5: constructor
constructor(options: any, edmx: Edm.Edmx) {
options = options || {};
this.options = extend({}, options)
this.metadata = edmx
}
示例6: it
it('should not include fractional digits if not provided', function() {
const input = extend({}, INPUT_OBJ);
delete input.fractional;
const time = bq.time(input);
assert.strictEqual(time.value, '14:2:38');
});
示例7: it
it('should use the credentials field of the options object', done => {
const options = extend(
{},
{
projectId: 'fake-project',
credentials: require('./fixtures/gcloud-credentials.json'),
}
);
const debug = new Debug(options, packageInfo);
const scope = nocks.oauth2(body => {
assert.strictEqual(body.client_id, options.credentials.client_id);
assert.strictEqual(body.client_secret, options.credentials.client_secret);
assert.strictEqual(body.refresh_token, options.credentials.refresh_token);
return true;
});
// Since we have to get an auth token, this always gets intercepted second.
nocks.register(() => {
scope.done();
setImmediate(done);
return true;
});
nocks.projectId('project-via-metadata');
// TODO: Determine how to remove this cast.
debuglet = new Debuglet(debug, (config as {}) as DebugAgentConfig);
debuglet.start();
});
示例8: it
it('should by default error when workingDirectory is a root directory with a package.json', done => {
const debug = new Debug({}, packageInfo);
/*
* `path.sep` represents a root directory on both Windows and Unix.
* On Windows, `path.sep` resolves to the current drive.
*
* That is, after opening a command prompt in Windows, relative to the
* drive C: and starting the Node REPL, the value of `path.sep`
* represents `C:\\'.
*
* If `D:` is entered at the prompt to switch to the D: drive before
* starting the Node REPL, `path.sep` represents `D:\\`.
*/
const root = path.sep;
const mockedDebuglet = proxyquire('../src/agent/debuglet', {
/*
* Mock the 'fs' module to verify that if the root directory is used,
* and the root directory is reported to contain a `package.json`
* file, then the agent still produces an `initError` when the
* working directory is the root directory.
*/
fs: {
stat: (
filepath: string | Buffer,
cb: (err: Error | null, stats: {}) => void
) => {
if (filepath === path.join(root, 'package.json')) {
// The key point is that looking for `package.json` in the
// root directory does not cause an error.
return cb(null, {});
}
fs.stat(filepath, cb);
},
},
});
const config = extend({}, defaultConfig, {workingDirectory: root});
const debuglet = new mockedDebuglet.Debuglet(debug, config);
let text = '';
debuglet.logger.error = (str: string) => {
text += str;
};
debuglet.on('initError', (err: Error) => {
const errorMessage =
'The working directory is a root ' +
'directory. Disabling to avoid a scan of the entire filesystem ' +
'for JavaScript files. Use config `allowRootAsWorkingDirectory` ' +
'if you really want to do this.';
assert.ok(err);
assert.strictEqual(err.message, errorMessage);
assert.ok(text.includes(errorMessage));
done();
});
debuglet.once('started', () => {
assert.fail('Should not start if workingDirectory is a root directory');
});
debuglet.start();
});
示例9: extend
createMethod: (id, options, callback) => {
if (is.fn(options)) {
callback = options;
options = {};
}
options = extend({}, options, {location: this.location});
return bigQuery.createDataset(id, options, callback);
},
示例10: setMetadata
setMetadata(metadata: Metadata, callback?: ResponseCallback):
void|Promise<SetMetadataResponse> {
// tslint:disable-next-line:no-any
const protoOpts = (this.methods.setMetadata as any).protoOpts;
const reqOpts =
extend(true, {}, this.getOpts(this.methods.setMetadata), metadata);
this.request(protoOpts, reqOpts, callback || util.noop);
}
示例11: table
/**
* Create a Table object.
*
* @param {string} id The ID of the table.
* @param {object} [options] Table options.
* @param {string} [options.location] The geographic location of the table, by
* default this value is inherited from the dataset. This can be used to
* configure the location of all jobs created through a table instance. It
* cannot be used to set the actual location of the table. This value will
* be superseded by any API responses containing location data for the
* table.
* @return {Table}
*
* @example
* const BigQuery = require('@google-cloud/bigquery');
* const bigquery = new BigQuery();
* const dataset = bigquery.dataset('institutions');
*
* const institutions = dataset.table('institution_data');
*/
table(id, options) {
options = extend(
{
location: this.location,
},
options
);
return new Table(this, id, options);
};
示例12: it
it('should optionally accept options', function(done) {
const options = {a: 'b'};
const expectedOptions = extend({location: undefined}, options);
BIGQUERY.request = function(reqOpts) {
assert.deepStrictEqual(reqOpts.qs, expectedOptions);
done();
};
job.getQueryResults(options, assert.ifError);
});
示例13: extend
export function getPluginsPrep
( o:WPACK.CONFIG
, extensions:string[]
)
{
const
{ isProd
, isServer
, isDev
, isClient
, isDevServer
, doCopyFiles
, doCompileStyles
} = o
const USES_TYPESCRIPT = extensions.indexOf('ts')>=0;
const copyConfig = doCopyFiles &&
{ from: o.copyFiles.from
, to: o.copyFiles.to
};
const uglify = extend(true,{},uglifyDefaults,o.uglify);
const extractText = extend(true,{},extractTextDefaults,o.extractText);
return (
{ isProd
, isDevServer
, isServer
, isDev
, isClient
, doCompileStyles
, USES_TYPESCRIPT
, extractText
, doCopyFiles
, copyConfig
}
);
}
示例14: it
it('should extend defaults with custom options object passed to constructor', () => {
let expected = extend({}, defaultOptions, {
trigger: [new Trigger('click')],
text: 'hello world',
placement: 'bottom'
}); // copy
expect(deepEqual((new Options({
trigger: 'click',
text: expected.text,
placement: expected.placement
})), expected)).toBe(true);
});
示例15: it
it('should make the correct request', done => {
const setMetadataMethod = grpcServiceObject.methods.setMetadata;
const expectedReqOpts = extend(true, {}, DEFAULT_REQ_OPTS, METADATA);
grpcServiceObject.methods.setMetadata.reqOpts = DEFAULT_REQ_OPTS;
grpcServiceObject.request = (protoOpts, reqOpts, callback) => {
assert.strictEqual(protoOpts, setMetadataMethod.protoOpts);
assert.deepStrictEqual(reqOpts, expectedReqOpts);
callback(); // done()
};
grpcServiceObject.setMetadata(METADATA, done);
});