{"id":28396334,"url":"https://github.com/ssbc/ssb-sort","last_synced_at":"2025-08-31T14:08:35.521Z","repository":{"id":57368797,"uuid":"58832519","full_name":"ssbc/ssb-sort","owner":"ssbc","description":null,"archived":false,"fork":false,"pushed_at":"2019-01-11T20:53:53.000Z","size":49,"stargazers_count":8,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-18T08:28:48.831Z","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/ssbc.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":"2016-05-14T22:03:55.000Z","updated_at":"2023-04-12T07:31:46.000Z","dependencies_parsed_at":"2022-09-12T03:01:25.077Z","dependency_job_id":null,"html_url":"https://github.com/ssbc/ssb-sort","commit_stats":null,"previous_names":["dominictarr/ssb-sort"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/ssbc/ssb-sort","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssbc%2Fssb-sort","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssbc%2Fssb-sort/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssbc%2Fssb-sort/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssbc%2Fssb-sort/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ssbc","download_url":"https://codeload.github.com/ssbc/ssb-sort/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ssbc%2Fssb-sort/sbom","scorecard":{"id":844517,"data":{"date":"2025-08-11","repo":{"name":"github.com/ssbc/ssb-sort","commit":"fa4308067eb7431698a4061a17352ff7f150c000"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/17 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":"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":"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":"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":"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":"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":"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":"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"}},{"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":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 15 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"}}]},"last_synced_at":"2025-08-23T21:08:43.273Z","repository_id":57368797,"created_at":"2025-08-23T21:08:43.273Z","updated_at":"2025-08-23T21:08:43.273Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272988919,"owners_count":25026961,"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-08-31T02:00:09.071Z","response_time":79,"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":"2025-05-31T21:38:06.969Z","updated_at":"2025-08-31T14:08:35.509Z","avatar_url":"https://github.com/ssbc.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ssb-sort\n\nsort a collection of messages by their causal order.\n\nA hash can be interpreted as a link,\n(except it is _what_ link, not a _where_ link.\nLike cinderella's glass slipper, a hash lets you confirm\nwhen you have found a thing, but doesn't clue you in to\nwhere that thing is)\n\nAn interesting thing about hashes as links, is that they\nalways point backwards in time. That is because you can't\nknow the hash of something you've seen it, or seen evidence of it.\nYou could make up a random hash - but then the chance that\nsomething with that hash will actually turn up is basically impossible.\n\nThis means that hashes represent _causation_, in some sense,\n\n## api\n\n``` js\nvar sort = require('ssb-sort')\n```\n\nall functions will throw if there is a duplicate message in the input.\n\n### `sort (set) =\u003e Array`\n\nsort a set (array of unique messages) by causal order,\nsorts first by causal order, but if two messages are concurrent,\nbreaks the tie by their received, then self-stated timestamps, then order by keys.\n\nmutates the original set\n\n### `sort.heads (set) =\u003e Array`\n\nreturns the most \"recent keys\" in the set (furtherest down the\ncausation chain). `sort.heads` is used to calculate the `branch`\nproperty is [patchwork](https://github.com/ssbc/patchwork) threads.\n\nUsually, a single key is returned, but if there have been\n[concurrent](https://en.wikipedia.org/wiki/Concurrent_computing)\nresponses `heads` will return multiple values. If two or more peers\nrespond while not having the latest messages, (for example because\nthey are offline, or they respond before all the messages have\nreached them)\n\nYou can think of \"concurrent\" as meaning both \"at the same time\"\nor \"not knowing about the other\".\n\n### `sort.roots (set) =\u003e Array`\n\nreturns the earliest keys in the set, since this operates\non an arbitary set of messages, there may be more than one root.\nbut usually you'll select a set by getting messages that point\nto a particular root node, in which case this will return one key.\n\n### `sort.missingContext (set) =\u003e Object`\n\nwith scuttlebutt, it's possible for people to post message simultaneously \n(or even at different times) and not know about other messages that were written.\nthis method tells you which messages were on 'different branches', \nas in did not know about other messages at the time of writing.\n\n```\n\n    A     // first message\n   / \\\n  B1  B2  // messages which were posted without know about each other\n   \\ /\n    C     // this message was posted and had see B1+B2 (and A)\n    |\n    D     // most recent message\n```\n\nhere `sort.missingContext([A, B1, B2, C, D])` returns:\n\n```js\n{\n  B1.key: [ B2 ],\n  B2.key: [ B1 ]\n}\n```\n\nThere are more complicated examples (with diagrams!) in the tests.\n\n## License\n\nMIT\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fssbc%2Fssb-sort","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fssbc%2Fssb-sort","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fssbc%2Fssb-sort/lists"}