open-index/open-npm huggingface dataset:
npm package: @synonymdev/slashtags-contacts
Description: Slashtags contacts management.
Latest version: 1.0.0-alpha.0

# slashtags-contacts

Slashtags contacts management.

## Install

```bash
npm install @synonymdev/slashtags-contacts
```

## Usage

Initialize

```js
const coreData = new SlashtagsCoreData()

const contacts = new SlashtagsContacts(coreData)

await contacts.ready() // await loading contacts from disk

await contacts.set('slash:kencdz6km9xde46iph165d6isidssy9uate7b6srfaur8stm5br7', { name: "Foo" }) // set new contact

const contact = contacts.get('slash:kencdz6km9xde46iph165d6isidssy9uate7b6srfaur8stm5br7')
// { name: "Foo" }


for (let [id, contact] contacts.list() {
  // id: 'kencdz6km9xde46iph165d6isidssy9uate7b6srfaur8stm5br7'
  // ccontact: { name: "Foo" }
}
```

## API

#### `const contacts = new SlashtagsContacts(coreData)`

Create a new contacts instance from a CoreData instance

#### `await contacts.ready()`

Await opening the contacts list from storage.

#### `await contacts.set(url, contact)`

Await setting the value of contact and storing it as persistent encrypted data. `contact` has to be in the shape:

```js
{
  name: string, // Local (pet)name of the contact.
}
```

#### `const contact = contacts.get(url)`

Return contact value from contact's Slashtags url.

#### `for (let [id, contact] contacts.list() {}`

Return an iterator of entries in the internal Map. `id` is z-base32 endoced key of the contact. Internal map will be populated after `contacts.ready()`


#### `contact.close()`

Close underlying coreData instance and all subscriptions.