1
1
# 🧠 🔒 Haf 🦺 ✏️
2
2
3
+ [ ![ npm version] ( https://img.shields.io/npm/v/@batuhanw/haf.svg )] ( https://www.npmjs.com/package/@batuhanw/haf )
3
4
![ CI] ( https://github.com/BatuhanW/haf/workflows/main/badge.svg )
5
+ [ ![ Known Vulnerabilities] ( https://snyk.io/test/github/BatuhanW/haf/badge.svg?targetFile=package.json )] ( https://snyk.io/test/github/BatuhanW/haf?targetFile=package.json )
4
6
[ ![ Maintainability] ( https://api.codeclimate.com/v1/badges/4315aa36678fe4181b77/maintainability )] ( https://codeclimate.com/github/BatuhanW/haf/maintainability )
5
7
[ ![ Test Coverage] ( https://api.codeclimate.com/v1/badges/4315aa36678fe4181b77/test_coverage )] ( https://codeclimate.com/github/BatuhanW/haf/test_coverage )
6
- [ ![ Dependencies] ( https://status.david-dm.org/gh/batuhanw/haf.svg )] ( https://status.david-dm.org/gh/batuhanw/haf )
7
- [ ![ Dev Dependencies] ( https://status.david-dm.org/gh/batuhanw/haf.svg?type=dev )] ( https://status.david-dm.org/gh/batuhanw/haf )
8
8
9
9
Haf is a fully typed 🔒, cross-platform, persistent 💾 config ⚙️ solution for your NodeJS projects with a great developer experience!
10
10
@@ -50,32 +50,30 @@ interface DogSchema {
50
50
### 2. Initiate Haf
51
51
52
52
``` typescript
53
- import Haf from ' @batuhanw/haf'
54
-
55
- const haf = new Haf <DogSchema >(
56
- {
57
- name: ' myDog' ,
58
- defaultSchema: {
59
- name: ' Pop' ,
60
- age: 2 ,
61
- toys: [' socks' , ' toilet paper' ],
62
- vaccines: [
63
- { name: ' rabbies' , date: ' 2020-01-01' },
64
- { name: ' parasite' , date: ' 2020-01-01' , next: ' 2020-01-03' },
65
- ],
66
- appearance: {
67
- eyeColor: ' brown' ,
68
- hairColor: {
69
- primary: ' white' ,
70
- secondary: undefined ,
71
- otherColors: [' black' ],
72
- },
53
+ import Haf from ' @batuhanw/haf' ;
54
+
55
+ const haf = new Haf <DogSchema >({
56
+ name: ' myDog' ,
57
+ defaultSchema: {
58
+ name: ' Pop' ,
59
+ age: 2 ,
60
+ toys: [' socks' , ' toilet paper' ],
61
+ vaccines: [
62
+ { name: ' rabbies' , date: ' 2020-01-01' },
63
+ { name: ' parasite' , date: ' 2020-01-01' , nextDate: ' 2020-01-03' },
64
+ ],
65
+ appearance: {
66
+ eyeColor: ' brown' ,
67
+ hairColor: {
68
+ primary: ' white' ,
69
+ secondary: undefined ,
70
+ otherColors: [' black' ],
73
71
},
74
- sterilizedAt: undefined ,
75
- hasPuppies: false ,
76
- }
77
- }
78
- )
72
+ } ,
73
+ sterilizedAt: undefined ,
74
+ hasPuppies: false ,
75
+ },
76
+ });
79
77
```
80
78
81
79
### 3. Enjoy
@@ -100,7 +98,7 @@ haf.set('name', 'Pop');
100
98
haf .set (' appearance.hairColor' , { primary: ' white' });
101
99
haf .set (' appearance.hairColor.secondary' , ' brown' );
102
100
haf .set (' appearance.hairColor.secondary' , undefined );
103
- haf .set (' appearance.hairColor.otherColors' , [' black' ]) // This will overwrite existing array
101
+ haf .set (' appearance.hairColor.otherColors' , [' black' ]); // This will overwrite existing array
104
102
105
103
haf .set (' name' , 1 ); // type error
106
104
haf .set (' toys' , [1 , 2 ]); // type error
@@ -114,11 +112,11 @@ haf.set('appearance.haircolor', { notExist: 'white' }); //type error
114
112
Appends given values to the existing array
115
113
116
114
``` typescript
117
- haf .get (' toys' ) // ['socks', 'toilet paper']
115
+ haf .get (' toys' ); // ['socks', 'toilet paper']
118
116
119
- haf .append (' toys' , ' human hand' , ' bone' )
117
+ haf .append (' toys' , ' human hand' , ' bone' );
120
118
121
- haf .get (' toys' ) // ['socks', 'toilet paper', 'human hand', 'bone']
119
+ haf .get (' toys' ); // ['socks', 'toilet paper', 'human hand', 'bone']
122
120
```
123
121
124
122
#### Delete
0 commit comments