{"id":22428422,"url":"https://github.com/momsfriendlydevco/chainable","last_synced_at":"2026-02-06T12:10:41.699Z","repository":{"id":255442977,"uuid":"851946368","full_name":"MomsFriendlyDevCo/chainable","owner":"MomsFriendlyDevCo","description":"Tiny, zero-dependency chainable object wrapper","archived":false,"fork":false,"pushed_at":"2024-12-20T06:30:19.000Z","size":83,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-12-22T06:01:48.956Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MomsFriendlyDevCo.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":"2024-09-04T00:41:23.000Z","updated_at":"2024-12-20T06:30:23.000Z","dependencies_parsed_at":"2024-09-04T00:45:36.661Z","dependency_job_id":"48caed14-32be-4dab-a966-0a45c3d13d1d","html_url":"https://github.com/MomsFriendlyDevCo/chainable","commit_stats":null,"previous_names":["momsfriendlydevco/chainable"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/MomsFriendlyDevCo/chainable","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MomsFriendlyDevCo%2Fchainable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MomsFriendlyDevCo%2Fchainable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MomsFriendlyDevCo%2Fchainable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MomsFriendlyDevCo%2Fchainable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MomsFriendlyDevCo","download_url":"https://codeload.github.com/MomsFriendlyDevCo/chainable/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MomsFriendlyDevCo%2Fchainable/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29160810,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-06T07:18:23.844Z","status":"ssl_error","status_checked_at":"2026-02-06T07:13:32.659Z","response_time":59,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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-12-05T20:14:44.463Z","updated_at":"2026-02-06T12:10:41.672Z","avatar_url":"https://github.com/MomsFriendlyDevCo.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"@MomsFriendlyDevCo/Chainable\n============================\nMake any JavaScript object a chainable, functional interface.\n\nThis library is _intentionally_ tiny and dependency free. The entire library, minified is less than 1kb!\n\n\n**Make the tiny Mitt event library chainable**\n\n```javascript\nimport chainable from '../lib/chainable.js';\nimport mitt from 'mitt';\n\nlet emitter = chainable(mitt)\n    .on('blarp', ()=\u003e { /* Handle blarp emit */ })\n    .on('flonk', ()=\u003e { /* Handle flonk emit */ })\n    .emit('blarp')\n    .value() // Get original unwrapped emitter\n```\n\n\n**Make a browser DOM element chainable**\n```javascript\nimport chainable from '@momsfriendlydevco/chainable';\n\n// Make a chainable DOM object\nchainable(document.createElement('div'));\n    .addEventListener('click', ()=\u003e { /* Handle clicks */ })\n    .set('style.position', 'absolute') // Set a deeply nested property\n    .value() // Output the original object (if needed)\n```\n\n\nWhy?\n----\nThis library exists this because handling chainability in some non-chainable interfaces gets repetitive.\n\n```javascript\n// Horrible \u003cdiv\u003e setup using the native DOM\nlet widget = document.createElement('div');\nwidget.addEventListener('click', ()=\u003e { /* Handle click */ });\nwidget.style.position = 'absolute';\nwidget.style.top = '0px';\nwidget.style.left = '0px';\nwidget.classList.add('red');\n\ndocument.body.append(widget);\n```\n\n```javascript\n// Equivalent using chainable\ndocument.append(\n    chainable(document.createElement('div'));\n        .addEventListener('click', ()=\u003e { /* Handle clicks */ })\n        .set('style.position', 'absolute') // Set a deeply nested property\n        .set('style.top', '0px')\n        .set('style.left', '0px')\n        .call('classList.add', 'red')\n        .value() // Output the original raw DOMElement\n);\n```\n\n\n\nAPI\n===\n\nchainable(object)\n-----------------\nCreate a new chainable instance.\nThis also sets `$source` to the original object.\n\n\nchainable.$source\n-----------------\nAlso available as `chainable.source` if there isn't any conflict with the name.\nThe chainable source object.\nGenerally you don't want to access this directly.\n\n\nchainable.$call(name, ...args)\n------------------------------\nAlso available as `chainable.call(name, ...args)` if there isn't any conflict with the name.\nAs with `.$get` the name can be in dotted notation or array notation for deeply nested methods.\nCall a method on source but ignore the response and return the chainable instance.\n\n\nchainable.$set(key, val)\n------------------------\nAlso available as `chainable.set(key, val)` if there isn't any conflict with the name.\nSet one or more properties within a source object.\nCan be called as a simple key/val setter - `chainable.$set(keyName, value)` - or as an object - `chainable.$set({key1: val1, key2: val2})`\nThe key can also use dotted notation (e.g. `this.is.a.nested.key`) or an array notation (e.g. `['this', 'is', 'a', 'nested', 'key']`) to set deeply nested properties.\nReturns the chainable instance.\n\n\nchainable.$get(path)\n--------------------\nAlso available as `chainable.get(path)` if there isn't any conflict with the name.\nFetch a value from the source object, returning it.\nThe path can also use dotted notation (e.g. `this.is.a.nested.key`) or an array notation (e.g. `['this', 'is', 'a', 'nested', 'key']`) to get deeply nested properties.\nReturns the value found at the path or undefined if none.\n\n\nchainable.$value()\n------------------\nAlso available as `chainable.value()` if there isn't any conflict with the name.\nReturn the original source object - i.e. unwrap the original.\n\n\nchainable.$tap(callback)\n------------------------\nAlso available as `chainable.tap(callback)` if there isn't any conflict with the name.\nRun a callback inline as `(chainable) =\u003e { /* handler */ }`, ignore the result and return the chainable instance.\n\n\nchainable.$thru(callback)\n-------------------------\nAlso available as `chainable.tap(callback)` if there isn't any conflict with the name.\nRun a callback inline as `(chainable) =\u003e { /* handler */ }`, take the returned value as the new `$source` and and return the chainable instance.\n\n\nchainable.$replace(newState)\n----------------------------\nReplace the target item if it looks like an object\nThis is really only used when overwriting internal state or possibly replacing the state object due to a `$thru()` or `$call` return.\nReturns the chainable instance.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmomsfriendlydevco%2Fchainable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmomsfriendlydevco%2Fchainable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmomsfriendlydevco%2Fchainable/lists"}