本文整理匯總了TypeScript中meteor/meteor.Meteor.wrapAsync方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Meteor.wrapAsync方法的具體用法?TypeScript Meteor.wrapAsync怎麽用?TypeScript Meteor.wrapAsync使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類meteor/meteor.Meteor
的用法示例。
在下文中一共展示了Meteor.wrapAsync方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: function
'search_courses': function(text: string, results_per_page: number, page_no: number) {
var courseAsync = Meteor.wrapAsync(course_search);
var result;
var error;
courseAsync(text, results_per_page, page_no, function(res, err) {
if(err) {
result = null;
error = err;
}
else {
result = res;
error = null;
}
});
if(error) {
throw new Meteor.Error("Search Error");
}
else {
return result;
}
}
示例2: digest
import * as crypto from 'crypto';
import * as _ from 'lodash';
import * as moment from 'moment'
import * as parse from 'csv-parse';
import {
OtpImportLogCollection, OtpIncomeOrExpense, OtpImportLogEntry, OtpSchemas, OtpCsvLine,
OtpCsvLineHashCollection
} from "../index.ts";
import {Logger} from "../../../startup/server/Logger";
Meteor.publish('otp.importlogs', () => OtpImportLogCollection.find({}));
Meteor.publish('otp.importLogs.single', (id) => OtpImportLogCollection.find(id));
const parseSync = Meteor.wrapAsync(parse);
function digest(line: OtpCsvLine): string {
const hash = crypto.createHash('sha256');
hash.update(line.raw.join(","));
return hash.digest('hex');
}
Meteor.methods({
'otp.import-csv': function (csvText) {
check(csvText, String);
const logContext = Logger.withContext(this, {type: 'otp.import-csv'});
logContext.info({event: 'start'});
logContext.info({event: 'parsing-start'});
var parsed;