Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio_mebibou
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Alexandra Rogova
jio_mebibou
Commits
385cbbcf
Commit
385cbbcf
authored
Apr 17, 2014
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sort_on done in workers
parent
c656fe29
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
20 deletions
+36
-20
src/queries/core/globals.js
src/queries/core/globals.js
+2
-1
src/queries/core/query.js
src/queries/core/query.js
+7
-2
src/queries/core/tool.js
src/queries/core/tool.js
+27
-17
No files found.
src/queries/core/globals.js
View file @
385cbbcf
/*jslint indent: 2, maxlen: 80, sloppy: true */
/*jslint indent: 2, maxlen: 80, sloppy: true */
var
query_class_dict
=
{};
var
query_class_dict
=
{},
background
=
{};
src/queries/core/query.js
View file @
385cbbcf
...
@@ -91,9 +91,14 @@ Query.prototype.exec = function (item_list, option) {
...
@@ -91,9 +91,14 @@ Query.prototype.exec = function (item_list, option) {
}
}
}
}
if
(
option
.
sort_on
)
{
if
(
option
.
sort_on
)
{
return
sortOn
(
option
.
sort_on
,
item_list
);
j
=
sortOn
(
option
.
sort_on
,
item_list
);
// sortOn clones the list, to avoid to get it twice, free memory
item_list
=
undefined
;
return
j
;
}
}
},
function
()
{
return
item_list
;
},
function
(
list
)
{
item_list
=
list
;
if
(
option
.
limit
)
{
if
(
option
.
limit
)
{
return
limit
(
option
.
limit
,
item_list
);
return
limit
(
option
.
limit
,
item_list
);
}
}
...
...
src/queries/core/tool.js
View file @
385cbbcf
/*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true */
/*jslint indent: 2, maxlen: 80, sloppy: true, nomen: true */
/*global Query, RSVP, deepClone */
/*global Query, RSVP, deepClone
, background, jIO
*/
/**
/**
* Escapes regexp special chars from a string.
* Escapes regexp special chars from a string.
...
@@ -173,31 +173,41 @@ function select(select_option, list, clone) {
...
@@ -173,31 +173,41 @@ function select(select_option, list, clone) {
Query
.
select
=
select
;
Query
.
select
=
select
;
/**
/**
* Sort a list of items, according to keys and directions.
If `clone` is true,
* Sort a list of items, according to keys and directions.
This function acts on
*
then the method will act on
a cloned list.
* a cloned list.
*
*
* @param {Array} sort_on_option List of couples [key, direction]
* @param {Array} sort_on_option List of couples [key, direction]
* @param {Array} list The item list to sort
* @param {Array} list The item list to sort
* @param {Boolean} [clone=false] If true, modifies a clone of the list
* @return {Array} The filtered list
* @return {Array} The filtered list
*/
*/
function
sortOn
(
sort_on_option
,
list
,
clone
)
{
function
sortOn
(
sort_on_option
,
list
)
{
var
sort_index
;
if
(
!
background
.
sortOn
)
{
background
.
sortOn
=
function
(
event
)
{
var
sort_index
,
option
=
event
.
data
.
option
,
array
=
event
.
data
.
array
;
for
(
sort_index
=
option
.
length
-
1
;
sort_index
>=
0
;
sort_index
-=
1
)
{
array
.
sort
(
sortFunction
(
option
[
sort_index
][
0
],
option
[
sort_index
][
1
]
));
}
/*global resolve*/
resolve
(
array
);
};
background
.
sortOn
=
jIO
.
util
.
worker
(
metadataValueToStringArray
.
toString
()
+
sortFunction
.
toString
()
+
"
onmessage =
"
+
background
.
sortOn
.
toString
()
);
}
if
(
!
Array
.
isArray
(
sort_on_option
))
{
if
(
!
Array
.
isArray
(
sort_on_option
))
{
throw
new
TypeError
(
"
jioquery.sortOn():
"
+
throw
new
TypeError
(
"
jioquery.sortOn():
"
+
"
Argument 1 is not of type 'array'
"
);
"
Argument 1 is not of type 'array'
"
);
}
}
if
(
clone
)
{
return
background
.
sortOn
({
list
=
deepClone
(
list
);
"
option
"
:
sort_on_option
,
}
"
array
"
:
list
for
(
sort_index
=
sort_on_option
.
length
-
1
;
sort_index
>=
0
;
});
sort_index
-=
1
)
{
list
.
sort
(
sortFunction
(
sort_on_option
[
sort_index
][
0
],
sort_on_option
[
sort_index
][
1
]
));
}
return
list
;
}
}
Query
.
sortOn
=
sortOn
;
Query
.
sortOn
=
sortOn
;
...
...
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