1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- {
- "_args": [
- [
- {
- "raw": "seq-queue",
- "scope": null,
- "escapedName": "seq-queue",
- "name": "seq-queue",
- "rawSpec": "",
- "spec": "latest",
- "type": "tag"
- },
- "/data/feimat/test_yali/online/shoufeilive/liveserver"
- ]
- ],
- "_from": "seq-queue@latest",
- "_id": "seq-queue@0.0.5",
- "_inCache": true,
- "_location": "/seq-queue",
- "_npmUser": {
- "name": "changchang",
- "email": "changchang005@gmail.com"
- },
- "_npmVersion": "1.1.59",
- "_phantomChildren": {},
- "_requested": {
- "raw": "seq-queue",
- "scope": null,
- "escapedName": "seq-queue",
- "name": "seq-queue",
- "rawSpec": "",
- "spec": "latest",
- "type": "tag"
- },
- "_requiredBy": [
- "#USER"
- ],
- "_resolved": "https://registry.npmjs.org/seq-queue/-/seq-queue-0.0.5.tgz",
- "_shasum": "d56812e1c017a6e4e7c3e3a37a1da6d78dd3c93e",
- "_shrinkwrap": null,
- "_spec": "seq-queue",
- "_where": "/data/feimat/test_yali/online/shoufeilive/liveserver",
- "author": {
- "name": "changchang",
- "email": "changchang005@gmail.com"
- },
- "bugs": {
- "url": "https://github.com/changchang/seq-queue/issues"
- },
- "contributors": [
- {
- "name": "* Yongchang Zhou",
- "email": "changchang005@gmail.com"
- }
- ],
- "dependencies": {},
- "description": "A simple tool to keep requests to be executed in order.",
- "devDependencies": {
- "mocha": ">=0.0.1",
- "should": ">=0.0.1"
- },
- "directories": {},
- "dist": {
- "shasum": "d56812e1c017a6e4e7c3e3a37a1da6d78dd3c93e",
- "tarball": "https://registry.npmjs.org/seq-queue/-/seq-queue-0.0.5.tgz"
- },
- "homepage": "https://github.com/changchang/seq-queue",
- "maintainers": [
- {
- "name": "changchang",
- "email": "changchang005@gmail.com"
- }
- ],
- "name": "seq-queue",
- "optionalDependencies": {},
- "readme": "seq-queue - queue to keep request process in sequence\n=====================================================\n\nSeq-queue is simple tool to keep requests to be executed in order.\n\nAs we known, Node.js codes run in asynchronous mode and the callbacks are unordered. But sometimes we may need the requests to be processed in order. For example, in a game, a player would do some operations such as turn right and go ahead. And in the server side, we would like to process these requests one by one, not do them all at the same time.\n\nSeq-queue takes the responsibility to make the asynchronous, unordered processing flow into serial and ordered. It's simple but not a repeated wheel.\n\nSeq-queue is a FIFO task queue and we can push tasks as we wish, anytime(before the queue closed), anywhere(if we hold the queue instance). A task is known as a function and we can do anything in the function and just need to call `task.done()` to tell the queue current task has finished. It promises that a task in queue would not be executed util all tasks before it finished.\n\nSeq-queue add timeout for each task execution. If a task throws an uncaught exception in its call back or a developer forgets to call `task.done()` callback, queue would be blocked and would not execute the left tasks. To avoid these situations, seq-queue set a timeout for each task. If a task timeout, queue would drop the task and notify develop by a 'timeout' event and then invoke the next task. Any `task.done()` invoked in a timeout task would be ignored.\n\n * Tags: node.js\n\n##Installation\n```\nnpm install seq-queue\n```\n\n##Usage\n``` javascript\nvar seqqueue = require('seq-queue');\n\nvar queue = seqqueue.createQueue(1000);\n\nqueue.push(\n function(task) {\n setTimeout(function() {\n console.log('hello ');\n task.done();\n }, 500);\n }, \n function() {\n console.log('task timeout');\n }, \n 1000\n);\n\nqueue.push(\n function(task) {\n setTimeout(function() {\n console.log('world~');\n task.done();\n }, 500);\n }\n);\n``` \n\n##API\n###seqqueue.createQueue(timeout)\nCreate a new queue instance. A global timeout value in ms for the new instance can be set by `timeout` parameter or use the default timeout (3s) by no parameter.\n\n###queue.push(fn, ontimeout, timeout)\nAdd a task into the queue instance. \n####Arguments\n+ fn(task) - The function that describes the content of task and would be invoke by queue. `fn` takes a arguemnt task and we *must* call task.done() to tell queue current task has finished.\n+ ontimeout() - Callback for task timeout. \n+ timeout - Timeout in ms for `fn`. If specified, it would overwrite the global timeout that set by `createQueue` for `fn`.\n\n###queue.close(force)\nClose the queue. A closed queue would stop receiving new task immediately. And the left tasks would be treated in different ways decided by `force`.\n####Arguments\n+ force - If true, queue would stop working immediately and ignore any tasks left in queue. Otherwise queue would execute the tasks in queue and then stop.\n\n##Event\nSeq-queue instances extend the EventEmitter and would emit events in their life cycles.\n###'timeout'(totask)\nIf current task not invoke task.done() within the timeout ms, a timeout event would be emit. totask.fn and totask.timeout is the `fn` and `timeout` arguments that passed by `queue.push(2)`.\n###'error'(err, task)\nIf the task function (not callbacks) throws an uncaught error, queue would emit an error event and passes the err and task informations by event callback arguments.\n###'closed'\nEmit when the close(false) is invoked.\n###'drained'\nEmit when close(true) is invoked or all tasks left have finished in closed status.\n",
- "repository": {
- "type": "git",
- "url": "git+ssh://git@github.com/changchang/seq-queue.git"
- },
- "version": "0.0.5"
- }
|