{"id":17349842,"url":"https://github.com/stasm/eslisp-chain","last_synced_at":"2026-02-20T19:02:52.850Z","repository":{"id":138205104,"uuid":"44013922","full_name":"stasm/eslisp-chain","owner":"stasm","description":"An eslisp macro for chaining method calls on a single object.","archived":false,"fork":false,"pushed_at":"2015-10-10T16:45:32.000Z","size":124,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-14T22:44:35.154Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/eslisp-chain","language":"Makefile","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/stasm.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":"2015-10-10T14:31:32.000Z","updated_at":"2015-10-11T15:25:50.000Z","dependencies_parsed_at":"2023-03-13T12:07:26.974Z","dependency_job_id":null,"html_url":"https://github.com/stasm/eslisp-chain","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/stasm/eslisp-chain","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stasm%2Feslisp-chain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stasm%2Feslisp-chain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stasm%2Feslisp-chain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stasm%2Feslisp-chain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stasm","download_url":"https://codeload.github.com/stasm/eslisp-chain/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stasm%2Feslisp-chain/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279014139,"owners_count":26085464,"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-10-13T02:00:06.723Z","response_time":61,"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":[],"created_at":"2024-10-15T16:57:20.919Z","updated_at":"2025-10-13T07:41:18.962Z","avatar_url":"https://github.com/stasm.png","language":"Makefile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# eslisp-chain [![Build status][travisimage]][travislink]\n\n[travisimage]: https://travis-ci.org/stasm/eslisp-chain.png?branch=master\n[travislink]: https://travis-ci.org/stasm/eslisp-chain\n\n\u003c!-- !test program\nsed 's/(require \"eslisp-chain\")/(require \".\\\\/index\")/' \\\n| ./node_modules/.bin/eslc \\\n| head -c -1\n--\u003e\n\nAn [eslisp][] macro for chaining method calls on a single object.\n\n## Examples\n\nThe macro is best suited for APIs whose methods return the same \nobject to make it possible to chain sebsequent method calls.  _eslisp_'s \nfunctional syntax makes such API rather tedious to use. \n\nConsider the following example in JavaScript:\n\n\u003c!-- !test out chain methods --\u003e\n\n    service.method('greet', function (name) {\n        return 'Hello, ' + (name + '!');\n    }).listen();\n\nThis can be expressed in _eslisp_ with the following code:\n\n    ((. \n      ((. service method) \"greet\" (lambda (name)\n        (return (+ \"Hello, \" name \"!\"))))\n      listen))\n\nAs the number of method calls increases, this inside-out functional syntax can \nget unwieldy, with multiple nested `((.` invocations.\n\nThe _eslisp-chain_ macro makes it possible to write the same code in \na sequential manner:\n\n\u003c!-- !test in chain methods --\u003e\n\n    (macro -\u003e (require \"eslisp-chain\"))\n    (-\u003e service\n      (method \"greet\" (lambda (name)\n        (return (+ \"Hello, \" name \"!\"))))\n      (listen))\n\n\nThis syntax is convenient for chaining promises:\n\n\u003c!-- !test in chain promises --\u003e\n\n    (macro -\u003e (require \"eslisp-chain\"))\n    (-\u003e (read \"data.json\")\n      (then (. JSON parse))\n      (then (lambda (obj)\n        (return ((. Object keys) obj))))\n      (catch (. console error)))\n\n↓\n\n\u003c!-- !test out chain promises --\u003e\n\n    read('data.json').then(JSON.parse).then(function (obj) {\n        return Object.keys(obj);\n    }).catch(console.error);\n\n\nIt can be used to compose array methods:\n\n\u003c!-- !test in chain array methods --\u003e\n\n    (macro -\u003e (require \"eslisp-chain\"))\n    (-\u003e Object\n      (keys data)\n      (filter (lambda (key)\n        (return (!== (get key 0) \"_\"))))\n      (forEach processPublicMembers))\n\n↓\n\n\u003c!-- !test out chain array methods --\u003e\n\n    Object.keys(data).filter(function (key) {\n        return key[0] !== '_';\n    }).forEach(processPublicMembers);\n\n\nThe macro offers an alternative even for single method calls when there is no \nchaining:\n\n\u003c!-- !test in single method accessor --\u003e\n\n    (macro -\u003e (require \"eslisp-chain\"))\n    (-\u003e app\n      (get \"/\" (lambda (req, res)\n        ((. res send) \"Hello, world!\"))))\n\n    (-\u003e app\n      (listen 3000))\n\n↓\n\n\u003c!-- !test out single method accessor --\u003e\n\n    app.get('/', function (req, unquote(res)) {\n        res.send('Hello, world!');\n    });\n    app.listen(3000);\n\n[eslisp]: https://www.npmjs.com/package/eslisp\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstasm%2Feslisp-chain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstasm%2Feslisp-chain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstasm%2Feslisp-chain/lists"}