{"id":19837345,"url":"https://github.com/e-e-e/sequentialise","last_synced_at":"2025-09-05T02:07:46.017Z","repository":{"id":57356678,"uuid":"95294167","full_name":"e-e-e/sequentialise","owner":"e-e-e","description":"A utility to force a javascript object’s methods to be executed sequentially.","archived":false,"fork":false,"pushed_at":"2017-07-06T06:54:15.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-14T10:01:52.879Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/e-e-e.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-24T11:42:39.000Z","updated_at":"2017-06-24T11:42:57.000Z","dependencies_parsed_at":"2022-09-26T16:31:52.344Z","dependency_job_id":null,"html_url":"https://github.com/e-e-e/sequentialise","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e-e-e%2Fsequentialise","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e-e-e%2Fsequentialise/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e-e-e%2Fsequentialise/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/e-e-e%2Fsequentialise/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/e-e-e","download_url":"https://codeload.github.com/e-e-e/sequentialise/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240599186,"owners_count":19826959,"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","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":[],"created_at":"2024-11-12T12:14:08.446Z","updated_at":"2025-02-28T18:46:59.733Z","avatar_url":"https://github.com/e-e-e.png","language":"JavaScript","readme":"# Sequentialise\n\n[![Build Status](https://travis-ci.org/e-e-e/sequentialise.svg?branch=master)](https://travis-ci.org/e-e-e/sequentialise) [![Coverage Status](https://coveralls.io/repos/github/e-e-e/sequentialise/badge.svg?branch=master)](https://coveralls.io/github/e-e-e/sequentialise?branch=master)\n\nSequentialise is a simple utility for creating simple Proxy objects that force all of an object’s methods to be run sequentially.\n\nThis was originally developed to as a helper for querying Sqlite3. Sqlite is limited to one connection at a time and as such is prone to timeout errors when there is heavy querying load. By passing our database object to sequentialise we were able to ensure each query was executed in order and avoid timeout errors.\n\nThis library may also be useful for async api interfaces which require enforced linearity.\n\n## Install\n\n```\nnpm install sequentialise\n```\n\n## Interface\n\n`var seqObject = sequentialise(Object toWrap, [Object options])`\nReturns a new Proxy of object passed in as the functions first arguments.\nExample options:\n```js\n{\n  promise: Promise, // The flavour of promises you want to use. Defaults to native promises\n  ignore: ['method', 'names', 'you', 'don’t', 'want', 'sequentialised'], // Array of methods to ignore\n}\n```\n\n`seqObject.[ALL_METHODS](...args, [Object options])`\nAll sequentialised methods return promises, which are resolved or rejected in the order in which they are executed.\nExample options:\n```js\n  {\n    attempts: number, // if method fails it will retry this many times.\n    priority: number, // execution is ordered by priority default = 0.\n  }\n```\n\n`var queue = seqObject.promiseQueue`\nReturns the internal instance of [PromiseQueue](https://www.npmjs.com/package/a-promise-queue). Look at PromiseQueue for available options.\n\n## Caveats\n\n1. Sequentialised methods **can not** reference one another. This will make deadlock condition where the method called within a method is waiting for that one to finish before it can proceed, this will never happens as it is waiting for the nested method to return.\n2. Sequentialised methods **should not** use new ES6 ...rest arguments. ...rest arguments are not counted in `function.length` which confuses the calculations used to determine the options argument added by sequentialise.\n3. `.promiseQueue` is a reserved method name.\n\n## How to use\n\n```js\nvar sequentialise = require('sequentialise');\n\nvar delay = (ms) =\u003e () =\u003e new Promise(resolve =\u003e setTimeout(resolve, ms));\n\nvar anObject = {\n  post: (id, data) =\u003e {\n    console.log('POST', id, 'with', data);\n    return delay(100);\n  },\n  get: (id) =\u003e {\n    console.log('GET', id);\n    return delay(10);\n  },\n  echo: (message) =\u003e {\n    return 'echo:' + message;\n  },\n  ignoreMe: () =\u003e {\n    console.log('i can happen whenever');\n  }\n};\n\nvar seqObject = sequentialise(anObject, { ignore: ['ignoreMe'] });\n\nseqObject.post(1, 'this');\nseqObject.echo('ping').then(console.log); // original functions don't need to be asynchronous\nseqObject.post(2, 'that');\nseqObject.post(3, 'and this');\nseqObject.get(1, { priority: 1 }); // get takes priority over post\nseqObject.ignoreMe(); // happens immediately.\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fe-e-e%2Fsequentialise","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fe-e-e%2Fsequentialise","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fe-e-e%2Fsequentialise/lists"}