本文整理汇总了TypeScript中Node.extend.default方法的典型用法代码示例。如果您正苦于以下问题:TypeScript extend.default方法的具体用法?TypeScript extend.default怎么用?TypeScript extend.default使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Node.extend
的用法示例。
在下文中一共展示了extend.default方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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);
示例2: 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;
};
示例3: 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);
}
});
示例4: handleResultsInList
async.map(docs, function(aDoc, cbdoc) {
// Do we already have them in the list?
var thisId = aDoc._id,
resultObject,
resultPos;
for (resultPos = results.length - 1; resultPos >= 0; resultPos--) {
if (results[resultPos].id.id === thisId.id) {
break;
}
}
function handleResultsInList() {
resultObject.searchImportance = item.resource.options.searchImportance || 99;
if (item.resource.options.localisationData) {
resultObject.resource = translate(resultObject.resource, item.resource.options.localisationData, 'resource');
resultObject.resourceText = translate(resultObject.resourceText, item.resource.options.localisationData, 'resourceText');
resultObject.resourceTab = translate(resultObject.resourceTab, item.resource.options.localisationData, 'resourceTab');
}
results.splice(_.sortedIndex(results, resultObject, calcResultValue), 0, resultObject);
cbdoc(null);
}
if (resultPos >= 0) {
resultObject = {};
extend(resultObject, results[resultPos]);
// If they have already matched then improve their weighting
resultObject.addHits = Math.max((resultObject.addHits || 9) - 1, 1);
// remove it from current position
results.splice(resultPos, 1);
// and re-insert where appropriate
results.splice(_.sortedIndex(results, resultObject, calcResultValue), 0, resultObject);
cbdoc(null);
} else {
// Otherwise add them new...
// Use special listings format if defined
var specialListingFormat = item.resource.options.searchResultFormat;
if (specialListingFormat) {
resultObject = specialListingFormat.apply(aDoc);
handleResultsInList();
} else {
that.getListFields(item.resource, aDoc, function(err, description) {
if (err) {
cbdoc(err);
} else {
resultObject = {
id: thisId,
weighting: 9999,
text: description
};
if (resourceCount > 1 || includeResourceInResults) {
resultObject.resource = resultObject.resourceText = item.resource.resourceName;
}
handleResultsInList();
}
});
}
}
},function(err) {
示例5: extend
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;
}
示例6: 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);
});
});
示例7: 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);
}
});
});
});
}
示例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;
示例9:
(options.plugins || []).forEach(pluginPath => {
extend(true, result, this.tryLoadingPlugin(pluginPath)(result));
});