{"id":13602267,"url":"https://github.com/BatuhanW/haf","last_synced_at":"2025-04-11T08:31:51.593Z","repository":{"id":40749229,"uuid":"331778366","full_name":"BatuhanW/haf","owner":"BatuhanW","description":"A fully typed 🔒, cross-platform, persistent 💾 config ⚙️ solution for your NodeJS projects with a great developer experience!","archived":false,"fork":false,"pushed_at":"2024-06-16T17:40:31.000Z","size":1334,"stargazers_count":189,"open_issues_count":1,"forks_count":6,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-09T20:02:00.601Z","etag":null,"topics":["app","cli","config","node","nodejs","store","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/BatuhanW.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-21T23:03:59.000Z","updated_at":"2025-01-19T06:56:17.000Z","dependencies_parsed_at":"2024-06-17T06:01:11.241Z","dependency_job_id":"3ed385ef-cc2c-4be4-9e58-6fec1a6c0414","html_url":"https://github.com/BatuhanW/haf","commit_stats":{"total_commits":31,"total_committers":2,"mean_commits":15.5,"dds":0.3548387096774194,"last_synced_commit":"85a8e69d54b10bdcca8892b42caecbf488dfadfd"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BatuhanW%2Fhaf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BatuhanW%2Fhaf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BatuhanW%2Fhaf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BatuhanW%2Fhaf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BatuhanW","download_url":"https://codeload.github.com/BatuhanW/haf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248103864,"owners_count":21048245,"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":["app","cli","config","node","nodejs","store","typescript"],"created_at":"2024-08-01T18:01:18.389Z","updated_at":"2025-04-11T08:31:51.568Z","avatar_url":"https://github.com/BatuhanW.png","language":"TypeScript","funding_links":[],"categories":["TypeScript","cli"],"sub_categories":[],"readme":"# 🧠 🔒 Haf 🦺 ✏️\n\n[![npm version](https://img.shields.io/npm/v/@batuhanw/haf.svg)](https://www.npmjs.com/package/@batuhanw/haf)\n![CI](https://github.com/BatuhanW/haf/workflows/main/badge.svg)\n[![Known Vulnerabilities](https://snyk.io/test/github/BatuhanW/haf/badge.svg?targetFile=package.json)](https://snyk.io/test/github/BatuhanW/haf?targetFile=package.json)\n[![Maintainability](https://api.codeclimate.com/v1/badges/4315aa36678fe4181b77/maintainability)](https://codeclimate.com/github/BatuhanW/haf/maintainability)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/4315aa36678fe4181b77/test_coverage)](https://codeclimate.com/github/BatuhanW/haf/test_coverage)\n\nHaf is a fully typed 🔒, cross-platform, persistent 💾 JSON storage ⚙️ solution for your NodeJS projects with a great developer experience!\n\n- ✏️ Auto-completed dot-notation suggestions as you type when you try to get()/set()/delete()/reset() data from the store.\n- ✅ The type of the value you get() from the store is correctly inferred. So you always know what you'll get().\n- ❌ Non-nullable values aren't suggested on delete(). Trying to delete() a non-nullable field will throw a type error.\n\n\u003e [Go to gifs section to see it in action!](./README.md#Gifs)\n\n## Installation\n\n```\nnpm i @batuhanw/haf\n\nOR\n\nyarn add @batuhanw/haf\n```\n\n## 🏃 Getting Started\n\n### 1. Define Your Schema\n\n```typescript\ninterface DogSchema {\n  name: string;\n  age: number;\n  toys: string[];\n  vaccines: { name: string; date: string; nextDate?: string }[];\n  appearance: {\n    eyeColor: string;\n    hairColor: {\n      primary: string;\n      secondary?: string;\n      otherColors: string[];\n    };\n  };\n  sterilizedAt?: string;\n  hasPuppies: boolean;\n}\n```\n\n### 2. Initiate Haf\n\n```typescript\nimport Haf from '@batuhanw/haf';\n\nconst haf = new Haf\u003cDogSchema\u003e({\n  name: 'myDog',\n  defaultSchema: {\n    name: 'Pop',\n    age: 2,\n    toys: ['socks', 'toilet paper'],\n    vaccines: [\n      { name: 'rabbies', date: '2020-01-01' },\n      { name: 'parasite', date: '2020-01-01', nextDate: '2020-01-03' },\n    ],\n    appearance: {\n      eyeColor: 'brown',\n      hairColor: {\n        primary: 'white',\n        secondary: undefined,\n        otherColors: ['black'],\n      },\n    },\n    sterilizedAt: undefined,\n    hasPuppies: false,\n  },\n});\n```\n\n### 3. Enjoy\n\n#### Get\n\n```typescript\n  const name = haf.get('name') // string\n  const age = haf.get('age') // number\n  const hasPuppies = haf.get('hasPuppies') // boolean\n  const vaccines = haf.get('vaccines') // { name: string; date: string; nextDate?: string }[]\n  const hairColor: haf.get('appearance.haircolor') // { primary: string; secondary?: string, otherColors: string[] }\n  const secondaryHairColor: haf.get('appearance.hairColor.secondary') // string | undefined\n\n  const invalid = haf.get('non-existent') // type error\n```\n\n#### Set\n\n```typescript\nhaf.set('name', 'Pop');\nhaf.set('appearance.hairColor', { primary: 'white' });\nhaf.set('appearance.hairColor.secondary', 'brown');\nhaf.set('appearance.hairColor.secondary', undefined);\nhaf.set('appearance.hairColor.otherColors', ['black']); // This will overwrite existing array\n\nhaf.set('name', 1); // type error\nhaf.set('toys', [1, 2]); // type error\nhaf.set('appearance.haircolor', { primary: 1 }); //type error\nhaf.set('appearance.hairColor.primary', 1); // type error\nhaf.set('appearance.haircolor', { notExist: 'white' }); //type error\n```\n\n#### Append\n\nAppends given values to the existing array\n\n```typescript\nhaf.get('toys'); // ['socks', 'toilet paper']\n\nhaf.append('toys', 'human hand', 'bone');\n\nhaf.get('toys'); // ['socks', 'toilet paper', 'human hand', 'bone']\n```\n\n#### Delete\n\n```typescript\nhaf.delete('sterilizedAt');\nhaf.delete('appearance.hairColor.secondary');\n\nhaf.delete('name'); // type error\nhaf.delete('appearance.hairColor.primary'); // type error\n```\n\n### Gifs\n\n#### Get\n\n![](https://github.com/BatuhanW/Haf/blob/main/get.gif)\n\n#### Set\n\n![](https://github.com/BatuhanW/Haf/blob/main/set.gif)\n\n#### Delete\n\n![](https://github.com/BatuhanW/Haf/blob/main/delete.gif)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBatuhanW%2Fhaf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBatuhanW%2Fhaf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBatuhanW%2Fhaf/lists"}