npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@expo/contact-utils

v0.0.0

Published

Tools for working with Expo.Contacts

Downloads

3

Readme

expo-contact-utils

NPM

Methods

parseDate

parseDate({ year, month, day, format }): Date

Return a JS Date given a native calendar date.

Parameters

| Name | Type | Description | | -------------- | ---------------- | ------------------------------------------ | | calendarFormat | CalendarFormat | The shape containing calendar information. |

Returns

| Name | Type | Description | | ---- | ------ | ------------------ | | date | Date | A javascript date. |

Example

const date = ContactUtils.parseDate({ year, month, day, format });

formatAddress

formatAddress(address: Address): string

Return a readable name from native address information.

Parameters

| Name | Type | Description | | ------- | --------- | ------------------------------------------------ | | address | Address | The shape containing postal address information. |

Returns

| Name | Type | Description | | ------------- | -------- | ------------------------ | | formatAddress | string | A readable address name. |

Example

const address = ContactUtils.formatAddress({
  city,
  country,
  postalCode,
  region,
  street,
});

nameForFieldAsync

nameForFieldAsync(key: ContactField, strings = STRINGS): ?string

Get a localized name for a Contact.Fields key.

Only supported language is en (US-English) currently.

Parameters

| Name | Type | Description | | ------- | -------------------------------------- | ----------------------------------------- | | key | ContactField | The field you want to get a name for. | | strings | { [en]: { [ContactField]: string } } | An alternative list of localized strings. |

Returns

| Name | Type | Description | | ---- | --------- | ------------------------------------ | | name | ?string | The name of a supplied ContactField. |

Example

const name = await nameForFieldAsync(Contacts.Fields.FirstName);

getPrimaryEntry

getPrimaryEntry(items: Array): ?Object

Given a list of contact entries, (like emails) this will find the primary entry.

Parameters

| Name | Type | Description | | ----- | ------------------------------------------ | ------------------------------- | | items | Array<{ label, id, isPrimary, ...data }> | An array of contact entry data. |

Returns

| Name | Type | Description | | ---- | ------------------------------------ | ---------------------------------------------------------- | | item | ?{ label, id, isPrimary, ...data } | A contact field entry that is the assumed primary value. |

Example

const primary = getPrimaryEntry(phoneNumbers);

getGroupWithNameAsync

iOS only

getGroupWithNameAsync(groupName: string): Promise<?Group>

Gets the first group with a given name.

Parameters

| Name | Type | Description | | --------- | -------- | ------------------------------------ | | groupName | string | Name of the group you want to query. |

Returns

| Name | Type | Description | | ----- | -------- | ------------------------------------------------ | | group | ?Group | A group with a name matching the provided query. |

Example

const contactGroup = await getGroupWithNameAsync("Expo Programmers")

duplicateContactWithIdAsync

iOS only

duplicateContactWithIdAsync(contactId: string): Promise<string>

Creates a clone of an existing system contact.

Parameters

| Name | Type | Description | | --------- | -------- | ------------------------------------------------- | | contactId | string | ID of the existing contact you want to duplicate. |

Returns

| Name | Type | Description | | --------- | -------- | ---------------------- | | contactId | string | ID of the new contact. |

Example

const cloneId = await duplicateContactWithIdAsync(contactId)

ensureGroupWithNameExistsAsync

iOS only

ensureGroupWithNameExistsAsync(groupName: string): Promise<string>

Tries to retrieve a contact group, if it cannot be found, create a new contact group with the provided name.

Parameters

| Name | Type | Description | | --------- | -------- | ---------------------------------- | | groupName | string | Name of the group you wish to get. |

Returns

| Name | Type | Description | | ------- | -------- | ---------------------------- | | groupId | string | ID of the group you ensured. |

Example

const groupId = await ensureGroupWithNameExistsAsync("Expo programmers")

deleteGroupWithNameAsync

iOS only

deleteGroupWithNameAsync(groupName: string): Promise<any>

Query a group by name, and delete it.

Parameters

| Name | Type | Description | | --------- | -------- | ------------------------------------- | | groupName | string | Name of the group you want to delete. |

Example

await deleteGroupWithNameAsync("Xamarin programmers")

removeAllChildrenFromGroupWithNameAsync

iOS only

removeAllChildrenFromGroupWithNameAsync(groupName: string): Promise<any>

Delete all the contacts from a group.

Parameters | Name | Type | Description | | ------- | --------- | ------------------------------------------------ | | groupName | string | Name of the target group. |

Example

await removeAllChildrenFromGroupWithNameAsync("Xamarin Devs")

presentNewContactFormAsync

presentNewContactFormAsync(options: ContactFormOptions): Promise<any>

Present a native modal for adding a new system contact.

Parameters

| Name | Type | Description | | ------- | -------------------- | ------------------------------------------------- | | options | ContactFormOptions | The configuration used for customizing the modal. |

Example

await presentNewContactFormAsync({ contact, options })

presentUnknownContactFormAsync

presentUnknownContactFormAsync(options: ContactFormOptions): Promise<any>

Present a native modal for an unknown contact.

Parameters

| Name | Type | Description | | ------- | -------------------- | ------------------------------------------------- | | options | ContactFormOptions | The configuration used for customizing the modal. |

Example

const data = await presentUnknownContactFormAsync({ contact, options })

presentContactInfoFormAsync

presentContactInfoFormAsync(options: ContactFormOptions): Promise<any>

Present a native modal for inspecting contact information.

Parameters

| Name | Type | Description | | ------- | -------------------- | ------------------------------------------------- | | options | ContactFormOptions | The configuration used for customizing the modal. |

Example

await presentContactInfoFormAsync({ contact, options })

Types

ContactFormOptions

| Name | Type | Description | | ------- | --------- | ---------------------------------- | | contact | Contact | Contact information for the modal. | | options | Object | Configuration data for the modal. |