рефакторинг

This commit is contained in:
vgoma 2017-11-29 13:13:48 +03:00
parent c3525905d2
commit e607b0cd6b
5 changed files with 44 additions and 26 deletions

20
dist/1.crypto-pro.js vendored
View File

@ -604,26 +604,32 @@ webpackJsonpCryptoPro([1],[
]; ];
function execute(cb) { function execute(cb) {
var canAsync = cadesplugin.CreateObjectAsync;
cb = String(cb); cb = String(cb);
var args = cb.match(/^function\s*?\((.*?)\)/); var args = cb.match(/^function\s*?\((.*?)\)/);
args = (args && args[1]) || ''; args = (args && args[1]) || '';
cb = cb.replace(/^.*?{([\s\S]*?)}$/, '$1');
function GeneratorFunction() { function GeneratorFunction() {
return (new Function('', 'return Object.getPrototypeOf(function*(){}).constructor'))(); return (new Function('', 'return Object.getPrototypeOf(function*(){}).constructor'))();
} }
if (cadesplugin.CreateObjectAsync) { cb = String(new (canAsync ? GeneratorFunction() : Function)(args, cb));
cb = cb.replace(/^.*?{([\s\S]*?)}$/, '$1');
cb = String(new (GeneratorFunction())(args, cb)); cb = cb.replace(/cryptoCommon\.createObj(\([\s\S]*?\))/gm, 'cadesplugin.CreateObject' + (canAsync ? 'Async' : '') + '$1');
cb = cb.replace(/("|')(yield)(\1)\s*?\+\s*?\b/gm, canAsync ? '$2 ' : '');
cb = cb.replace(/cryptoCommon\.createObj(\([\s\S]*?\))/gm, 'cadesplugin.CreateObjectAsync$1'); if (!canAsync) {
cb = cb.replace(/("|')(yield)(\1)\s*?\+\s*?\b/gm, '$2 '); cb = cb.replace(/propset_(.*?)\((.*?)\)/gm, '.$1 = $2');
return 'cadesplugin.async_spawn(' + cb + ');';
} }
return canAsync ?
'cadesplugin.async_spawn(' + cb + ');'
: '(' + cb + ')();';
} }
/** /**

File diff suppressed because one or more lines are too long

20
dist/2.crypto-pro.js vendored
View File

@ -47,26 +47,32 @@ webpackJsonpCryptoPro([2],[
]; ];
function execute(cb) { function execute(cb) {
var canAsync = cadesplugin.CreateObjectAsync;
cb = String(cb); cb = String(cb);
var args = cb.match(/^function\s*?\((.*?)\)/); var args = cb.match(/^function\s*?\((.*?)\)/);
args = (args && args[1]) || ''; args = (args && args[1]) || '';
cb = cb.replace(/^.*?{([\s\S]*?)}$/, '$1');
function GeneratorFunction() { function GeneratorFunction() {
return (new Function('', 'return Object.getPrototypeOf(function*(){}).constructor'))(); return (new Function('', 'return Object.getPrototypeOf(function*(){}).constructor'))();
} }
if (cadesplugin.CreateObjectAsync) { cb = String(new (canAsync ? GeneratorFunction() : Function)(args, cb));
cb = cb.replace(/^.*?{([\s\S]*?)}$/, '$1');
cb = String(new (GeneratorFunction())(args, cb)); cb = cb.replace(/cryptoCommon\.createObj(\([\s\S]*?\))/gm, 'cadesplugin.CreateObject' + (canAsync ? 'Async' : '') + '$1');
cb = cb.replace(/("|')(yield)(\1)\s*?\+\s*?\b/gm, canAsync ? '$2 ' : '');
cb = cb.replace(/cryptoCommon\.createObj(\([\s\S]*?\))/gm, 'cadesplugin.CreateObjectAsync$1'); if (!canAsync) {
cb = cb.replace(/("|')(yield)(\1)\s*?\+\s*?\b/gm, '$2 '); cb = cb.replace(/propset_(.*?)\((.*?)\)/gm, '.$1 = $2');
return 'cadesplugin.async_spawn(' + cb + ');';
} }
return canAsync ?
'cadesplugin.async_spawn(' + cb + ');'
: '(' + cb + ')();';
} }
/** /**

File diff suppressed because one or more lines are too long

View File

@ -38,26 +38,32 @@ var subjectNameTagsTranslations = [
]; ];
function execute(cb) { function execute(cb) {
var canAsync = cadesplugin.CreateObjectAsync;
cb = String(cb); cb = String(cb);
var args = cb.match(/^function\s*?\((.*?)\)/); var args = cb.match(/^function\s*?\((.*?)\)/);
args = (args && args[1]) || ''; args = (args && args[1]) || '';
cb = cb.replace(/^.*?{([\s\S]*?)}$/, '$1');
function GeneratorFunction() { function GeneratorFunction() {
return (new Function('', 'return Object.getPrototypeOf(function*(){}).constructor'))(); return (new Function('', 'return Object.getPrototypeOf(function*(){}).constructor'))();
} }
if (cadesplugin.CreateObjectAsync) { cb = String(new (canAsync ? GeneratorFunction() : Function)(args, cb));
cb = cb.replace(/^.*?{([\s\S]*?)}$/, '$1');
cb = String(new (GeneratorFunction())(args, cb)); cb = cb.replace(/cryptoCommon\.createObj(\([\s\S]*?\))/gm, 'cadesplugin.CreateObject' + (canAsync ? 'Async' : '') + '$1');
cb = cb.replace(/("|')(yield)(\1)\s*?\+\s*?\b/gm, canAsync ? '$2 ' : '');
cb = cb.replace(/cryptoCommon\.createObj(\([\s\S]*?\))/gm, 'cadesplugin.CreateObjectAsync$1'); if (!canAsync) {
cb = cb.replace(/("|')(yield)(\1)\s*?\+\s*?\b/gm, '$2 '); cb = cb.replace(/propset_(.*?)\((.*?)\)/gm, '.$1 = $2');
return 'cadesplugin.async_spawn(' + cb + ');';
} }
return canAsync ?
'cadesplugin.async_spawn(' + cb + ');'
: '(' + cb + ')();';
} }
/** /**