xonecas.io
311
Fn

ffmpeg-node / commit 0e8cb4f

made validation more clear, and effective

xonecas2011-02-03 0e8cb4f46bd9473e0bc525e41404c0545619d1b1 parent 147c753

1 file changed

ffmpeg-node.js+22−20
@@ -18,7 +18,7 @@ var path = require('path'),
1818 * function (stderr, stdout, exitCode) { ... }
1919 */
2020
21-exports.call = function (params, callback) {
21+exports.exec = function (params, callback) {
2222
2323 if (params instanceof Array && params.length > 2) {
2424
@@ -70,29 +70,31 @@ exports.convert = function (/* overloaded */) {
7070 else if (arguments.length > 3) {
7171 var err = false;
7272
73- if (arguments[2] instanceof Array)
73+ if (arguments[2] instanceof Array &&
74+ typeof arguments[3] === 'string' &&
75+ arguments[4] instanceof Function) {
76+
7477 params = arguments[2];
75- else if (typeof arguments[2] === 'string')
78+ output = arguments[3];
79+ callback = arguments[4];
80+ }
81+ else if (arguments[2] instanceof Array &&
82+ arguments[3] instanceof Function) {
83+
84+ params = arguments[2];
85+ callback = arguments[3];
86+ }
87+ else if (typeof arguments[2] === string &&
88+ arguments[3] instanceof Function) {
89+
7690 output = arguments[2];
91+ callback = arguments[3];
92+ }
7793 else if (arguments[2] instanceof Function)
7894 callback = arguments[2];
79- else
80- err = true;
95+ else
96+ throw new Error("Couldn't parse arguments");
8197
82- if (typeof arguments[3] === 'string')
83- output = arguments[3];
84- else if (arguments[3] instanceof Function)
85- callback = arguments[3];
86- else
87- err = true;
88-
89- if (arguments[4] instanceof Function)
90- var callback = arguments[4];
91- else
92- err = true;
93-
94- if (err)
95- throw new Error('Could not parse arguments');
9698 }
9799 else
98100 throw new Error('Not enough arguments');
@@ -138,7 +140,7 @@ exports.convert = function (/* overloaded */) {
138140 break;
139141 }
140142
141- this.call(params, callback);
143+ this.exec(params, callback);
142144
143145 }