{"id":22828685,"url":"https://github.com/busterc/l8r","last_synced_at":"2025-08-10T22:18:41.337Z","repository":{"id":74997381,"uuid":"84217974","full_name":"busterc/l8r","owner":"busterc","description":":alarm_clock: queue multiple functions and run later","archived":false,"fork":false,"pushed_at":"2018-08-25T21:50:28.000Z","size":7,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-08T14:12:22.020Z","etag":null,"topics":["defer","delay","handler","handlers","queue","tasks"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/busterc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-07T15:54:02.000Z","updated_at":"2023-09-08T17:21:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"7c31dc4b-e1b7-4201-a8e3-c817642618cf","html_url":"https://github.com/busterc/l8r","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/busterc/l8r","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/busterc%2Fl8r","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/busterc%2Fl8r/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/busterc%2Fl8r/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/busterc%2Fl8r/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/busterc","download_url":"https://codeload.github.com/busterc/l8r/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/busterc%2Fl8r/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269795783,"owners_count":24477099,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-10T02:00:08.965Z","response_time":71,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["defer","delay","handler","handlers","queue","tasks"],"created_at":"2024-12-12T19:11:27.295Z","updated_at":"2025-08-10T22:18:41.278Z","avatar_url":"https://github.com/busterc.png","language":"JavaScript","readme":"# l8r [![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Dependency Status][daviddm-image]][daviddm-url]\n\u003e queue multiple functions and run later\n\n__*Niceties*__\n- widely compatible and small codebase\n\n__*Caveats*__\n- there is no built in mechanism to receive return values; use callbacks or promises\n- any unhandled exception will stop subsequent function calls\n\n## Installation\n\n```sh\n$ npm install --save l8r\n```\n\n## Example\n\n```js\n'use strict';\n\n// let's queue socket listeners before we have a connection\n\nvar L8r = require('l8r');\n\nvar httpServer = require('http').createServer().listen(3000);\nvar io = require('socket.io')(httpServer);\nvar ioClient = require('socket.io-client')('http://localhost:3000');\n\n// ...\n\n// queue client-side listeners\nvar clientListeners = new L8r();\n\n(function () {\n  var self = {\n    smile: '=)'\n  };\n\n  clientListeners.add(function (socket) {\n    var smile = this.smile || self.smile;\n\n    socket.on('smile', function (gesture) {\n      var smiley = gesture || smile;\n      console.log(smiley);\n\n      if (smile === '=)') {\n        socket.emit('wink');\n      }\n    });\n\n    socket.on('smirk', function (gesture) {\n      if (gesture === ';D' \u0026\u0026 smile === ':-)') {\n        console.log(gesture);\n        httpServer.close();\n        ioClient.close();\n      }\n    });\n  });\n})();\n\n// ...\n\n// queue server-side listeners\nvar serverListeners = new L8r();\n\n(function () {\n  serverListeners.add(function (socket) {\n    socket.once('wink', function () {\n      socket.emit('smirk', ';D');\n    });\n  });\n})();\n\n// ...\n\n// now that it's later, add listeners\nserverListeners.run(ioClient);\n\n// ...\n\nio.on('connection', function (socket) {\n  // now we that we have the connected socket, \n  // we can add listeners\n  clientListeners.run(socket);\n\n  // if you want to pass context to all the functions,\n  // use \"apply()\" instead of \"run()\"\n  clientListeners.apply({\n    smile: ':-)'\n  }, [socket]);\n\n  ioClient.emit('smile');\n  // =\u003e =)\n  // =\u003e :-)\n  // =\u003e ;D\n});\n```\n\n## API\n\n### add(fn)\n\n- #### fn\n  \n    *Required*\n    Type `Function`\n\n    A function to be queued for calling later.\n\n### run([arguments])\n\n    Run all the functions added to the queue, passing in any arguments\n\n- #### arguments\n\n    Type: `Any`\n    \n    Parameters to pass into each function\n\n### apply(context, [parameters])\n\n    Run all the functions added to the queue, with context, \n    applying an array of parameters (if provided)\n\n- #### context\n\n    *Required*\n    Type: `Object`\n\n- #### parameters\n\n    Type: `Array`\n\n### queue\n\n    The queue of functions to be called later\n\n### q\n\n    An alias for `queue`\n\n\n## License\n\nISC © [Buster Collings](https://about.me/buster)\n\n\n[npm-image]: https://badge.fury.io/js/l8r.svg\n[npm-url]: https://npmjs.org/package/l8r\n[travis-image]: https://travis-ci.org/busterc/l8r.svg?branch=master\n[travis-url]: https://travis-ci.org/busterc/l8r\n[daviddm-image]: https://david-dm.org/busterc/l8r.svg?theme=shields.io\n[daviddm-url]: https://david-dm.org/busterc/l8r\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbusterc%2Fl8r","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbusterc%2Fl8r","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbusterc%2Fl8r/lists"}