{"id":19708723,"url":"https://github.com/nlight/objektiv","last_synced_at":"2025-10-09T08:18:10.944Z","repository":{"id":16879796,"uuid":"19640296","full_name":"nLight/objektiv","owner":"nLight","description":"Functional lenses in JavaScript","archived":false,"fork":false,"pushed_at":"2025-10-02T00:29:36.000Z","size":144,"stargazers_count":28,"open_issues_count":4,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-10-07T18:01:10.413Z","etag":null,"topics":["functional","functional-lenses","javascript","lenses"],"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/nLight.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null}},"created_at":"2014-05-10T11:54:44.000Z","updated_at":"2023-01-14T08:08:37.000Z","dependencies_parsed_at":"2024-06-26T22:46:46.057Z","dependency_job_id":"73d6ca58-47cc-47b2-b8e7-f3cd181e5489","html_url":"https://github.com/nLight/objektiv","commit_stats":{"total_commits":108,"total_committers":8,"mean_commits":13.5,"dds":0.4444444444444444,"last_synced_commit":"9d35e5c2dfa75df17e70239a6bfdb65e6e4c91d7"},"previous_names":["nlight/tscope.js"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/nLight/objektiv","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nLight%2Fobjektiv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nLight%2Fobjektiv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nLight%2Fobjektiv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nLight%2Fobjektiv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nLight","download_url":"https://codeload.github.com/nLight/objektiv/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nLight%2Fobjektiv/sbom","scorecard":{"id":672289,"data":{"date":"2025-08-11","repo":{"name":"github.com/nLight/objektiv","commit":"9d35e5c2dfa75df17e70239a6bfdb65e6e4c91d7"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.5,"checks":[{"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":"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":"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":"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":"Code-Review","score":0,"reason":"Found 0/21 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":"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":"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":"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":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"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"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 13 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Vulnerabilities","score":3,"reason":"7 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-2j2x-2gpw-g8fm","Warn: Project is vulnerable to: GHSA-ww39-953v-wcq6","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-21T20:33:10.469Z","repository_id":16879796,"created_at":"2025-08-21T20:33:10.469Z","updated_at":"2025-08-21T20:33:10.469Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001101,"owners_count":26082991,"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-09T02:00:07.460Z","response_time":59,"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":["functional","functional-lenses","javascript","lenses"],"created_at":"2024-11-11T21:44:26.982Z","updated_at":"2025-10-09T08:18:10.923Z","avatar_url":"https://github.com/nLight.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Objektiv [![Build Status](https://travis-ci.org/nLight/objektiv.svg?branch=master)](https://travis-ci.org/nLight/objektiv)\n\nFunctional lenses in JavaScript\n\nObjektiv (German) Lens, optics, objective\n\n## Basics\n\n`Objektiv.attr('field')` Object attribute accessor.\u003cbr\u003e\n`Objektiv.at(index)` Array element accessor.\u003cbr\u003e\n`lens.then(otherLens, ...)` Lens composition can take many arguments.\u003cbr\u003e\n`lens.traversal([filter])` Returns traversal, optionally filtered.\n\n# Regular lenses\n\nThrow TypeError unless element has been found\n\n```javascript\nconst data = { array: [1, 2, 3] };\nconst firstOfSome = Objektiv.attr(\"array\").at(0);\n\nfirstOfSome.get(data); //=\u003e 1\nfirstOfSome.set(data, 10); //=\u003e { array: [10, 2, 3] }\nfirstOfSome.map(data, x =\u003e x + 1); //=\u003e { array: [2, 2, 3] }\n```\n\n# Partial lenses\n\nSkip missing element\n\n```javascript\nconst data = { array: [1, 2, 3] };\nconst firstOfMissing = Objektiv.partialAttr(\"missing\").partialAt(0);\n\nfirstOfMissing.get(data); //=\u003e undefined\nfirstOfMissing.set(data, 10); //=\u003e { array: [1, 2, 3] }\nfirstOfMissing.map(data, x =\u003e x + 1); //=\u003e { array: [1, 2, 3] }\n```\n\n# Traversals\n\nTraversals make working with series of data easy:\n\n```javascript\nconst data = { array: [{ x: 0, y: 9 }, { x: 1, y: 8 }, { x: 2, y: 7 }] };\nconst traversal = Objektiv.attr(\"array\")\n  .traversal()\n  .attr(\"x\");\n\ntraversal.get(data); //=\u003e [0, 1, 2]\ntraversal.map(data, x =\u003e x + 1); //=\u003e {array: [{x: 1, y:9}, {x: 2, y: 8}, {x: 3, y: 7}]}\ntraversal.set(data, 6); //=\u003e {array: [{x: 6, y:9}, {x: 6, y: 8}, {x: 6, y: 7}]}\n\n// Nested traversals\nconst data = {\n  users: [{ id: 1, friends: [\"Alice\", \"Bob\"] }, { id: 2, friends: [\"Sam\"] }]\n};\nconst traversal = Objektiv.attr(\"users\")\n  .traversal()\n  .attr(\"friends\")\n  .traversal();\n\ntraversal.get(data); //=\u003e [['Alice', 'Bob'], ['Sam']]\ntraversal.map(data, name =\u003e name.toUpperCase()); //=\u003e {users: [{id: 1, friends: ['ALICE', 'BOB']}, {id: 2, friends: ['SAM']}]};\n```\n\n## Filtered traversals\n\nArray elements can be traversed by calling `.traversal([predicate])` on a lens that references an array.\u003cbr\u003e\nYou can pass `predicate` in traversal to filter elements of an array or chain `.traversal().filter(predicate)` function.\u003cbr\u003e\nSeveral `.filter()` functions can be chained one after another.\n\n```javascript\nconst data = { array: [{ x: 0, y: 9 }, { x: 1, y: 8 }, { x: 2, y: 7 }] };\nconst xGreaterThanOne = el =\u003e el.x \u003e 1;\nconst traversal = Objektiv.attr(\"array\")\n  .traversal(xGreaterThanOne)\n  .attr(\"x\");\n// Same as:\nObjektiv.attr(\"array\")\n  .traversal()\n  .filter(xGreaterThanOne)\n  .attr(\"x\");\n\ntraversal.get(data); //=\u003e [2]\ntraversal.map(data, x =\u003e x + 1); //=\u003e {array: [{x: 0, y:9}, {x: 1, y: 8}, {x: 3, y: 7}]}\ntraversal.set(data, 6); //=\u003e {array: [{x: 0, y:9}, {x: 0, y: 8}, {x: 6, y: 7}]}\n\n// Nested traversals\nconst data = {\n  users: [{ id: 1, friends: [\"Alice\", \"Bob\"] }, { id: 2, friends: [\"Sam\"] }]\n};\nconst hasTwoFriends = user =\u003e user.friends.length == 2;\nconst threeLetter = str =\u003e str.length === 3;\n\nconst traversal = Objektiv.attr(\"users\")\n  .traversal(hasTwoFriends)\n  .attr(\"friends\")\n  .traversal(threeLetter);\n\ntraversal.get(data); //=\u003e [['Bob']]\ntraversal.map(data, name =\u003e name.toUpperCase()); //=\u003e {users: [{id: 1, friends: ['Alice', 'BOB']}, {id: 2, friends: ['Sam']}]};\n```\n\n# Cursors\n\nObjektiv also provides cursors which are lenses enclosed over data or root accessors. Cursor is a handy self-contained object to pass around. Cursors can be composed and traversed as regular lenses.\n\n```javascript\nconst data = {some: deep: 1};\nconst full = Objektiv.dataCursor(data);\nconst deepLens = Objektiv.attr('some').attr('deep');\nconst cursor = full.then(deepLens);\n\ncursor.get() //=\u003e 1\ncursor.set(42)\ncursor.get() //=\u003e 42\nfull.get() //=\u003e {some: deep: 42}\n// All data are handled as immutable so original data is still:\ndata   //=\u003e {some: deep: 1}\n```\n\nCursor can notify about each change via callback:\n\n```javascript\nconst full = Objektiv.dataCursor(data, (newState, oldState) =\u003e {\n  // ... deal with it\n});\n```\n\nThis way it can be used with ReactJS. Inside a component:\n\n```javascript\nconst that = this;\nconst full = Objektiv.dataCursor(this.state, function(state) {\n  that.setState(state);\n});\nconst childCursor = full.attr(\"child\"); // ... and pass it to a child component\n```\n\nOutside of a root component:\n\n```javascript\nconst root = \u003cRoot ... /\u003e;\nObjektiv.dataCursor({/** Initial data **/}, function (state) {\n  root.setProps(state);\n});\nReact.renderComponent(root, ...);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnlight%2Fobjektiv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnlight%2Fobjektiv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnlight%2Fobjektiv/lists"}