{"id":16482520,"url":"https://github.com/f/honst","last_synced_at":"2025-03-16T18:31:44.614Z","repository":{"id":40750086,"uuid":"323200189","full_name":"f/honst","owner":"f","description":"Fixes your dataset according to your rules.","archived":false,"fork":false,"pushed_at":"2023-01-06T17:28:47.000Z","size":3875,"stargazers_count":68,"open_issues_count":11,"forks_count":5,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-02-21T06:02:42.795Z","etag":null,"topics":["correction","data-integrity"],"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/f.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":"2020-12-21T01:22:54.000Z","updated_at":"2024-04-09T12:07:57.000Z","dependencies_parsed_at":"2023-02-06T07:16:45.908Z","dependency_job_id":null,"html_url":"https://github.com/f/honst","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/f%2Fhonst","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/f%2Fhonst/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/f%2Fhonst/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/f%2Fhonst/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/f","download_url":"https://codeload.github.com/f/honst/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243826783,"owners_count":20354220,"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":["correction","data-integrity"],"created_at":"2024-10-11T13:11:06.765Z","updated_at":"2025-03-16T18:31:41.768Z","avatar_url":"https://github.com/f.png","language":"JavaScript","readme":"# ⛓️ honst\n\n\u003e The name: I wanted it to be \"honest\", but it was occupied, so I removed a letter, and it became \"honst\".\n\nData Integrity fixer for an **object matrix**.\n\n## Use Cases\n- On editing a **joined** matrix data needs the data integrity to be kept.\n- Keeping your local state correct.\n\n## Demo\n\n\u003cimg src=\"./honst-demo.gif\"\u003e\n\nYou can play with honst on CodeSandbox:\n\n[![Edit honst demo](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/honst-demo-6s187?fontsize=14\u0026hidenavigation=1\u0026theme=light)\n\n## Overview\n\n```js\nconst data = [\n  { username: \"johndoe\", name: \"John\", surname: \"Doe\", age: \"22\" },\n  { username: \"johndoe\", name: \"John\", surname: \"Doe\", age: \"25\" },\n  { username: \"johndoe2\", name: \"John\", surname: \"Doe\", age: \"22\" },\n  { username: \"johndoe2\", name: \"John\", surname: \"Doez\", age: \"22\" },\n]\n```\n\nAccording to `username` field, there are many integrity issues around the array. So let **honst** fix these:\n\n```diff\n[\n  { username: \"johndoe\", name: \"John\", surname: \"Doe\", age: 22 },\n-  { username: \"johndoe\", name: \"John\", surname: \"Doe\", age: 25 },\n+  { username: \"johndoe\", name: \"John\", surname: \"Doe\", age: 22 },\n  { username: \"johnapple\", name: \"John\", surname: \"Apple\", age: 29 },\n- { username: \"johnapple\", name: \"John\", surname: \"Orange\", age: 22 },\n+ { username: \"johnapple\", name: \"John\", surname: \"Apple\", age: 29 },\n]\n```\n\n1. Referencing to `data[0].username`, `name`, `surname`, and `age` should be `John`, `Doe` and `22`.\n2. But `data[1].age` is `25` and it should be fixed.\n3. Referencing to `data[3].username`, `name`, `surname`, and `age` should be `John`, `Apple` and `29`.\n4. But `data[1].age` is `25`, `data[1].surname` is `Orange` and these should be fixed as well.\n\n**honst** simply fixes these integrity issues.\n\n## Usage\n\nInstall using `npm` or `yarn`:\n\n```\nnpm install honst\n# or\nyarn add honst\n```\n\nNow you can start:\n\n```js\nimport { honst } from 'honst';\n\nconst { data, delta } = honst({\n  data: [\n    { username: \"johndoe\", name: \"John\", surname: \"Doe\", age: \"22\" },\n    { username: \"johndoe\", name: \"John\", surname: \"Doe\", age: \"25\" }\n  ],\n  pivot: 0,     // an index number, \"scan\" or \"reverse-scan\"\n  delta: true,  // boolean\n  rules: {\n    // the ruleset of integrity\n    // e.g. we want all names, surnames and ages to be same according to \"username\"\n    name: [\"username\"],\n    surname: [\"username\"],\n    age: [\"username\"],\n  }\n})\n```\n\nThis will generate following data:\n\n```js\nconst fixedData = {\n  data: [\n    { username: \"johndoe\", name: \"John\", surname: \"Doe\", age: \"22\" },\n    { username: \"johndoe\", name: \"John\", surname: \"Doe\", age: \"22\" },\n  ],\n  delta: [\n    {\n      candidatePath: \"age\", // the path of the field\n      falseValue: \"25\", // the wrong value\n      candidateValue: \"22\", // the candidate value\n      pivot: 0, // the pivot row index\n      candidateIndex: 1, // the false row index\n    }\n  ]\n}\n```\n\n## Scanning and Reverse Scanning\n\nJust pass `pivot` value `scan` or `reverse-scan`.\n\nIf you want to fix all the rows from **top-down** or **bottom-up**, this will scan the data and fix'em all.\n\n```js\nconst { data, delta } = honst({\n  data: [\n    { username: \"johndoe\", name: \"John\", surname: \"Doe\", age: \"22\" },\n    { username: \"johndoe\", name: \"John\", surname: \"Doe\", age: \"25\" },\n    { username: \"johndoe2\", name: \"John\", surname: \"Doe\", age: \"22\" },\n    { username: \"johndoe2\", name: \"John\", surname: \"Doez\", age: \"22\" },\n  ],\n  pivot: \"scan\",\n  delta: true,\n  rules: {\n    name: [\"username\"],\n    surname: [\"username\"],\n    age: [\"username\"],\n  }\n})\n```\n\nThis will generate the following:\n\n```js\nconst fixedData = [\n  { username: \"johndoe\", name: \"John\", surname: \"Doe\", age: \"22\" },\n  { username: \"johndoe\", name: \"John\", surname: \"Doe\", age: \"22\" },\n  { username: \"johndoe2\", name: \"John\", surname: \"Appleseed\", age: \"22\" },\n  { username: \"johndoe2\", name: \"John\", surname: \"Appleseed\", age: \"22\" },\n]\n```\n\nIf you select `scan` the upper rows will be fixed first, and matching\nrows below will be updated accordingly. If you select `reverse-scan` it'll start fixing from bottom\nand scan to the top, so the bottom rows will be assumed correct.\n\n## Nested Objects?\n\nYes it supports nested objects as well.\n\n```js\nconst { data, delta } = honst({\n  data: [\n    // ... some nested data\n  ],\n  rules: {\n    'user.name': [\"account.username\"],\n    'user.surname': [\"account.username\"],\n    'profile.age': [\"account.username\"],\n  }\n})\n```\n\n## Parameters\n\n| Name        | What's?                                                                    |  Type             | Value\n| ----------- | -------------------------------------------------------------------------  | ----------        | -------\n| data        | list to check                                                              | Array             | `object[]`\n| rules       | determines which area the areas will be controlled according to.           | Array             | `object`\n| pivot       | the index of the data considered correct in the list.                      | Number or String  | `number | \"scan\" | \"reverse-scan\"`\n| delta       | Used to get information about data corrected as a result of the operations | Boolean           | `boolean` (Optional)\n\n\u003cbr /\u003e\n\nResult in `delta` :\n\n\n|                    |                |\n| -----------------  | -------------- |\n| **candidatePath**  | modified path\n| **falseValue**     | modified incorrect value\n| **candidateValue** | new value\n| **pivot**          | correct value index in data\n| **candidateIndex** | modified value index in data\n\n\n\n## Contribution\n\n- Clone and edit the source as you wish.\n- Please do not forget to add tests.\n- Write a descriptive PR.\n\n## License\n\nThis project uses MIT license.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ff%2Fhonst","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ff%2Fhonst","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ff%2Fhonst/lists"}