{"id":21557090,"url":"https://github.com/shenfe/domod","last_synced_at":"2025-09-07T21:12:17.402Z","repository":{"id":57215028,"uuid":"99398013","full_name":"shenfe/domod","owner":"shenfe","description":"A lightweight data-binding (or so-called mvvm) approach, providing both declarative and imperative ways.","archived":false,"fork":false,"pushed_at":"2018-05-20T05:13:01.000Z","size":567,"stargazers_count":11,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-20T01:31:05.927Z","etag":null,"topics":["data-binding","javascript","reactive","template"],"latest_commit_sha":null,"homepage":"","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/shenfe.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}},"created_at":"2017-08-05T04:04:49.000Z","updated_at":"2020-11-07T18:22:10.000Z","dependencies_parsed_at":"2022-08-24T21:01:21.677Z","dependency_job_id":null,"html_url":"https://github.com/shenfe/domod","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/shenfe/domod","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shenfe%2Fdomod","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shenfe%2Fdomod/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shenfe%2Fdomod/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shenfe%2Fdomod/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shenfe","download_url":"https://codeload.github.com/shenfe/domod/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shenfe%2Fdomod/sbom","scorecard":{"id":817674,"data":{"date":"2025-08-11","repo":{"name":"github.com/shenfe/domod","commit":"588e59021bcdbf0a7c08da8030c53cf8c829a611"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-23T14:36:22.193Z","repository_id":57215028,"created_at":"2025-08-23T14:36:22.194Z","updated_at":"2025-08-23T14:36:22.194Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274095688,"owners_count":25221490,"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-09-07T02:00:09.463Z","response_time":67,"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":["data-binding","javascript","reactive","template"],"created_at":"2024-11-24T08:10:53.521Z","updated_at":"2025-09-07T21:12:17.362Z","avatar_url":"https://github.com/shenfe.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\u003cimg width=\"190\"src=\"https://raw.githubusercontent.com/shenfe/domod/master/readme_assets/logo.png\"\u003e\u003c/p\u003e\n\n![gzipped](http://img.badgesize.io/https://raw.githubusercontent.com/shenfe/domod/master/dist/domod.min.js?compression=gzip)\n\u003ca href=\"https://circleci.com/gh/shenfe/domod/tree/master\"\u003e\u003cimg  src=\"https://img.shields.io/circleci/project/shenfe/domod/master.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/domod\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/domod.svg\"\u003e\u003c/a\u003e\n![license](https://img.shields.io/npm/l/domod.svg)\n\nA lightweight data-binding (or so-called mvvm) library, providing both **declarative template** and **imperative call** ways.\n\n*\"domod\" is named from \"DOM\", \"Model\" and their two-way relationship.*\n\n## Philosophy\n\n* Connection, relation, dependency. Whether data or dom, it is a tree. Tree and tree node relations make up graphs.\n* Reactive programming.\n\n## Simple Application\n\nA simple application:\n\n```js\nconst state = {\n    count: 0,\n    increase() {\n        this.count++ // `this` points to `state`\n    }\n}\n\nDMD.relate(state, {\n    negative: {\n        resultFrom() {\n            return this.count \u003c 0 // `this` points to `state`\n        }\n    }\n})\n\nconst view = `\n    \u003cdiv\u003e\n        \u003ch1 m-style=\"{ color: $negative ? 'red' : 'green' }\"\u003e{{$count}}\u003c/h1\u003e\n        \u003cbutton m-onclick=\"$count = $count - 1\"\u003e-\u003c/button\u003e\n        \u003cbutton m-onclick=\"$increase()\"\u003e+\u003c/button\u003e\n    \u003c/div\u003e\n`\n\nDMD('#app', view, state)\n```\n\n## API\n\nAn online [demo](http://hengwu.me/repos/domod/domod3.html).\n\nA more complex example of a form:\n\n```html\n\u003cscript src=\"path/to/domod.js\" charset=\"utf-8\"\u003e\u003c/script\u003e\n\n\u003cform id=\"form1\"\u003e\n    \u003cdiv\u003e\n        \u003clabel\u003egender:\u003c/label\u003e\n        \u003cinput m-onclick=\"$form.gender = 'male'\" \n               type=\"radio\" name=\"gender\" value=\"male\" m-checked=\"$form.gender === 'male'\"\u003eMale\n        \u003cinput m-onclick=\"$form.gender = 'female'\" \n               type=\"radio\" name=\"gender\" value=\"female\" m-checked=\"$form.gender === 'female'\"\u003eFemale\n    \u003c/div\u003e\n    \u003cdiv\u003e\n        \u003clabel\u003emobile:\u003c/label\u003e\n        \u003cinput type=\"text\" name=\"mobile\" m-value=\"$form.mobile\"\u003e\n        \u003cspan m-style=\"{ display: !!$form.mobile ? 'inline' : 'none' }\"\u003e\n            You input: {{$parse($form.mobile)}}.\n        \u003c/span\u003e\n        \u003cspan m-class=\"['some-class', { red: !$mobileInputStatus }]\" \n              m-style=\"{ display: !$mobileInputStatus ? 'inline' : 'none' }\"\u003e\n            {{$form.mobile}} is {{$mobileInputStatus}}!\n        \u003c/span\u003e\n    \u003c/div\u003e\n    \u003cdiv\u003e\n        \u003clabel\u003eage:\u003c/label\u003e\n        \u003cselect name=\"age\" m-value=\"$form.age.value\"\u003e\n            \u003coption m-each=\"$val in $form.age.options\" m-value=\"$val\"\u003e{{$val}}\u003c/option\u003e\n        \u003c/select\u003e\n    \u003c/div\u003e\n    \u003cdiv\u003e\n        \u003clabel\u003ecity:\u003c/label\u003e\n        \u003cselect name=\"city\" m-value=\"$form.city.value\"\u003e\n            \u003coption m-each=\"($val, $key) in $form.city.options\" m-value=\"$key\"\u003e\n                {{$val.code}}.{{$val.name}}\n            \u003c/option\u003e\n        \u003c/select\u003e\n    \u003c/div\u003e\n\u003c/form\u003e\n\n\u003cscript\u003e\n    var store = {\n        parse: function (v) {\n            return parseInt(v);\n        },\n        validateMobile: function () {\n            return /^1[3|4|5|8][0-9]\\d{8}$/.test(this.form.mobile);\n        },\n        form: {\n            gender: 'female',\n            mobile: '15210001000',\n            age: {\n                value: '37-54',\n                options: [\n                    '0-18',\n                    '19-36',\n                    '37-54',\n                    '55-200'\n                ]\n            },\n            city: {\n                value: '1',\n                options: [\n                    { code: 1, name: 'beijing' },\n                    { code: 2, name: 'newyork' },\n                    { code: 3, name: 'tokyo' },\n                    { code: 4, name: 'london' },\n                    { code: 5, name: 'paris' }\n                ]\n            }\n        }\n    };\n\n    /* Watch a property mutation */\n    store.mobileInputStatus = store.validateMobile();\n    DMD.relate(store, {\n        'form.mobile': {\n            dnstream: 'mobileInputStatus',\n            resultIn: function (v) {\n                var newVal = store.validateMobile();\n                console.log(`mobile is ${newVal}`);\n                DMD.$(store, 'mobileInputStatus', newVal);\n            }\n        }\n    });\n\n    DMD('#form1', store);\n\u003c/script\u003e\n```\n\n## Advance\n\n### Imperative Calling\n\nProviding a data object:\n\n```js\nvar store = {\n    value: '1'\n};\n```\n\nNow assign a property `color` which would be computed from the property `value`.\n\nThere are two methods available, `kernel` and `relate`.\n\nThe `kernel` method, which is actually a constructor function, accepts two parameters besides the data object: the property and its relation object.\n\n```js\nnew domod.kernel(store, 'color', {\n    resultFrom: function () {\n        return isNaN(parseInt(store.value)) ? 'red' : 'green';\n    }\n});\n```\n\nThe `relate` method, which is somehow a composition of `kernel`, accepts one parameter besides the data object: an object representing a map from property names to relation objects.\n\n```js\ndomod.relate(store, {\n    color: {\n        resultFrom: function () {\n            return isNaN(parseInt(store.value)) ? 'red' : 'green';\n        }\n    }\n});\n```\n\n### Relation Object\n\nA relation object can be declared with these properties:\n\nProperty | Effect\n:---: | :---\nresultFrom | Do when the property is being got, and return the value computed.\nresultIn | Do when the property is being set.\nupstream | Other properties as the property's dependencies.\ndnstream | Other properties as the property's effects.\n\n## Standalone Libraries\n\n### Kernel\n\nSee the [code](https://github.com/shenfe/domod/blob/master/src/Kernel.js) and [doc](https://github.com/shenfe/domod/blob/master/doc/Kernel.md) for more.\n\n### ObservableArray\n\nAlso called OArray for short. See the [code](https://github.com/shenfe/domod/blob/master/src/OArray.js) and [doc](https://github.com/shenfe/domod/blob/master/doc/ObservableArray.md) for more.\n\n## License\n\n[MIT](http://opensource.org/licenses/MIT)\n\nCopyright © 2017-present, [shenfe](https://github.com/shenfe)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshenfe%2Fdomod","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshenfe%2Fdomod","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshenfe%2Fdomod/lists"}