{"id":15592071,"url":"https://github.com/derhuerst/hifo","last_synced_at":"2026-03-11T14:33:09.647Z","repository":{"id":57264047,"uuid":"41877201","full_name":"derhuerst/hifo","owner":"derhuerst","description":"Stores \u0026 sorts only the highest values.","archived":false,"fork":false,"pushed_at":"2020-05-03T15:56:28.000Z","size":35,"stargazers_count":9,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T05:00:04.596Z","etag":null,"topics":["highest","lowest","maximum","minimum","sort"],"latest_commit_sha":null,"homepage":"https://github.com/derhuerst/hifo","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/derhuerst.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-03T18:40:14.000Z","updated_at":"2022-03-19T04:57:51.000Z","dependencies_parsed_at":"2022-08-25T02:51:52.866Z","dependency_job_id":null,"html_url":"https://github.com/derhuerst/hifo","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derhuerst%2Fhifo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derhuerst%2Fhifo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derhuerst%2Fhifo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derhuerst%2Fhifo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/derhuerst","download_url":"https://codeload.github.com/derhuerst/hifo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249010212,"owners_count":21197797,"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","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":["highest","lowest","maximum","minimum","sort"],"created_at":"2024-10-02T23:54:09.944Z","updated_at":"2026-03-11T14:33:09.609Z","avatar_url":"https://github.com/derhuerst.png","language":"JavaScript","funding_links":["https://patreon.com/derhuerst"],"categories":[],"sub_categories":[],"readme":"# *hifo* – highest in, first out ⚖\n\n**Remembers the highest/lowest values in a data set of any size.** Useful if you have a large number of values, but are only interested in the `n` highest (or lowest) ones. If you looking for a stream version, check out [hifo-stream](https://github.com/brianshaler/hifo-stream#hifo-stream).\n\n- *hifo* is **fast**. To find the highest `m` of `n` values, the [time complexity is `O(m * n)`](https://en.wikipedia.org/wiki/Time_complexity#Linear_time).\n- It is **memory-efficient**. If you specifiy its size as `50`, it will only store 50 values in memory.\n- *hifo* works with **numeric values** and **simple objects** out of the box, but you can pass your own [`sort` function](#todo).\n\n[![build status](https://img.shields.io/travis/derhuerst/hifo.svg)](https://travis-ci.org/derhuerst/hifo)\n[![npm version](https://img.shields.io/npm/v/hifo.svg)](https://www.npmjs.com/package/hifo)\n[![dependency status](https://img.shields.io/david/derhuerst/hifo.svg)](https://david-dm.org/derhuerst/hifo)\n[![dev dependency status](https://img.shields.io/david/dev/derhuerst/hifo.svg)](https://david-dm.org/derhuerst/hifo#info=devDependencies)\n![ISC-licensed](https://img.shields.io/github/license/derhuerst/hifo.svg)\n[![chat on gitter](https://badges.gitter.im/derhuerst.svg)](https://gitter.im/derhuerst)\n[![support me on Patreon](https://img.shields.io/badge/support%20me-on%20patreon-fa7664.svg)](https://patreon.com/derhuerst)\n\n\n## Example\n\nLet's assume we have a huge **array of people**.\n\n```javascript\nvar people = [\n\t{ name: 'Alice', age: 23 },\n\t{ name: 'Eve', age: 45 },\n\t{ name: 'Jane', age: 19 },\n\t{ name: 'Bob', age: 30 },\n\t{ name: 'John', age: 60 },\n\t// thousands of others\n];\n```\n\nTo **find the 3 oldest people**, we reate a new `Hifo` instance and pass the `'age'` as the filter key and `3` as the size.\n\n```javascript\nvar hifo = require('hifo');\n\nvar oldest = hifo(hifo.highest('age'), 3);\nfor (var person in people) {\n\toldest.add(person);\n}\n```\n\n`oldest.data` will now look like this:\n\n```javascript\n[\n\t{ name: 'John', age: 60 },\n\t{ name: 'Eve', age: 45 },\n\t{ name: 'Bob', age: 30 }\n]\n```\n\nOf course you can do this kind of filtering with `hifo.lowest` as well.\n\n\n\n## Contributing\n\nIf you **have a question**, **found a bug** or want to **propose a feature**, have a look at [the issues page](https://github.com/derhuerst/hifo/issues).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderhuerst%2Fhifo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fderhuerst%2Fhifo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderhuerst%2Fhifo/lists"}