本文整理汇总了TypeScript中Node.extend类的典型用法代码示例。如果您正苦于以下问题:TypeScript extend类的具体用法?TypeScript extend怎么用?TypeScript extend使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了extend类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
DataForm.prototype.preprocess = function (paths, formSchema) {
var outPath = {},
hiddenFields = [],
listFields = [];
for (var element in paths) {
if (paths.hasOwnProperty(element) && element !== '__v') {
// check for schemas
if (paths[element].schema) {
var subSchemaInfo = this.preprocess(paths[element].schema.paths);
outPath[element] = {schema: subSchemaInfo.paths};
if (paths[element].options.form) {
outPath[element].options = {form: extend(true, {}, paths[element].options.form)};
}
} else {
// check for arrays
var realType = paths[element].caster ? paths[element].caster : paths[element];
if (!realType.instance) {
if (realType.options.type) {
var type = realType.options.type(),
typeType = typeof type;
if (typeType === 'string') {
realType.instance = (!isNaN(Date.parse(type))) ? 'Date' : 'String';
} else {
realType.instance = typeType;
}
}
}
outPath[element] = extend(true, {}, paths[element]);
if (paths[element].options.secure) {
hiddenFields.push(element);
}
if (paths[element].options.match) {
outPath[element].options.match = paths[element].options.match.source;
}
var schemaListInfo = paths[element].options.list;
if (schemaListInfo) {
var listFieldInfo:ListField = {field: element};
if (typeof schemaListInfo === 'object' && Object.keys(schemaListInfo).length > 0) {
listFieldInfo.params = schemaListInfo;
}
listFields.push(listFieldInfo);
}
}
}
}
outPath = this.applySchemaSubset(outPath, formSchema);
var returnObj : any = {paths: outPath};
if (hiddenFields.length > 0) {
returnObj.hide = hiddenFields;
}
if (listFields.length > 0) {
returnObj.listFields = listFields;
}
return returnObj;
};
示例2: extend
doc.save(function (err, doc2) {
if (err) {
var err2 : any = {status: 'err'};
if (!err.errors) {
err2.message = err.message;
} else {
extend(err2, err);
}
if (debug) {
console.log('Error saving record: ' + JSON.stringify(err2));
}
res.status(400).send(err2);
} else {
doc2 = doc2.toObject();
for (var hiddenField in hiddenFields) {
if (hiddenFields.hasOwnProperty(hiddenField) && hiddenFields[hiddenField]) {
var parts = hiddenField.split('.');
var lastPart = parts.length - 1;
var target = doc2;
for (var i = 0; i < lastPart; i++) {
if (target.hasOwnProperty(parts[i])) {
target = target[parts[i]];
}
}
if (target.hasOwnProperty(parts[lastPart])) {
delete target[parts[lastPart]];
}
}
}
res.send(doc2);
}
});
示例3: loadPlugins
loadPlugins(options?: ConfigurationOptions) {
if (!options) {
return this;
}
var result = extend(true, this, options);
(options.plugins || []).forEach(pluginPath => {
extend(true, result, this.tryLoadingPlugin(pluginPath)(result));
});
return result;
}
示例4: extend
fs.readFile(file, { encoding: this.options.encoding }, (err, contents) => {
if (err) {
this.emit('error', err);
}
var rawSettings = this.options.editor_config ? ec.parse(file) : {};
rawSettings = extend(rawSettings, this.options.settings);
var settings = this.settingFactory.createSettings(rawSettings);
var settingProvider = new SettingProvider(rawSettings, settings);
this.createUniqueRules(settingProvider, settings).forEach(rule => {
callback(contents, rule);
});
});
示例5: next
return _.bind(function (req, res, next) {
if (!(req.resource = this.getResource(req.params.resourceName))) {
return next();
}
var reportSchema,
self = this,
urlParts = url.parse(req.url, true);
if (req.params.reportName) {
reportSchema = req.resource.model.schema.statics['report'](req.params.reportName, req);
} else if (urlParts.query.r) {
switch (urlParts.query.r[0]) {
case '[':
reportSchema = {pipeline: JSON.parse(urlParts.query.r)};
break;
case '{':
reportSchema = JSON.parse(urlParts.query.r);
break;
default:
return self.renderError(new Error('Invalid "r" parameter'), null, req, res, next);
}
} else {
var fields = {};
for (var key in req.resource.model.schema.paths) {
if (req.resource.model.schema.paths.hasOwnProperty(key)) {
if (key !== '__v' && !req.resource.model.schema.paths[key].options.secure) {
if (key.indexOf('.') === -1) {
fields[key] = 1;
}
}
}
}
reportSchema = {pipeline: [
{$project: fields}
], drilldown: req.params.resourceName + '/|_id|/edit'};
}
// Replace parameters in pipeline
var schemaCopy : any = {};
extend(schemaCopy, reportSchema);
schemaCopy.params = schemaCopy.params || [];
self.reportInternal(req, req.resource, schemaCopy, urlParts, function (err, result) {
if (err) {
self.renderError(err, null, req, res, next);
} else {
res.send(result);
}
});
}, this);
示例6: compile
export function compile(options: IConfigurationOptions, files: string[],
callback: (exitCode: number) => void) {
var compiler = new Compiler(new Configuration(extend({}, config.raw, options)));
compiler.compile(files, (err, results) => {
if (err) {
throw err;
}
var count = results.length;
results.forEach(result => {
fs.writeFile(result.dest, result.contents, (err2) => {
if (err2) {
throw err2;
}
if (--count === 0) {
callback(0);
}
});
});
});
}
示例7: extend
(options.plugins || []).forEach(pluginPath => {
extend(true, result, this.tryLoadingPlugin(pluginPath)(result));
});
示例8: merge
const HMACKeyLength:number = 32;
const BlockSize:number = 16;
const GCMTagSize:number = 16;
const GCMStandardNonceSize:number = 12;
const ECIESKDFOutput = 512; // bits
const IVLength = 16; // bytes
const AESBlockLength = 16;
const CURVE_P_256_Size = 256;
const CURVE_P_384_Size = 384;
// variables
// #region Merging function/object declarations for ASN1js and PKIjs
var asn1js = merge(true, _asn1js, common);
var x509schema = merge(true, _x509schema, asn1js);
var pkijs_1 = merge(true, _pkijs, asn1js);
var pkijs = merge(true, pkijs_1, x509schema);
/**
* The crypto class contains implementations of various crypto primitives.
*/
export class Crypto {
private hashAlgorithm:string;
private securityLevel:number;
private curveName:string;
private suite:string;
private hashFunction:any;
private hashFunctionKeyDerivation:any;