Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
alvagi
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
alvagi
Commits
a5563899
Commit
a5563899
authored
May 22, 2016
by
Ivan Poddubny
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify prepareArgs
parent
b6561cde
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
22 deletions
+10
-22
context.js
lib/context.js
+10
-22
No files found.
lib/context.js
View file @
a5563899
...
@@ -138,7 +138,7 @@ Context.prototype.onEvent = function (event) {
...
@@ -138,7 +138,7 @@ Context.prototype.onEvent = function (event) {
//additional agi commands
//additional agi commands
commands
.
map
(
function
(
command
)
{
commands
.
forEach
(
function
(
command
)
{
var
str
=
''
;
var
str
=
''
;
Context
.
prototype
[
command
.
name
]
=
function
()
{
Context
.
prototype
[
command
.
name
]
=
function
()
{
if
(
command
.
params
>
0
)
{
if
(
command
.
params
>
0
)
{
...
@@ -152,28 +152,16 @@ commands.map(function (command) {
...
@@ -152,28 +152,16 @@ commands.map(function (command) {
});
});
var
prepareArgs
=
function
(
args
,
argsRules
,
count
)
{
var
prepareArgs
=
function
(
args
,
argsRules
,
count
)
{
var
q
,
argsP
=
[];
if
(
!
argsRules
||
!
count
)
{
if
(
argsRules
&&
count
)
{
return
args
;
args
=
args
.
map
(
function
(
arg
){
return
arg
.
toString
();
});
for
(
var
i
=
0
;
i
<
count
;
i
++
)
{
argsP
[
i
]
=
(
args
[
i
])
?
args
[
i
]
:
((
argsRules
[
i
]
&&
argsRules
[
i
].
default
)
?
argsRules
[
i
].
default
:
''
);
}
}
q
=
argsP
.
map
(
function
(
arg
,
i
)
{
return
Array
.
apply
(
null
,
new
Array
(
count
))
// old node.js versions don't support Array.fill()
return
(
argsRules
[
i
]
&&
argsRules
[
i
].
prepare
)
?
argsRules
[
i
].
prepare
(
arg
)
:
arg
;
.
map
(
function
(
arg
,
i
)
{
arg
=
args
[
i
]
!==
undefined
&&
args
[
i
]
!==
null
?
args
[
i
]
:
argsRules
[
i
]
&&
argsRules
[
i
].
default
||
''
;
var
prepare
=
argsRules
[
i
]
&&
argsRules
[
i
].
prepare
||
function
(
x
)
{
return
x
;
};
return
prepare
(
String
(
arg
));
});
});
}
else
{
q
=
args
;
}
return
q
;
};
};
//sugar commands
//sugar commands
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment