All Projects → BatuhanW → haf

BatuhanW / haf

Licence: MIT License
A fully typed 🔒, cross-platform, persistent 💾 config ⚙️ solution for your NodeJS projects with a great developer experience!

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to haf

Recon
HA LDAP based key/value solution for projects configuration storing with multi master replication support
Stars: ✭ 12 (-93.55%)
Mutual labels:  config, store
Data Store
Easily get, set and persist config data. Fast. Supports dot-notation in keys. No dependencies.
Stars: ✭ 120 (-35.48%)
Mutual labels:  config, store
StoreLib
Storelib is a DotNet library that provides APIs to interact with the various Microsoft Store endpoints.
Stars: ✭ 21 (-88.71%)
Mutual labels:  store
smallrye-config
SmallRye Config - A Java Configuration library
Stars: ✭ 74 (-60.22%)
Mutual labels:  config
Config
PHP library for simple configuration management
Stars: ✭ 39 (-79.03%)
Mutual labels:  config
eslint-define-config
Provide a defineConfig function for .eslintrc.js files
Stars: ✭ 61 (-67.2%)
Mutual labels:  config
rubric
Linter Config Initializer for Python
Stars: ✭ 21 (-88.71%)
Mutual labels:  config
RxReduxK
Micro-framework for Redux implemented in Kotlin
Stars: ✭ 65 (-65.05%)
Mutual labels:  store
nvimrc
My Neovim configuration. Supports macOS and Linux.
Stars: ✭ 31 (-83.33%)
Mutual labels:  config
yaask
Make your yaml configurable with interactive configurations!
Stars: ✭ 15 (-91.94%)
Mutual labels:  config
CakeShop
eCommerce website with cakephp
Stars: ✭ 19 (-89.78%)
Mutual labels:  store
rails-settings-cached
Global settings for your Rails application.
Stars: ✭ 940 (+405.38%)
Mutual labels:  config
panzerlop
Configuration Guides for fixing things in Linux, Proton & KDE
Stars: ✭ 23 (-87.63%)
Mutual labels:  config
play-rconf
Remote configuration for Play Framework
Stars: ✭ 17 (-90.86%)
Mutual labels:  config
knockout-store
State management for Knockout apps.
Stars: ✭ 37 (-80.11%)
Mutual labels:  store
store
The elementary OS merch store website
Stars: ✭ 20 (-89.25%)
Mutual labels:  store
todomvc-svelte
TodoMVC built with Svelte and Store
Stars: ✭ 34 (-81.72%)
Mutual labels:  store
goodconf
Transparently load variables from environment or JSON/YAML file.
Stars: ✭ 80 (-56.99%)
Mutual labels:  config
saleor
A modular, high performance, headless e-commerce platform built with Python, GraphQL, Django, and React.
Stars: ✭ 15,824 (+8407.53%)
Mutual labels:  store
mozitools
Mozi Botnet related tools helping to unpack a sample, decode a configuration and track active Mozi nodes using DHT.
Stars: ✭ 23 (-87.63%)
Mutual labels:  config

🧠 🔒 Haf 🦺 ✏️

CI Maintainability Test Coverage Dependencies Dev Dependencies

Haf is a fully typed 🔒, cross-platform, persistent 💾 config ⚙️ solution for your NodeJS projects with a great developer experience!

  • ✏️ Auto-completed dot-notation suggestions as you type when you try to get()/set()/delete()/reset() data from the store.
  • The type of the value you get() from the store is correctly inferred. So you always know what you'll get().
  • Non-nullable values aren't suggested on delete(). Trying to delete() a non-nullable field will throw a type error.

Go to gifs section to see it in action!

Installation

npm i @batuhanw/haf

OR

yarn add @batuhanw/haf

🏃 Getting Started

1. Define Your Schema

interface DogSchema {
  name: string;
  age: number;
  toys: string[];
  vaccines: { name: string; date: string; nextDate?: string }[];
  appearance: {
    eyeColor: string;
    hairColor: {
      primary: string;
      secondary?: string;
      otherColors: string[];
    };
  };
  sterilizedAt?: string;
  hasPuppies: boolean;
}

2. Initiate Haf

import Haf from '@batuhanw/haf'

const haf = new Haf<DogSchema>(
  {
    name: 'myDog',
    defaultSchema: {
      name: 'Pop',
      age: 2,
      toys: ['socks', 'toilet paper'],
      vaccines: [
        { name: 'rabbies', date: '2020-01-01' },
        { name: 'parasite', date: '2020-01-01', next: '2020-01-03' },
      ],
      appearance: {
        eyeColor: 'brown',
        hairColor: {
          primary: 'white',
          secondary: undefined,
          otherColors: ['black'],
        },
      },
      sterilizedAt: undefined,
      hasPuppies: false,
    }
  }
)

3. Enjoy

Get

  const name = haf.get('name') // string
  const age = haf.get('age') // number
  const hasPuppies = haf.get('hasPuppies') // boolean
  const vaccines = haf.get('vaccines') // { name: string; date: string; nextDate?: string }[]
  const hairColor: haf.get('appearance.haircolor') // { primary: string; secondary?: string, otherColors: string[] }
  const secondaryHairColor: haf.get('appearance.hairColor.secondary') // string | undefined

  const invalid = haf.get('non-existent') // type error

Set

haf.set('name', 'Pop');
haf.set('appearance.hairColor', { primary: 'white' });
haf.set('appearance.hairColor.secondary', 'brown');
haf.set('appearance.hairColor.secondary', undefined);
haf.set('appearance.hairColor.otherColors', ['black']) // This will overwrite existing array

haf.set('name', 1); // type error
haf.set('toys', [1, 2]); // type error
haf.set('appearance.haircolor', { primary: 1 }); //type error
haf.set('appearance.hairColor.primary', 1); // type error
haf.set('appearance.haircolor', { notExist: 'white' }); //type error

Append

Appends given values to the existing array

haf.get('toys') // ['socks', 'toilet paper']

haf.append('toys', 'human hand', 'bone')

haf.get('toys') // ['socks', 'toilet paper', 'human hand', 'bone']

Delete

haf.delete('sterilizedAt');
haf.delete('appearance.hairColor.secondary');

haf.delete('name'); // type error
haf.delete('appearance.hairColor.primary'); // type error

Gifs

Get

Set

Delete

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].