Skip to content

Helpers.relation()

Javi Jiménez edited this page Jun 26, 2016 · 4 revisions

Extract the relation value of a determinate array key list:

Example

import { relation } from 'ava-ia/lib/helpers'

const { location, when } = relation(['when', 'location'], state);

Definition

'use strict';

export default (keys, state) => {
  const relations = state.relations || {};
  let found = {};
  keys.filter(key => relations[key] ? found[key] = relations[key].text : null)

  return found;
}

Feel free to offer new features, improvements or anything you can think of. This project makes sense with your participation and experience using Ava.

Clone this wiki locally