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
aec783fa
Commit
aec783fa
authored
May 22, 2016
by
Dmitriev Sergey
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #9 from ipoddubny/patch-1
Simplify prepareArgs
parents
b6561cde
a5563899
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 @
aec783fa
...
...
@@ -138,7 +138,7 @@ Context.prototype.onEvent = function (event) {
//additional agi commands
commands
.
map
(
function
(
command
)
{
commands
.
forEach
(
function
(
command
)
{
var
str
=
''
;
Context
.
prototype
[
command
.
name
]
=
function
()
{
if
(
command
.
params
>
0
)
{
...
...
@@ -152,28 +152,16 @@ commands.map(function (command) {
});
var
prepareArgs
=
function
(
args
,
argsRules
,
count
)
{
var
q
,
argsP
=
[];
if
(
argsRules
&&
count
)
{
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
:
''
);
if
(
!
argsRules
||
!
count
)
{
return
args
;
}
q
=
argsP
.
map
(
function
(
arg
,
i
)
{
return
(
argsRules
[
i
]
&&
argsRules
[
i
].
prepare
)
?
argsRules
[
i
].
prepare
(
arg
)
:
arg
;
return
Array
.
apply
(
null
,
new
Array
(
count
))
// old node.js versions don't support Array.fill()
.
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
...
...
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