@surix/data-util
TypeScript icon, indicating that this package has built-in type declarations

0.1.3 • Public • Published

@surix/data-util

This library implements a set of utilities and wrappers that make it easier to work with data objects from the Surix API (e.g. entities).

These wrappers are used by the official client libraries to abstract away the raw Surix API data from the developer.

Usage

EntityWrapper class

import { EntityWrapper } from '@surix/data-util';

const raw = getRawEntityFromApi();
const wrapped = new EntityWrapper(raw);

const code = wrapped.value('address.country.code', 'KE');

// using raw entity, to avoid getting 'undefined' errors, we have to check whether each field exists
const codeFromRaw = raw.data.address
  && raw.data.address.value.country
  && raw.data.address.country.value.code
  && raw.data.address.country.value.code.value || 'KE';

Readme

Keywords

none

Package Sidebar

Install

npm i @surix/data-util

Weekly Downloads

1

Version

0.1.3

License

MIT

Unpacked Size

755 kB

Total Files

17

Last publish

Collaborators

  • grafitto
  • habbes
  • amuser