Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
opening-hours
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
regionalkauf
opening-hours
Commits
29b7c2ed
Commit
29b7c2ed
authored
Jul 11, 2014
by
Johannes Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bla
parent
a32fa7e1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
63 additions
and
1 deletion
+63
-1
holidays.js
lib/holidays.js
+1
-1
simplQueue.js
lib/simplQueue.js
+62
-0
No files found.
lib/holidays.js
View file @
29b7c2ed
var
holidayMapping
=
require
(
'./holidayMapping.json'
);
var
holidayMapping
=
require
(
'./holidayMapping.json'
);
var
easterSunday
=
require
(
'./easterSunday'
);
var
easterSunday
=
require
(
'./easterSunday'
);
var
restRequest
=
require
(
'./restRequests'
);
var
restRequest
=
require
(
'./restRequests'
);
var
SimplQueue
=
require
(
'./simplQueue'
);
var
easterSundays
=
{};
var
easterSundays
=
{};
var
fixedHolidays
=
{
var
fixedHolidays
=
{
...
@@ -107,7 +108,6 @@ function Holidays(year) {
...
@@ -107,7 +108,6 @@ function Holidays(year) {
cb
(
null
,
options
);
cb
(
null
,
options
);
}
}
});
});
}
}
function
isInEpochSpan
(
date
,
epochSpan
)
{
function
isInEpochSpan
(
date
,
epochSpan
)
{
...
...
simplQueue.js
→
lib/
simplQueue.js
View file @
29b7c2ed
function
SimplQueue
(
finisher
)
{
function
SimplQueue
(
finisher
)
{
this
.
_finisher
=
finisher
;
this
.
_queue
=
[];
this
.
_queue
=
[];
this
.
_started
=
false
;
this
.
_started
=
false
;
this
.
_boundHandler
=
this
.
_handler
.
bind
(
this
);
}
}
SimplQueue
.
prototype
.
push
=
function
(
cb
)
{
SimplQueue
.
prototype
.
push
=
function
(
cb
)
{
this
.
_queue
.
push
(
cb
);
this
.
_queue
.
push
(
cb
);
...
@@ -11,13 +11,17 @@ SimplQueue.prototype.push = function (cb) {
...
@@ -11,13 +11,17 @@ SimplQueue.prototype.push = function (cb) {
next
(
this
.
_handler
.
bind
(
this
));
next
(
this
.
_handler
.
bind
(
this
));
}
}
};
};
SimplQueue
.
prototype
.
finish
=
function
(
finisher
)
{
this
.
_finisher
=
finisher
;
this
.
_start
();
};
SimplQueue
.
prototype
.
start
=
function
()
{
SimplQueue
.
prototype
.
_
start
=
function
()
{
if
(
this
.
_started
)
return
;
if
(
this
.
_started
)
return
;
this
.
_started
=
true
;
this
.
_started
=
true
;
var
next
=
this
.
_queue
.
shift
();
var
next
=
this
.
_queue
.
shift
();
if
(
next
)
if
(
next
)
next
(
this
.
_
handler
.
bind
(
this
)
);
next
(
this
.
_
boundHandler
);
else
this
.
_finisher
();
else
this
.
_finisher
();
};
};
...
@@ -25,28 +29,34 @@ SimplQueue.prototype._handler = function (err) {
...
@@ -25,28 +29,34 @@ SimplQueue.prototype._handler = function (err) {
if
(
err
)
return
this
.
_finisher
(
err
);
if
(
err
)
return
this
.
_finisher
(
err
);
var
next
=
this
.
_queue
.
shift
();
var
next
=
this
.
_queue
.
shift
();
if
(
next
)
{
if
(
next
)
{
next
(
this
.
_
handler
.
bind
(
this
)
);
next
(
this
.
_
boundHandler
);
}
}
else
this
.
_finisher
(
null
);
else
this
.
_finisher
(
null
);
};
};
module
.
exports
=
SimplQueue
;
module
.
exports
=
SimplQueue
;
function
doStuff
()
{
var
queue
=
new
SimplQueue
(
function
(
err
)
{
console
.
log
(
err
);
console
.
log
(
"finished"
);
});
for
(
var
i
=
0
;
i
<
100
;
i
++
)
{
queue
.
push
(
function
(
cb
)
{
setTimeout
(
function
()
{
if
(
Math
.
random
()
>
0.9
)
return
cb
(
new
Error
(
"muh"
));
console
.
log
(
+
new
Date
());
cb
(
null
);
},
50
)
})
}
}
doStuff
();
//function doStuff() {
\ No newline at end of file
// var queue = new SimplQueue();
// var res = [];
// for (var i = 0; i < 200; i++) {
// queue.push(function (cb) {
// setTimeout(function () {
// if(Math.random() > 1)
// return cb(new Error("muh"));
// res.push(+new Date());
// cb(null);
// }, 10)
// });
// var time0 = process.hrtime();
// queue.finish(function (err) {
// if(err) return console.log(err);
// var time = process.hrtime(time0);
// console.log(time[0] * 1000 + time[1]*1e-6);
//// console.log(res);
// })
// }
//}
//
//doStuff();
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