Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
lucas.parsy
jio
Commits
099545bf
Commit
099545bf
authored
Apr 11, 2014
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jio.js updated
parent
6b4c1794
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
97 additions
and
25 deletions
+97
-25
jio.js
jio.js
+97
-25
No files found.
jio.js
View file @
099545bf
...
@@ -38,12 +38,15 @@ constants.http_status_text = {
...
@@ -38,12 +38,15 @@ constants.http_status_text = {
"
0
"
:
"
Unknown
"
,
"
0
"
:
"
Unknown
"
,
"
550
"
:
"
Internal JIO Error
"
,
"
550
"
:
"
Internal JIO Error
"
,
"
551
"
:
"
Internal Storage Error
"
,
"
551
"
:
"
Internal Storage Error
"
,
"
555
"
:
"
Cancelled
"
,
"
Unknown
"
:
"
Unknown
"
,
"
Unknown
"
:
"
Unknown
"
,
"
Internal JIO Error
"
:
"
Internal JIO Error
"
,
"
Internal JIO Error
"
:
"
Internal JIO Error
"
,
"
Internal Storage Error
"
:
"
Internal Storage Error
"
,
"
Internal Storage Error
"
:
"
Internal Storage Error
"
,
"
Cancelled
"
:
"
Cancelled
"
,
"
unknown
"
:
"
Unknown
"
,
"
unknown
"
:
"
Unknown
"
,
"
internal_jio_error
"
:
"
Internal JIO Error
"
,
"
internal_jio_error
"
:
"
Internal JIO Error
"
,
"
internal_storage_error
"
:
"
Internal Storage Error
"
,
"
internal_storage_error
"
:
"
Internal Storage Error
"
,
"
cancelled
"
:
"
Cancelled
"
,
"
200
"
:
"
Ok
"
,
"
200
"
:
"
Ok
"
,
"
201
"
:
"
Created
"
,
"
201
"
:
"
Created
"
,
...
@@ -150,12 +153,15 @@ constants.http_status = {
...
@@ -150,12 +153,15 @@ constants.http_status = {
"
0
"
:
0
,
"
0
"
:
0
,
"
550
"
:
550
,
"
550
"
:
550
,
"
551
"
:
551
,
"
551
"
:
551
,
"
555
"
:
555
,
"
Unknown
"
:
0
,
"
Unknown
"
:
0
,
"
Internal JIO Error
"
:
550
,
"
Internal JIO Error
"
:
550
,
"
Internal Storage Error
"
:
551
,
"
Internal Storage Error
"
:
551
,
"
Cancelled
"
:
555
,
"
unknown
"
:
0
,
"
unknown
"
:
0
,
"
internal_jio_error
"
:
550
,
"
internal_jio_error
"
:
550
,
"
internal_storage_error
"
:
551
,
"
internal_storage_error
"
:
551
,
"
cancelled
"
:
555
,
"
200
"
:
200
,
"
200
"
:
200
,
"
201
"
:
201
,
"
201
"
:
201
,
...
@@ -262,12 +268,15 @@ constants.http_action = {
...
@@ -262,12 +268,15 @@ constants.http_action = {
"
0
"
:
"
error
"
,
"
0
"
:
"
error
"
,
"
550
"
:
"
error
"
,
"
550
"
:
"
error
"
,
"
551
"
:
"
error
"
,
"
551
"
:
"
error
"
,
"
555
"
:
"
error
"
,
"
Unknown
"
:
"
error
"
,
"
Unknown
"
:
"
error
"
,
"
Internal JIO Error
"
:
"
error
"
,
"
Internal JIO Error
"
:
"
error
"
,
"
Internal Storage Error
"
:
"
error
"
,
"
Internal Storage Error
"
:
"
error
"
,
"
Cancelled
"
:
"
error
"
,
"
unknown
"
:
"
error
"
,
"
unknown
"
:
"
error
"
,
"
internal_jio_error
"
:
"
error
"
,
"
internal_jio_error
"
:
"
error
"
,
"
internal_storage_error
"
:
"
error
"
,
"
internal_storage_error
"
:
"
error
"
,
"
cancelled
"
:
"
error
"
,
"
200
"
:
"
success
"
,
"
200
"
:
"
success
"
,
"
201
"
:
"
success
"
,
"
201
"
:
"
success
"
,
...
@@ -717,8 +726,22 @@ function generateUuid() {
...
@@ -717,8 +726,22 @@ function generateUuid() {
exports
.
util
.
generateUuid
=
generateUuid
;
exports
.
util
.
generateUuid
=
generateUuid
;
/**
/**
* JSON stringify a value. Dict keys are sorted in order to make a kind of
* Concatenate a `string` `n` times.
* deepEqual thanks to a simple strict equal string comparison.
*
* @param {String} string The string to concat
* @param {Number} n The number of time to concat
* @return {String} The concatenated string
*/
function
concatStringNTimes
(
string
,
n
)
{
/*jslint plusplus: true */
var
res
=
""
;
while
(
--
n
>=
0
)
{
res
+=
string
;
}
return
res
;
}
/**
* JSON stringify a value. Object keys are sorted in order to make a kind of
* deepEqual thanks to a simple string comparison.
*
*
* JSON.stringify({"a": "b", "c": "d"}) ===
* JSON.stringify({"a": "b", "c": "d"}) ===
* JSON.stringify({"c": "d", "a": "b"}) // false
* JSON.stringify({"c": "d", "a": "b"}) // false
...
@@ -729,43 +752,84 @@ exports.util.generateUuid = generateUuid;
...
@@ -729,43 +752,84 @@ exports.util.generateUuid = generateUuid;
* uniqueJSONStringify({"c": "d", "a": "b"}) // true
* uniqueJSONStringify({"c": "d", "a": "b"}) // true
*
*
* @param {Any} value The value to stringify
* @param {Any} value The value to stringify
* @param {Function} [replacer] A function to replace values during parse
* @param {Function,Array} [replacer] A function to replace values during parse
* @param {String,Number} [space] Causes the result to be pretty-printed
* @return {String} The unique JSON stringified value
*/
*/
function
uniqueJSONStringify
(
value
,
replacer
)
{
function
uniqueJSONStringify
(
value
,
replacer
,
space
)
{
function
subStringify
(
value
,
key
)
{
var
indent
,
key_value_space
=
""
;
var
i
,
res
;
if
(
typeof
space
===
"
string
"
)
{
if
(
typeof
replacer
===
'
function
'
)
{
if
(
space
!==
""
)
{
indent
=
space
;
key_value_space
=
"
"
;
}
}
else
if
(
typeof
space
===
"
number
"
)
{
if
(
isFinite
(
space
)
&&
space
>
0
)
{
indent
=
concatStringNTimes
(
"
"
,
space
);
key_value_space
=
"
"
;
}
}
function
uniqueJSONStringifyRec
(
key
,
value
,
deep
)
{
var
i
,
l
,
res
,
my_space
;
if
(
value
&&
typeof
value
.
toJSON
===
"
function
"
)
{
value
=
value
.
toJSON
();
}
if
(
typeof
replacer
===
"
function
"
)
{
value
=
replacer
(
key
,
value
);
value
=
replacer
(
key
,
value
);
}
}
if
(
indent
)
{
my_space
=
concatStringNTimes
(
indent
,
deep
);
}
if
(
Array
.
isArray
(
value
))
{
if
(
Array
.
isArray
(
value
))
{
res
=
[];
res
=
[];
for
(
i
=
0
;
i
<
value
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
value
.
length
;
i
+=
1
)
{
res
[
res
.
length
]
=
subStringify
(
value
[
i
],
i
);
res
[
res
.
length
]
=
uniqueJSONStringifyRec
(
i
,
value
[
i
],
deep
+
1
);
if
(
res
[
res
.
length
-
1
]
===
undefined
)
{
if
(
res
[
res
.
length
-
1
]
===
undefined
)
{
res
[
res
.
length
-
1
]
=
'
null
'
;
res
[
res
.
length
-
1
]
=
"
null
"
;
}
}
}
}
return
'
[
'
+
res
.
join
(
'
,
'
)
+
'
]
'
;
if
(
res
.
length
===
0
)
{
return
"
[]
"
;
}
if
(
indent
)
{
return
"
[
\n
"
+
my_space
+
indent
+
res
.
join
(
"
,
\n
"
+
my_space
+
indent
)
+
"
\n
"
+
my_space
+
"
]
"
;
}
}
if
(
typeof
value
===
'
object
'
&&
value
!==
null
&&
return
"
[
"
+
res
.
join
(
"
,
"
)
+
"
]
"
;
typeof
value
.
toJSON
!==
'
function
'
)
{
}
res
=
[];
if
(
typeof
value
===
"
object
"
&&
value
!==
null
)
{
for
(
i
in
value
)
{
if
(
Array
.
isArray
(
replacer
)
)
{
if
(
value
.
hasOwnProperty
(
i
)
)
{
res
=
replacer
.
reduce
(
function
(
p
,
c
)
{
res
[
res
.
length
]
=
subStringify
(
value
[
i
],
i
);
p
.
push
(
c
);
if
(
res
[
res
.
length
-
1
]
!==
undefined
)
{
return
p
;
res
[
res
.
length
-
1
]
=
JSON
.
stringify
(
i
)
+
"
:
"
+
res
[
res
.
length
-
1
]
;
},
[])
;
}
else
{
}
else
{
res
.
length
-=
1
;
res
=
Object
.
keys
(
value
)
;
}
}
res
.
sort
();
for
(
i
=
0
,
l
=
res
.
length
;
i
<
l
;
i
+=
1
)
{
key
=
res
[
i
];
res
[
i
]
=
uniqueJSONStringifyRec
(
key
,
value
[
key
],
deep
+
1
);
if
(
res
[
i
]
!==
undefined
)
{
res
[
i
]
=
JSON
.
stringify
(
key
)
+
"
:
"
+
key_value_space
+
res
[
i
];
}
else
{
res
.
splice
(
i
,
1
);
l
-=
1
;
i
-=
1
;
}
}
}
}
res
.
sort
();
if
(
res
.
length
===
0
)
{
return
"
{}
"
;
}
return
'
{
'
+
res
.
join
(
'
,
'
)
+
'
}
'
;
if
(
indent
)
{
return
"
{
\n
"
+
my_space
+
indent
+
res
.
join
(
"
,
\n
"
+
my_space
+
indent
)
+
"
\n
"
+
my_space
+
"
}
"
;
}
return
"
{
"
+
res
.
join
(
"
,
"
)
+
"
}
"
;
}
}
return
JSON
.
stringify
(
value
);
return
JSON
.
stringify
(
value
);
}
}
return
subStringify
(
value
,
''
);
return
uniqueJSONStringifyRec
(
""
,
value
,
0
);
}
}
exports
.
util
.
uniqueJSONStringify
=
uniqueJSONStringify
;
exports
.
util
.
uniqueJSONStringify
=
uniqueJSONStringify
;
...
@@ -2947,6 +3011,13 @@ function enableJobMaker(jio, shared, options) {
...
@@ -2947,6 +3011,13 @@ function enableJobMaker(jio, shared, options) {
job
.
command
.
storage
=
function
()
{
job
.
command
.
storage
=
function
()
{
return
shared
.
createRestApi
.
apply
(
null
,
arguments
);
return
shared
.
createRestApi
.
apply
(
null
,
arguments
);
};
};
job
.
command
.
setCanceller
=
function
(
canceller
)
{
job
.
cancellers
[
"
command:canceller
"
]
=
canceller
;
};
job
.
cancellers
=
job
.
cancellers
||
{};
job
.
cancellers
[
"
job:canceller
"
]
=
function
()
{
shared
.
emit
(
"
job:reject
"
,
job
,
[
"
cancelled
"
]);
};
}
}
function
createJobFromRest
(
param
)
{
function
createJobFromRest
(
param
)
{
...
@@ -3447,6 +3518,7 @@ function enableRestAPI(jio, shared) { // (jio, shared, options)
...
@@ -3447,6 +3518,7 @@ function enableRestAPI(jio, shared) { // (jio, shared, options)
param
.
solver
.
reject
=
reject
;
param
.
solver
.
reject
=
reject
;
param
.
solver
.
notify
=
notify
;
param
.
solver
.
notify
=
notify
;
},
function
()
{
},
function
()
{
if
(
!
param
.
cancellers
)
{
return
;
}
var
k
;
var
k
;
for
(
k
in
param
.
cancellers
)
{
for
(
k
in
param
.
cancellers
)
{
if
(
param
.
cancellers
.
hasOwnProperty
(
k
))
{
if
(
param
.
cancellers
.
hasOwnProperty
(
k
))
{
...
...
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