import _ from './utils';

export default {
  has: (value = {}, conditions = {}) => {
    if (!_.isObject(conditions)) return false;
    if (_.isArray(value)) return !!_.find(value, conditions);
    if (_.isObject(value)) return !!_.find(value.transitions, conditions);
    return false;
  },

  find: (value = {}, conditions = {}) => {
    if (!_.isObject(conditions) && typeof (conditions) !== 'function') return undefined;
    if (_.isArray(value)) return _.find(value, conditions);
    if (_.isObject(value)) return _.find(value.transitions, conditions);
    return undefined;
  },

  filter: (value = {}, conditions = {}) => {
    if (!_.isObject(conditions) && typeof (conditions) !== 'function') return [];
    if (_.isArray(value)) return _.filter(value, conditions);
    if (_.isObject(value)) return _.filter(value.transitions, conditions);
    return [];
  },

  metaAttributes: (obj = {}) => {
    if (!_.isObject(obj)) return {};
    if (!_.isObject(obj.meta)) return {};
    return obj.meta.attributes || {};
  },

  metaLinks: (obj = {}) => {
    if (!_.isObject(obj)) return [];
    if (!_.isObject(obj.meta)) return [];
    return obj.meta.links || [];
  },

  attributes: (obj = {}) => {
    if (!_.isObject(obj)) return {};
    return obj.attributes || {};
  },

  transitions: (obj = {}) => {
    if (!_.isObject(obj)) return [];
    return obj.transitions || [];
  },

  get: _.get,
};

@@ -23,178 +23,79 @@
 ';%0A%0A
-export default %7B%0A  has: (value = %7B%7D, conditions = %7B%7D) =%3E %7B%0A    if (!_.isObject(conditions)) return false;%0A    if (_.isArray(value)) return !!_.find(value, conditions);%0A  
+function getTransitions(value) %7B%0A  if (_.isArray(value)) return value;%0A
   if
@@ -126,17 +126,8 @@
 urn 
-!!_.find(
 valu
@@ -143,265 +143,180 @@
 ions
-, conditions);%0A    return false;%0A  %7D,%0A%0A  find: (value = %7B%7D, conditions = %7B%7D) =%3E %7B%0A    if (!_.isObject(conditions) && typeof (conditions) !== 'function') return undefined;%0A    if (_.isArray(value)) return _.find(value, conditions);%0A    if (_.isObject(value))
+;%0A%7D%0A%0Aexport default %7B%0A  has: (value = %7B%7D, conditions = %7B%7D) =%3E %7B%0A    return !!_.find(getTransitions(value), conditions);%0A  %7D,%0A%0A  find: (value = %7B%7D, conditions = %7B%7D) =%3E %7B%0A   
  ret
@@ -326,23 +326,20 @@
  _.find(
-value.t
+getT
 ransitio
@@ -332,32 +332,39 @@
 d(getTransitions
+(value)
 , conditions);%0A 
@@ -366,30 +366,8 @@
 s);%0A
-    return undefined;%0A
   %7D,
@@ -421,236 +421,58 @@
     
-if (!_.isObject(conditions) && typeof (conditions) !== 'function') return %5B%5D;%0A    if (_.isArray(value)) return _.filter(value, conditions);%0A    if (_.isObject(value)) return _.filter(value.transitions, conditions);%0A    return %5B%5D
+return _.filter(getTransitions(value), conditions)
 ;%0A  

Trim code a little more