本文整理匯總了TypeScript中require-from-string.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了default函數的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: loadSync
})
configLoader.addLoader({
test: /\.[jt]s$/,
loadSync(id) {
const content = require('@babel/core').transform(
fs.readFileSync(id, 'utf8'),
{
babelrc: false,
configFile: false,
filename: id,
presets: [
[
require('@babel/preset-env'),
{
targets: {
node: 'current'
}
}
],
id.endsWith('.ts') && require('@babel/preset-typescript')
].filter(Boolean)
}
)
const m = requireFromString(content && content.code ? content.code : '', id)
return m.default || m
}
})
export default configLoader
示例2: createDSL
public createDSL(expression){
var treeVisitor = di.getInstance("TreeVisitor");
var _self = this;
var input = expression;
var chars = new antlr4.InputStream(input);
var lexer = new RealSocialableGrammarLexer(chars);
var tokens = new antlr4.CommonTokenStream(lexer);
var parser = new RealSocialableGrammarParser(tokens);
parser.buildParseTrees = true;
var tree = parser.prog();// 'block' is the start rule
treeVisitor.visitProg(tree);
var codeString = treeVisitor.getClassString();
var virtualModule = requireFromString(codeString);
let rsDSLObj:RSDSLModel = new RSDSLModel();
rsDSLObj.name = treeVisitor.className;
rsDSLObj.definition = codeString;
rsDSLObj.expression = input;
return _self.rsDSLRepository.post(rsDSLObj);
// .then((result:RSDSLModel)=>{
// let DSLAssignmentObj : AssignmentModel = new AssignmentModel();
// DSLAssignmentObj.dsl = result;
// DSLAssignmentObj.model = "rsICPerson";
// DSLAssignmentObj.modelId= "578622d85c2fbc1027ca507e" ;
// return _self.dslAssignmentRepository.post(DSLAssignmentObj);
// });
//content = user expression, code string is dsl output, for the integration model is rsperson, modelid is person id
//save dsl in the dsl
//assign to all the person (lets have 5 person in the table)
}
示例3: createDslObject
createDslObject(embeddedDslObj, mainDslContent, level)
{
let _self=this;
var dicList = {};
for(var i = 0; i< embeddedDslObj.length ; i++){
var name = embeddedDslObj[i].getName()
var variableName = name +"_" + level + "_"+ "_00_" + i;
var find = '"%' + name + '%"';
var replace = 'dslDictionary["' + variableName + '"]';
mainDslContent = _self.replaceAll(mainDslContent, find, replace)
//console.log(mainDslContent);
dicList[variableName] = embeddedDslObj[i];
}
_self.purgeCache('./executionService.js');
//for(var i= 0; i< require.cache[require.resolve('./executor.js')].children.length;)
var dslClass = requireFromString(mainDslContent);
var dslObject = new dslClass();
for (var prop in dicList) {
if (dicList.hasOwnProperty(prop)) {
dslObject.addDslMapping(prop, dicList[prop]);
}
}
return dslObject;
}
示例4: requireFromString
_self.rsDSLRepository.findByField("name",dslName).then((childRsDsl) => {
var input = childRsDsl.definition;
var virtualModule = requireFromString(input);
var obj = new virtualModule();
_self.purgeCache("./executionService.js");
if(obj.embeddedDsls().length > 0){
var promises = [];
obj.embeddedDsls().forEach(function(dsl) {
promises.push(_self.dslChain(dsl, level + 1));
});
q.all(promises).then(function(data){
var dslObject = _self.createDslObject(data, input, level)
defer.resolve(dslObject);
});
}
else{
defer.resolve(obj);
}
});